babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038
  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. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * 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.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * 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.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * 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).
  4312. * 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.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @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.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @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)
  7481. * @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)
  7482. * @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)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * 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.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7582. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7583. */
  7584. preserveParentRotationForBillboard: boolean;
  7585. /**
  7586. * 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
  7587. */
  7588. scalingDeterminant: number;
  7589. /**
  7590. * Sets the distance of the object to max, often used by skybox
  7591. */
  7592. infiniteDistance: boolean;
  7593. /**
  7594. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7595. * By default the system will update normals to compensate
  7596. */
  7597. ignoreNonUniformScaling: boolean;
  7598. /** @hidden */
  7599. _poseMatrix: Matrix;
  7600. /** @hidden */
  7601. _localMatrix: Matrix;
  7602. private _absolutePosition;
  7603. private _pivotMatrix;
  7604. private _pivotMatrixInverse;
  7605. protected _postMultiplyPivotMatrix: boolean;
  7606. private _tempMatrix;
  7607. private _tempMatrix2;
  7608. protected _isWorldMatrixFrozen: boolean;
  7609. /** @hidden */
  7610. _indexInSceneTransformNodesArray: number;
  7611. /**
  7612. * An event triggered after the world matrix is updated
  7613. */
  7614. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7615. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7616. /**
  7617. * Gets a string identifying the name of the class
  7618. * @returns "TransformNode" string
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7623. */
  7624. position: Vector3;
  7625. /**
  7626. * 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)).
  7627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7628. */
  7629. rotation: Vector3;
  7630. /**
  7631. * 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)).
  7632. */
  7633. scaling: Vector3;
  7634. /**
  7635. * 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).
  7636. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7637. */
  7638. rotationQuaternion: Nullable<Quaternion>;
  7639. /**
  7640. * The forward direction of that transform in world space.
  7641. */
  7642. readonly forward: Vector3;
  7643. /**
  7644. * The up direction of that transform in world space.
  7645. */
  7646. readonly up: Vector3;
  7647. /**
  7648. * The right direction of that transform in world space.
  7649. */
  7650. readonly right: Vector3;
  7651. /**
  7652. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7653. * @param matrix the matrix to copy the pose from
  7654. * @returns this TransformNode.
  7655. */
  7656. updatePoseMatrix(matrix: Matrix): TransformNode;
  7657. /**
  7658. * Returns the mesh Pose matrix.
  7659. * @returns the pose matrix
  7660. */
  7661. getPoseMatrix(): Matrix;
  7662. /** @hidden */
  7663. _isSynchronized(): boolean;
  7664. /** @hidden */
  7665. _initCache(): void;
  7666. /**
  7667. * Flag the transform node as dirty (Forcing it to update everything)
  7668. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7669. * @returns this transform node
  7670. */
  7671. markAsDirty(property: string): TransformNode;
  7672. /**
  7673. * Returns the current mesh absolute position.
  7674. * Returns a Vector3.
  7675. */
  7676. readonly absolutePosition: Vector3;
  7677. /**
  7678. * Sets a new matrix to apply before all other transformation
  7679. * @param matrix defines the transform matrix
  7680. * @returns the current TransformNode
  7681. */
  7682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7683. /**
  7684. * Sets a new pivot matrix to the current node
  7685. * @param matrix defines the new pivot matrix to use
  7686. * @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
  7687. * @returns the current TransformNode
  7688. */
  7689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7690. /**
  7691. * Returns the mesh pivot matrix.
  7692. * Default : Identity.
  7693. * @returns the matrix
  7694. */
  7695. getPivotMatrix(): Matrix;
  7696. /**
  7697. * Prevents the World matrix to be computed any longer.
  7698. * @returns the TransformNode.
  7699. */
  7700. freezeWorldMatrix(): TransformNode;
  7701. /**
  7702. * Allows back the World matrix computation.
  7703. * @returns the TransformNode.
  7704. */
  7705. unfreezeWorldMatrix(): this;
  7706. /**
  7707. * True if the World matrix has been frozen.
  7708. */
  7709. readonly isWorldMatrixFrozen: boolean;
  7710. /**
  7711. * Retuns the mesh absolute position in the World.
  7712. * @returns a Vector3.
  7713. */
  7714. getAbsolutePosition(): Vector3;
  7715. /**
  7716. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7717. * @param absolutePosition the absolute position to set
  7718. * @returns the TransformNode.
  7719. */
  7720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7721. /**
  7722. * Sets the mesh position in its local space.
  7723. * @param vector3 the position to set in localspace
  7724. * @returns the TransformNode.
  7725. */
  7726. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7727. /**
  7728. * Returns the mesh position in the local space from the current World matrix values.
  7729. * @returns a new Vector3.
  7730. */
  7731. getPositionExpressedInLocalSpace(): Vector3;
  7732. /**
  7733. * Translates the mesh along the passed Vector3 in its local space.
  7734. * @param vector3 the distance to translate in localspace
  7735. * @returns the TransformNode.
  7736. */
  7737. locallyTranslate(vector3: Vector3): TransformNode;
  7738. private static _lookAtVectorCache;
  7739. /**
  7740. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7741. * @param targetPoint the position (must be in same space as current mesh) to look at
  7742. * @param yawCor optional yaw (y-axis) correction in radians
  7743. * @param pitchCor optional pitch (x-axis) correction in radians
  7744. * @param rollCor optional roll (z-axis) correction in radians
  7745. * @param space the choosen space of the target
  7746. * @returns the TransformNode.
  7747. */
  7748. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7749. /**
  7750. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7751. * This Vector3 is expressed in the World space.
  7752. * @param localAxis axis to rotate
  7753. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7754. */
  7755. getDirection(localAxis: Vector3): Vector3;
  7756. /**
  7757. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7758. * localAxis is expressed in the mesh local space.
  7759. * result is computed in the Wordl space from the mesh World matrix.
  7760. * @param localAxis axis to rotate
  7761. * @param result the resulting transformnode
  7762. * @returns this TransformNode.
  7763. */
  7764. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7765. /**
  7766. * Sets this transform node rotation to the given local axis.
  7767. * @param localAxis the axis in local space
  7768. * @param yawCor optional yaw (y-axis) correction in radians
  7769. * @param pitchCor optional pitch (x-axis) correction in radians
  7770. * @param rollCor optional roll (z-axis) correction in radians
  7771. * @returns this TransformNode
  7772. */
  7773. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7774. /**
  7775. * Sets a new pivot point to the current node
  7776. * @param point defines the new pivot point to use
  7777. * @param space defines if the point is in world or local space (local by default)
  7778. * @returns the current TransformNode
  7779. */
  7780. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7781. /**
  7782. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7783. * @returns the pivot point
  7784. */
  7785. getPivotPoint(): Vector3;
  7786. /**
  7787. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7788. * @param result the vector3 to store the result
  7789. * @returns this TransformNode.
  7790. */
  7791. getPivotPointToRef(result: Vector3): TransformNode;
  7792. /**
  7793. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7794. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7795. */
  7796. getAbsolutePivotPoint(): Vector3;
  7797. /**
  7798. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7799. * @param result vector3 to store the result
  7800. * @returns this TransformNode.
  7801. */
  7802. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7803. /**
  7804. * Defines the passed node as the parent of the current node.
  7805. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7806. * @see https://doc.babylonjs.com/how_to/parenting
  7807. * @param node the node ot set as the parent
  7808. * @returns this TransformNode.
  7809. */
  7810. setParent(node: Nullable<Node>): TransformNode;
  7811. private _nonUniformScaling;
  7812. /**
  7813. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7814. */
  7815. readonly nonUniformScaling: boolean;
  7816. /** @hidden */
  7817. _updateNonUniformScalingState(value: boolean): boolean;
  7818. /**
  7819. * Attach the current TransformNode to another TransformNode associated with a bone
  7820. * @param bone Bone affecting the TransformNode
  7821. * @param affectedTransformNode TransformNode associated with the bone
  7822. * @returns this object
  7823. */
  7824. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7825. /**
  7826. * Detach the transform node if its associated with a bone
  7827. * @returns this object
  7828. */
  7829. detachFromBone(): TransformNode;
  7830. private static _rotationAxisCache;
  7831. /**
  7832. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7833. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7834. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7835. * The passed axis is also normalized.
  7836. * @param axis the axis to rotate around
  7837. * @param amount the amount to rotate in radians
  7838. * @param space Space to rotate in (Default: local)
  7839. * @returns the TransformNode.
  7840. */
  7841. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7842. /**
  7843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7844. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7845. * The passed axis is also normalized. .
  7846. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7847. * @param point the point to rotate around
  7848. * @param axis the axis to rotate around
  7849. * @param amount the amount to rotate in radians
  7850. * @returns the TransformNode
  7851. */
  7852. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7853. /**
  7854. * Translates the mesh along the axis vector for the passed distance in the given space.
  7855. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7856. * @param axis the axis to translate in
  7857. * @param distance the distance to translate
  7858. * @param space Space to rotate in (Default: local)
  7859. * @returns the TransformNode.
  7860. */
  7861. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7862. /**
  7863. * Adds a rotation step to the mesh current rotation.
  7864. * x, y, z are Euler angles expressed in radians.
  7865. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7866. * This means this rotation is made in the mesh local space only.
  7867. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7868. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7869. * ```javascript
  7870. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7871. * ```
  7872. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7873. * 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.
  7874. * @param x Rotation to add
  7875. * @param y Rotation to add
  7876. * @param z Rotation to add
  7877. * @returns the TransformNode.
  7878. */
  7879. addRotation(x: number, y: number, z: number): TransformNode;
  7880. /**
  7881. * @hidden
  7882. */
  7883. protected _getEffectiveParent(): Nullable<Node>;
  7884. /**
  7885. * Computes the world matrix of the node
  7886. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7887. * @returns the world matrix
  7888. */
  7889. computeWorldMatrix(force?: boolean): Matrix;
  7890. protected _afterComputeWorldMatrix(): void;
  7891. /**
  7892. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7893. * @param func callback function to add
  7894. *
  7895. * @returns the TransformNode.
  7896. */
  7897. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7898. /**
  7899. * Removes a registered callback function.
  7900. * @param func callback function to remove
  7901. * @returns the TransformNode.
  7902. */
  7903. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7904. /**
  7905. * Gets the position of the current mesh in camera space
  7906. * @param camera defines the camera to use
  7907. * @returns a position
  7908. */
  7909. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7910. /**
  7911. * Returns the distance from the mesh to the active camera
  7912. * @param camera defines the camera to use
  7913. * @returns the distance
  7914. */
  7915. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7916. /**
  7917. * Clone the current transform node
  7918. * @param name Name of the new clone
  7919. * @param newParent New parent for the clone
  7920. * @param doNotCloneChildren Do not clone children hierarchy
  7921. * @returns the new transform node
  7922. */
  7923. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7924. /**
  7925. * Serializes the objects information.
  7926. * @param currentSerializationObject defines the object to serialize in
  7927. * @returns the serialized object
  7928. */
  7929. serialize(currentSerializationObject?: any): any;
  7930. /**
  7931. * Returns a new TransformNode object parsed from the source provided.
  7932. * @param parsedTransformNode is the source.
  7933. * @param scene the scne the object belongs to
  7934. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7935. * @returns a new TransformNode object parsed from the source provided.
  7936. */
  7937. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7938. /**
  7939. * Get all child-transformNodes of this node
  7940. * @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
  7941. * @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
  7942. * @returns an array of TransformNode
  7943. */
  7944. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7945. /**
  7946. * Releases resources associated with this transform node.
  7947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7949. */
  7950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7951. }
  7952. }
  7953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7954. /**
  7955. * Class used to override all child animations of a given target
  7956. */
  7957. export class AnimationPropertiesOverride {
  7958. /**
  7959. * Gets or sets a value indicating if animation blending must be used
  7960. */
  7961. enableBlending: boolean;
  7962. /**
  7963. * Gets or sets the blending speed to use when enableBlending is true
  7964. */
  7965. blendingSpeed: number;
  7966. /**
  7967. * Gets or sets the default loop mode to use
  7968. */
  7969. loopMode: number;
  7970. }
  7971. }
  7972. declare module "babylonjs/Bones/bone" {
  7973. import { Skeleton } from "babylonjs/Bones/skeleton";
  7974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7975. import { Nullable } from "babylonjs/types";
  7976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7978. import { Node } from "babylonjs/node";
  7979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7980. /**
  7981. * Class used to store bone information
  7982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7983. */
  7984. export class Bone extends Node {
  7985. /**
  7986. * defines the bone name
  7987. */
  7988. name: string;
  7989. private static _tmpVecs;
  7990. private static _tmpQuat;
  7991. private static _tmpMats;
  7992. /**
  7993. * Gets the list of child bones
  7994. */
  7995. children: Bone[];
  7996. /** Gets the animations associated with this bone */
  7997. animations: import("babylonjs/Animations/animation").Animation[];
  7998. /**
  7999. * Gets or sets bone length
  8000. */
  8001. length: number;
  8002. /**
  8003. * @hidden Internal only
  8004. * Set this value to map this bone to a different index in the transform matrices
  8005. * Set this value to -1 to exclude the bone from the transform matrices
  8006. */
  8007. _index: Nullable<number>;
  8008. private _skeleton;
  8009. private _localMatrix;
  8010. private _restPose;
  8011. private _baseMatrix;
  8012. private _absoluteTransform;
  8013. private _invertedAbsoluteTransform;
  8014. private _parent;
  8015. private _scalingDeterminant;
  8016. private _worldTransform;
  8017. private _localScaling;
  8018. private _localRotation;
  8019. private _localPosition;
  8020. private _needToDecompose;
  8021. private _needToCompose;
  8022. /** @hidden */
  8023. _linkedTransformNode: Nullable<TransformNode>;
  8024. /** @hidden */
  8025. /** @hidden */
  8026. _matrix: Matrix;
  8027. /**
  8028. * Create a new bone
  8029. * @param name defines the bone name
  8030. * @param skeleton defines the parent skeleton
  8031. * @param parentBone defines the parent (can be null if the bone is the root)
  8032. * @param localMatrix defines the local matrix
  8033. * @param restPose defines the rest pose matrix
  8034. * @param baseMatrix defines the base matrix
  8035. * @param index defines index of the bone in the hiearchy
  8036. */
  8037. constructor(
  8038. /**
  8039. * defines the bone name
  8040. */
  8041. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8042. /**
  8043. * Gets the current object class name.
  8044. * @return the class name
  8045. */
  8046. getClassName(): string;
  8047. /**
  8048. * Gets the parent skeleton
  8049. * @returns a skeleton
  8050. */
  8051. getSkeleton(): Skeleton;
  8052. /**
  8053. * Gets parent bone
  8054. * @returns a bone or null if the bone is the root of the bone hierarchy
  8055. */
  8056. getParent(): Nullable<Bone>;
  8057. /**
  8058. * Returns an array containing the root bones
  8059. * @returns an array containing the root bones
  8060. */
  8061. getChildren(): Array<Bone>;
  8062. /**
  8063. * Sets the parent bone
  8064. * @param parent defines the parent (can be null if the bone is the root)
  8065. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8066. */
  8067. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8068. /**
  8069. * Gets the local matrix
  8070. * @returns a matrix
  8071. */
  8072. getLocalMatrix(): Matrix;
  8073. /**
  8074. * Gets the base matrix (initial matrix which remains unchanged)
  8075. * @returns a matrix
  8076. */
  8077. getBaseMatrix(): Matrix;
  8078. /**
  8079. * Gets the rest pose matrix
  8080. * @returns a matrix
  8081. */
  8082. getRestPose(): Matrix;
  8083. /**
  8084. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8085. */
  8086. getWorldMatrix(): Matrix;
  8087. /**
  8088. * Sets the local matrix to rest pose matrix
  8089. */
  8090. returnToRest(): void;
  8091. /**
  8092. * Gets the inverse of the absolute transform matrix.
  8093. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8094. * @returns a matrix
  8095. */
  8096. getInvertedAbsoluteTransform(): Matrix;
  8097. /**
  8098. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8099. * @returns a matrix
  8100. */
  8101. getAbsoluteTransform(): Matrix;
  8102. /**
  8103. * Links with the given transform node.
  8104. * The local matrix of this bone is copied from the transform node every frame.
  8105. * @param transformNode defines the transform node to link to
  8106. */
  8107. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8108. /** Gets or sets current position (in local space) */
  8109. position: Vector3;
  8110. /** Gets or sets current rotation (in local space) */
  8111. rotation: Vector3;
  8112. /** Gets or sets current rotation quaternion (in local space) */
  8113. rotationQuaternion: Quaternion;
  8114. /** Gets or sets current scaling (in local space) */
  8115. scaling: Vector3;
  8116. /**
  8117. * Gets the animation properties override
  8118. */
  8119. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8120. private _decompose;
  8121. private _compose;
  8122. /**
  8123. * Update the base and local matrices
  8124. * @param matrix defines the new base or local matrix
  8125. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8126. * @param updateLocalMatrix defines if the local matrix should be updated
  8127. */
  8128. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8129. /** @hidden */
  8130. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8131. /**
  8132. * Flag the bone as dirty (Forcing it to update everything)
  8133. */
  8134. markAsDirty(): void;
  8135. private _markAsDirtyAndCompose;
  8136. private _markAsDirtyAndDecompose;
  8137. /**
  8138. * Translate the bone in local or world space
  8139. * @param vec The amount to translate the bone
  8140. * @param space The space that the translation is in
  8141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8142. */
  8143. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8144. /**
  8145. * Set the postion of the bone in local or world space
  8146. * @param position The position to set the bone
  8147. * @param space The space that the position is in
  8148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8149. */
  8150. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8151. /**
  8152. * Set the absolute position of the bone (world space)
  8153. * @param position The position to set the bone
  8154. * @param mesh The mesh that this bone is attached to
  8155. */
  8156. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8157. /**
  8158. * Scale the bone on the x, y and z axes (in local space)
  8159. * @param x The amount to scale the bone on the x axis
  8160. * @param y The amount to scale the bone on the y axis
  8161. * @param z The amount to scale the bone on the z axis
  8162. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8163. */
  8164. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8165. /**
  8166. * Set the bone scaling in local space
  8167. * @param scale defines the scaling vector
  8168. */
  8169. setScale(scale: Vector3): void;
  8170. /**
  8171. * Gets the current scaling in local space
  8172. * @returns the current scaling vector
  8173. */
  8174. getScale(): Vector3;
  8175. /**
  8176. * Gets the current scaling in local space and stores it in a target vector
  8177. * @param result defines the target vector
  8178. */
  8179. getScaleToRef(result: Vector3): void;
  8180. /**
  8181. * Set the yaw, pitch, and roll of the bone in local or world space
  8182. * @param yaw The rotation of the bone on the y axis
  8183. * @param pitch The rotation of the bone on the x axis
  8184. * @param roll The rotation of the bone on the z axis
  8185. * @param space The space that the axes of rotation are in
  8186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8187. */
  8188. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8189. /**
  8190. * Add a rotation to the bone on an axis in local or world space
  8191. * @param axis The axis to rotate the bone on
  8192. * @param amount The amount to rotate the bone
  8193. * @param space The space that the axis is in
  8194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8195. */
  8196. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8197. /**
  8198. * Set the rotation of the bone to a particular axis angle in local or world space
  8199. * @param axis The axis to rotate the bone on
  8200. * @param angle The angle that the bone should be rotated to
  8201. * @param space The space that the axis is in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. */
  8204. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8205. /**
  8206. * Set the euler rotation of the bone in local of world space
  8207. * @param rotation The euler rotation that the bone should be set to
  8208. * @param space The space that the rotation is in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. */
  8211. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8212. /**
  8213. * Set the quaternion rotation of the bone in local of world space
  8214. * @param quat The quaternion rotation that the bone should be set to
  8215. * @param space The space that the rotation is in
  8216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8217. */
  8218. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8219. /**
  8220. * Set the rotation matrix of the bone in local of world space
  8221. * @param rotMat The rotation matrix that the bone should be set to
  8222. * @param space The space that the rotation is in
  8223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8224. */
  8225. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8226. private _rotateWithMatrix;
  8227. private _getNegativeRotationToRef;
  8228. /**
  8229. * Get the position of the bone in local or world space
  8230. * @param space The space that the returned position is in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @returns The position of the bone
  8233. */
  8234. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8235. /**
  8236. * Copy the position of the bone to a vector3 in local or world space
  8237. * @param space The space that the returned position is in
  8238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8239. * @param result The vector3 to copy the position to
  8240. */
  8241. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8242. /**
  8243. * Get the absolute position of the bone (world space)
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @returns The absolute position of the bone
  8246. */
  8247. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8248. /**
  8249. * Copy the absolute position of the bone (world space) to the result param
  8250. * @param mesh The mesh that this bone is attached to
  8251. * @param result The vector3 to copy the absolute position to
  8252. */
  8253. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8254. /**
  8255. * Compute the absolute transforms of this bone and its children
  8256. */
  8257. computeAbsoluteTransforms(): void;
  8258. /**
  8259. * Get the world direction from an axis that is in the local space of the bone
  8260. * @param localAxis The local direction that is used to compute the world direction
  8261. * @param mesh The mesh that this bone is attached to
  8262. * @returns The world direction
  8263. */
  8264. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8265. /**
  8266. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8267. * @param localAxis The local direction that is used to compute the world direction
  8268. * @param mesh The mesh that this bone is attached to
  8269. * @param result The vector3 that the world direction will be copied to
  8270. */
  8271. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8272. /**
  8273. * Get the euler rotation of the bone in local or world space
  8274. * @param space The space that the rotation should be in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @returns The euler rotation
  8277. */
  8278. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8279. /**
  8280. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8281. * @param space The space that the rotation should be in
  8282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8283. * @param result The vector3 that the rotation should be copied to
  8284. */
  8285. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8286. /**
  8287. * Get the quaternion rotation of the bone in either local or world space
  8288. * @param space The space that the rotation should be in
  8289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8290. * @returns The quaternion rotation
  8291. */
  8292. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8293. /**
  8294. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8295. * @param space The space that the rotation should be in
  8296. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8297. * @param result The quaternion that the rotation should be copied to
  8298. */
  8299. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8300. /**
  8301. * Get the rotation matrix of the bone in local or world space
  8302. * @param space The space that the rotation should be in
  8303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8304. * @returns The rotation matrix
  8305. */
  8306. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8307. /**
  8308. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8309. * @param space The space that the rotation should be in
  8310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8311. * @param result The quaternion that the rotation should be copied to
  8312. */
  8313. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8314. /**
  8315. * Get the world position of a point that is in the local space of the bone
  8316. * @param position The local position
  8317. * @param mesh The mesh that this bone is attached to
  8318. * @returns The world position
  8319. */
  8320. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8321. /**
  8322. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8323. * @param position The local position
  8324. * @param mesh The mesh that this bone is attached to
  8325. * @param result The vector3 that the world position should be copied to
  8326. */
  8327. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8328. /**
  8329. * Get the local position of a point that is in world space
  8330. * @param position The world position
  8331. * @param mesh The mesh that this bone is attached to
  8332. * @returns The local position
  8333. */
  8334. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8335. /**
  8336. * Get the local position of a point that is in world space and copy it to the result param
  8337. * @param position The world position
  8338. * @param mesh The mesh that this bone is attached to
  8339. * @param result The vector3 that the local position should be copied to
  8340. */
  8341. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8342. }
  8343. }
  8344. declare module "babylonjs/Misc/iInspectable" {
  8345. /**
  8346. * Enum that determines the text-wrapping mode to use.
  8347. */
  8348. export enum InspectableType {
  8349. /**
  8350. * Checkbox for booleans
  8351. */
  8352. Checkbox = 0,
  8353. /**
  8354. * Sliders for numbers
  8355. */
  8356. Slider = 1,
  8357. /**
  8358. * Vector3
  8359. */
  8360. Vector3 = 2,
  8361. /**
  8362. * Quaternions
  8363. */
  8364. Quaternion = 3,
  8365. /**
  8366. * Color3
  8367. */
  8368. Color3 = 4
  8369. }
  8370. /**
  8371. * Interface used to define custom inspectable properties.
  8372. * This interface is used by the inspector to display custom property grids
  8373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8374. */
  8375. export interface IInspectable {
  8376. /**
  8377. * Gets the label to display
  8378. */
  8379. label: string;
  8380. /**
  8381. * Gets the name of the property to edit
  8382. */
  8383. propertyName: string;
  8384. /**
  8385. * Gets the type of the editor to use
  8386. */
  8387. type: InspectableType;
  8388. /**
  8389. * Gets the minimum value of the property when using in "slider" mode
  8390. */
  8391. min?: number;
  8392. /**
  8393. * Gets the maximum value of the property when using in "slider" mode
  8394. */
  8395. max?: number;
  8396. /**
  8397. * Gets the setp to use when using in "slider" mode
  8398. */
  8399. step?: number;
  8400. }
  8401. }
  8402. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8403. import { Nullable } from "babylonjs/types";
  8404. import { Scene } from "babylonjs/scene";
  8405. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8407. /**
  8408. * Class for creating a cube texture
  8409. */
  8410. export class CubeTexture extends BaseTexture {
  8411. private _delayedOnLoad;
  8412. /**
  8413. * The url of the texture
  8414. */
  8415. url: string;
  8416. /**
  8417. * Gets or sets the center of the bounding box associated with the cube texture.
  8418. * It must define where the camera used to render the texture was set
  8419. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8420. */
  8421. boundingBoxPosition: Vector3;
  8422. private _boundingBoxSize;
  8423. /**
  8424. * Gets or sets the size of the bounding box associated with the cube texture
  8425. * When defined, the cubemap will switch to local mode
  8426. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8427. * @example https://www.babylonjs-playground.com/#RNASML
  8428. */
  8429. /**
  8430. * Returns the bounding box size
  8431. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8432. */
  8433. boundingBoxSize: Vector3;
  8434. protected _rotationY: number;
  8435. /**
  8436. * Sets texture matrix rotation angle around Y axis in radians.
  8437. */
  8438. /**
  8439. * Gets texture matrix rotation angle around Y axis radians.
  8440. */
  8441. rotationY: number;
  8442. /**
  8443. * Are mip maps generated for this texture or not.
  8444. */
  8445. readonly noMipmap: boolean;
  8446. private _noMipmap;
  8447. private _files;
  8448. private _extensions;
  8449. private _textureMatrix;
  8450. private _format;
  8451. private _createPolynomials;
  8452. /** @hidden */
  8453. _prefiltered: boolean;
  8454. /**
  8455. * Creates a cube texture from an array of image urls
  8456. * @param files defines an array of image urls
  8457. * @param scene defines the hosting scene
  8458. * @param noMipmap specifies if mip maps are not used
  8459. * @returns a cube texture
  8460. */
  8461. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8462. /**
  8463. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8464. * @param url defines the url of the prefiltered texture
  8465. * @param scene defines the scene the texture is attached to
  8466. * @param forcedExtension defines the extension of the file if different from the url
  8467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8468. * @return the prefiltered texture
  8469. */
  8470. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8471. /**
  8472. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8473. * as prefiltered data.
  8474. * @param rootUrl defines the url of the texture or the root name of the six images
  8475. * @param scene defines the scene the texture is attached to
  8476. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8477. * @param noMipmap defines if mipmaps should be created or not
  8478. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8479. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8480. * @param onError defines a callback triggered in case of error during load
  8481. * @param format defines the internal format to use for the texture once loaded
  8482. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8483. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8484. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8487. * @return the cube texture
  8488. */
  8489. 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);
  8490. /**
  8491. * Get the current class name of the texture useful for serialization or dynamic coding.
  8492. * @returns "CubeTexture"
  8493. */
  8494. getClassName(): string;
  8495. /**
  8496. * Update the url (and optional buffer) of this texture if url was null during construction.
  8497. * @param url the url of the texture
  8498. * @param forcedExtension defines the extension to use
  8499. * @param onLoad callback called when the texture is loaded (defaults to null)
  8500. */
  8501. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8502. /**
  8503. * Delays loading of the cube texture
  8504. * @param forcedExtension defines the extension to use
  8505. */
  8506. delayLoad(forcedExtension?: string): void;
  8507. /**
  8508. * Returns the reflection texture matrix
  8509. * @returns the reflection texture matrix
  8510. */
  8511. getReflectionTextureMatrix(): Matrix;
  8512. /**
  8513. * Sets the reflection texture matrix
  8514. * @param value Reflection texture matrix
  8515. */
  8516. setReflectionTextureMatrix(value: Matrix): void;
  8517. /**
  8518. * Parses text to create a cube texture
  8519. * @param parsedTexture define the serialized text to read from
  8520. * @param scene defines the hosting scene
  8521. * @param rootUrl defines the root url of the cube texture
  8522. * @returns a cube texture
  8523. */
  8524. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8525. /**
  8526. * Makes a clone, or deep copy, of the cube texture
  8527. * @returns a new cube texture
  8528. */
  8529. clone(): CubeTexture;
  8530. }
  8531. }
  8532. declare module "babylonjs/Shaders/postprocess.vertex" {
  8533. /** @hidden */
  8534. export var postprocessVertexShader: {
  8535. name: string;
  8536. shader: string;
  8537. };
  8538. }
  8539. declare module "babylonjs/Cameras/targetCamera" {
  8540. import { Nullable } from "babylonjs/types";
  8541. import { Camera } from "babylonjs/Cameras/camera";
  8542. import { Scene } from "babylonjs/scene";
  8543. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8544. /**
  8545. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8546. * This is the base of the follow, arc rotate cameras and Free camera
  8547. * @see http://doc.babylonjs.com/features/cameras
  8548. */
  8549. export class TargetCamera extends Camera {
  8550. private static _RigCamTransformMatrix;
  8551. private static _TargetTransformMatrix;
  8552. private static _TargetFocalPoint;
  8553. /**
  8554. * Define the current direction the camera is moving to
  8555. */
  8556. cameraDirection: Vector3;
  8557. /**
  8558. * Define the current rotation the camera is rotating to
  8559. */
  8560. cameraRotation: Vector2;
  8561. /**
  8562. * When set, the up vector of the camera will be updated by the rotation of the camera
  8563. */
  8564. updateUpVectorFromRotation: boolean;
  8565. private _tmpQuaternion;
  8566. /**
  8567. * Define the current rotation of the camera
  8568. */
  8569. rotation: Vector3;
  8570. /**
  8571. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8572. */
  8573. rotationQuaternion: Quaternion;
  8574. /**
  8575. * Define the current speed of the camera
  8576. */
  8577. speed: number;
  8578. /**
  8579. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8580. * around all axis.
  8581. */
  8582. noRotationConstraint: boolean;
  8583. /**
  8584. * Define the current target of the camera as an object or a position.
  8585. */
  8586. lockedTarget: any;
  8587. /** @hidden */
  8588. _currentTarget: Vector3;
  8589. /** @hidden */
  8590. _initialFocalDistance: number;
  8591. /** @hidden */
  8592. _viewMatrix: Matrix;
  8593. /** @hidden */
  8594. _camMatrix: Matrix;
  8595. /** @hidden */
  8596. _cameraTransformMatrix: Matrix;
  8597. /** @hidden */
  8598. _cameraRotationMatrix: Matrix;
  8599. /** @hidden */
  8600. _referencePoint: Vector3;
  8601. /** @hidden */
  8602. _transformedReferencePoint: Vector3;
  8603. protected _globalCurrentTarget: Vector3;
  8604. protected _globalCurrentUpVector: Vector3;
  8605. /** @hidden */
  8606. _reset: () => void;
  8607. private _defaultUp;
  8608. /**
  8609. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8610. * This is the base of the follow, arc rotate cameras and Free camera
  8611. * @see http://doc.babylonjs.com/features/cameras
  8612. * @param name Defines the name of the camera in the scene
  8613. * @param position Defines the start position of the camera in the scene
  8614. * @param scene Defines the scene the camera belongs to
  8615. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8616. */
  8617. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8618. /**
  8619. * Gets the position in front of the camera at a given distance.
  8620. * @param distance The distance from the camera we want the position to be
  8621. * @returns the position
  8622. */
  8623. getFrontPosition(distance: number): Vector3;
  8624. /** @hidden */
  8625. _getLockedTargetPosition(): Nullable<Vector3>;
  8626. private _storedPosition;
  8627. private _storedRotation;
  8628. private _storedRotationQuaternion;
  8629. /**
  8630. * Store current camera state of the camera (fov, position, rotation, etc..)
  8631. * @returns the camera
  8632. */
  8633. storeState(): Camera;
  8634. /**
  8635. * Restored camera state. You must call storeState() first
  8636. * @returns whether it was successful or not
  8637. * @hidden
  8638. */
  8639. _restoreStateValues(): boolean;
  8640. /** @hidden */
  8641. _initCache(): void;
  8642. /** @hidden */
  8643. _updateCache(ignoreParentClass?: boolean): void;
  8644. /** @hidden */
  8645. _isSynchronizedViewMatrix(): boolean;
  8646. /** @hidden */
  8647. _computeLocalCameraSpeed(): number;
  8648. /**
  8649. * Defines the target the camera should look at.
  8650. * This will automatically adapt alpha beta and radius to fit within the new target.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module "babylonjs/Cameras/cameraInputsManager" {
  8693. import { Nullable } from "babylonjs/types";
  8694. import { Camera } from "babylonjs/Cameras/camera";
  8695. /**
  8696. * @ignore
  8697. * This is a list of all the different input types that are available in the application.
  8698. * Fo instance: ArcRotateCameraGamepadInput...
  8699. */
  8700. export var CameraInputTypes: {};
  8701. /**
  8702. * This is the contract to implement in order to create a new input class.
  8703. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8704. */
  8705. export interface ICameraInput<TCamera extends Camera> {
  8706. /**
  8707. * Defines the camera the input is attached to.
  8708. */
  8709. camera: Nullable<TCamera>;
  8710. /**
  8711. * Gets the class name of the current intput.
  8712. * @returns the class name
  8713. */
  8714. getClassName(): string;
  8715. /**
  8716. * Get the friendly name associated with the input class.
  8717. * @returns the input friendly name
  8718. */
  8719. getSimpleName(): string;
  8720. /**
  8721. * Attach the input controls to a specific dom element to get the input from.
  8722. * @param element Defines the element the controls should be listened from
  8723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach the current controls from the specified dom element.
  8728. * @param element Defines the element to stop listening the inputs from
  8729. */
  8730. detachControl(element: Nullable<HTMLElement>): void;
  8731. /**
  8732. * Update the current camera state depending on the inputs that have been used this frame.
  8733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8734. */
  8735. checkInputs?: () => void;
  8736. }
  8737. /**
  8738. * Represents a map of input types to input instance or input index to input instance.
  8739. */
  8740. export interface CameraInputsMap<TCamera extends Camera> {
  8741. /**
  8742. * Accessor to the input by input type.
  8743. */
  8744. [name: string]: ICameraInput<TCamera>;
  8745. /**
  8746. * Accessor to the input by input index.
  8747. */
  8748. [idx: number]: ICameraInput<TCamera>;
  8749. }
  8750. /**
  8751. * This represents the input manager used within a camera.
  8752. * It helps dealing with all the different kind of input attached to a camera.
  8753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8754. */
  8755. export class CameraInputsManager<TCamera extends Camera> {
  8756. /**
  8757. * Defines the list of inputs attahed to the camera.
  8758. */
  8759. attached: CameraInputsMap<TCamera>;
  8760. /**
  8761. * Defines the dom element the camera is collecting inputs from.
  8762. * This is null if the controls have not been attached.
  8763. */
  8764. attachedElement: Nullable<HTMLElement>;
  8765. /**
  8766. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. noPreventDefault: boolean;
  8769. /**
  8770. * Defined the camera the input manager belongs to.
  8771. */
  8772. camera: TCamera;
  8773. /**
  8774. * Update the current camera state depending on the inputs that have been used this frame.
  8775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8776. */
  8777. checkInputs: () => void;
  8778. /**
  8779. * Instantiate a new Camera Input Manager.
  8780. * @param camera Defines the camera the input manager blongs to
  8781. */
  8782. constructor(camera: TCamera);
  8783. /**
  8784. * Add an input method to a camera
  8785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8786. * @param input camera input method
  8787. */
  8788. add(input: ICameraInput<TCamera>): void;
  8789. /**
  8790. * Remove a specific input method from a camera
  8791. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8792. * @param inputToRemove camera input method
  8793. */
  8794. remove(inputToRemove: ICameraInput<TCamera>): void;
  8795. /**
  8796. * Remove a specific input type from a camera
  8797. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8798. * @param inputType the type of the input to remove
  8799. */
  8800. removeByType(inputType: string): void;
  8801. private _addCheckInputs;
  8802. /**
  8803. * Attach the input controls to the currently attached dom element to listen the events from.
  8804. * @param input Defines the input to attach
  8805. */
  8806. attachInput(input: ICameraInput<TCamera>): void;
  8807. /**
  8808. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8809. * @param element Defines the dom element to collect the events from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current manager inputs controls from a specific dom element.
  8815. * @param element Defines the dom element to collect the events from
  8816. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8817. */
  8818. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8819. /**
  8820. * Rebuild the dynamic inputCheck function from the current list of
  8821. * defined inputs in the manager.
  8822. */
  8823. rebuildInputCheck(): void;
  8824. /**
  8825. * Remove all attached input methods from a camera
  8826. */
  8827. clear(): void;
  8828. /**
  8829. * Serialize the current input manager attached to a camera.
  8830. * This ensures than once parsed,
  8831. * the input associated to the camera will be identical to the current ones
  8832. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8833. */
  8834. serialize(serializedCamera: any): void;
  8835. /**
  8836. * Parses an input manager serialized JSON to restore the previous list of inputs
  8837. * and states associated to a camera.
  8838. * @param parsedCamera Defines the JSON to parse
  8839. */
  8840. parse(parsedCamera: any): void;
  8841. }
  8842. }
  8843. declare module "babylonjs/Events/keyboardEvents" {
  8844. /**
  8845. * Gather the list of keyboard event types as constants.
  8846. */
  8847. export class KeyboardEventTypes {
  8848. /**
  8849. * The keydown event is fired when a key becomes active (pressed).
  8850. */
  8851. static readonly KEYDOWN: number;
  8852. /**
  8853. * The keyup event is fired when a key has been released.
  8854. */
  8855. static readonly KEYUP: number;
  8856. }
  8857. /**
  8858. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8859. */
  8860. export class KeyboardInfo {
  8861. /**
  8862. * Defines the type of event (KeyboardEventTypes)
  8863. */
  8864. type: number;
  8865. /**
  8866. * Defines the related dom event
  8867. */
  8868. event: KeyboardEvent;
  8869. /**
  8870. * Instantiates a new keyboard info.
  8871. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8872. * @param type Defines the type of event (KeyboardEventTypes)
  8873. * @param event Defines the related dom event
  8874. */
  8875. constructor(
  8876. /**
  8877. * Defines the type of event (KeyboardEventTypes)
  8878. */
  8879. type: number,
  8880. /**
  8881. * Defines the related dom event
  8882. */
  8883. event: KeyboardEvent);
  8884. }
  8885. /**
  8886. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8887. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8888. */
  8889. export class KeyboardInfoPre extends KeyboardInfo {
  8890. /**
  8891. * Defines the type of event (KeyboardEventTypes)
  8892. */
  8893. type: number;
  8894. /**
  8895. * Defines the related dom event
  8896. */
  8897. event: KeyboardEvent;
  8898. /**
  8899. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8900. */
  8901. skipOnPointerObservable: boolean;
  8902. /**
  8903. * Instantiates a new keyboard pre info.
  8904. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8905. * @param type Defines the type of event (KeyboardEventTypes)
  8906. * @param event Defines the related dom event
  8907. */
  8908. constructor(
  8909. /**
  8910. * Defines the type of event (KeyboardEventTypes)
  8911. */
  8912. type: number,
  8913. /**
  8914. * Defines the related dom event
  8915. */
  8916. event: KeyboardEvent);
  8917. }
  8918. }
  8919. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8920. import { Nullable } from "babylonjs/types";
  8921. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8922. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8923. /**
  8924. * Manage the keyboard inputs to control the movement of a free camera.
  8925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8926. */
  8927. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8928. /**
  8929. * Defines the camera the input is attached to.
  8930. */
  8931. camera: FreeCamera;
  8932. /**
  8933. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8934. */
  8935. keysUp: number[];
  8936. /**
  8937. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8938. */
  8939. keysDown: number[];
  8940. /**
  8941. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8942. */
  8943. keysLeft: number[];
  8944. /**
  8945. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8946. */
  8947. keysRight: number[];
  8948. private _keys;
  8949. private _onCanvasBlurObserver;
  8950. private _onKeyboardObserver;
  8951. private _engine;
  8952. private _scene;
  8953. /**
  8954. * Attach the input controls to a specific dom element to get the input from.
  8955. * @param element Defines the element the controls should be listened from
  8956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8957. */
  8958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8959. /**
  8960. * Detach the current controls from the specified dom element.
  8961. * @param element Defines the element to stop listening the inputs from
  8962. */
  8963. detachControl(element: Nullable<HTMLElement>): void;
  8964. /**
  8965. * Update the current camera state depending on the inputs that have been used this frame.
  8966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8967. */
  8968. checkInputs(): void;
  8969. /**
  8970. * Gets the class name of the current intput.
  8971. * @returns the class name
  8972. */
  8973. getClassName(): string;
  8974. /** @hidden */
  8975. _onLostFocus(): void;
  8976. /**
  8977. * Get the friendly name associated with the input class.
  8978. * @returns the input friendly name
  8979. */
  8980. getSimpleName(): string;
  8981. }
  8982. }
  8983. declare module "babylonjs/Lights/shadowLight" {
  8984. import { Camera } from "babylonjs/Cameras/camera";
  8985. import { Scene } from "babylonjs/scene";
  8986. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8988. import { Light } from "babylonjs/Lights/light";
  8989. /**
  8990. * Interface describing all the common properties and methods a shadow light needs to implement.
  8991. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8992. * as well as binding the different shadow properties to the effects.
  8993. */
  8994. export interface IShadowLight extends Light {
  8995. /**
  8996. * The light id in the scene (used in scene.findLighById for instance)
  8997. */
  8998. id: string;
  8999. /**
  9000. * The position the shdow will be casted from.
  9001. */
  9002. position: Vector3;
  9003. /**
  9004. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9005. */
  9006. direction: Vector3;
  9007. /**
  9008. * The transformed position. Position of the light in world space taking parenting in account.
  9009. */
  9010. transformedPosition: Vector3;
  9011. /**
  9012. * The transformed direction. Direction of the light in world space taking parenting in account.
  9013. */
  9014. transformedDirection: Vector3;
  9015. /**
  9016. * The friendly name of the light in the scene.
  9017. */
  9018. name: string;
  9019. /**
  9020. * Defines the shadow projection clipping minimum z value.
  9021. */
  9022. shadowMinZ: number;
  9023. /**
  9024. * Defines the shadow projection clipping maximum z value.
  9025. */
  9026. shadowMaxZ: number;
  9027. /**
  9028. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9029. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9030. */
  9031. computeTransformedInformation(): boolean;
  9032. /**
  9033. * Gets the scene the light belongs to.
  9034. * @returns The scene
  9035. */
  9036. getScene(): Scene;
  9037. /**
  9038. * Callback defining a custom Projection Matrix Builder.
  9039. * This can be used to override the default projection matrix computation.
  9040. */
  9041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9042. /**
  9043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9044. * @param matrix The materix to updated with the projection information
  9045. * @param viewMatrix The transform matrix of the light
  9046. * @param renderList The list of mesh to render in the map
  9047. * @returns The current light
  9048. */
  9049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9050. /**
  9051. * Gets the current depth scale used in ESM.
  9052. * @returns The scale
  9053. */
  9054. getDepthScale(): number;
  9055. /**
  9056. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9057. * @returns true if a cube texture needs to be use
  9058. */
  9059. needCube(): boolean;
  9060. /**
  9061. * Detects if the projection matrix requires to be recomputed this frame.
  9062. * @returns true if it requires to be recomputed otherwise, false.
  9063. */
  9064. needProjectionMatrixCompute(): boolean;
  9065. /**
  9066. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9067. */
  9068. forceProjectionMatrixCompute(): void;
  9069. /**
  9070. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9071. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9072. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9073. */
  9074. getShadowDirection(faceIndex?: number): Vector3;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. }
  9088. /**
  9089. * Base implementation IShadowLight
  9090. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9091. */
  9092. export abstract class ShadowLight extends Light implements IShadowLight {
  9093. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9094. protected _position: Vector3;
  9095. protected _setPosition(value: Vector3): void;
  9096. /**
  9097. * Sets the position the shadow will be casted from. Also use as the light position for both
  9098. * point and spot lights.
  9099. */
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. position: Vector3;
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. /**
  9112. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9113. * Also use as the light direction on spot and directional lights.
  9114. */
  9115. direction: Vector3;
  9116. private _shadowMinZ;
  9117. /**
  9118. * Gets the shadow projection clipping minimum z value.
  9119. */
  9120. /**
  9121. * Sets the shadow projection clipping minimum z value.
  9122. */
  9123. shadowMinZ: number;
  9124. private _shadowMaxZ;
  9125. /**
  9126. * Sets the shadow projection clipping maximum z value.
  9127. */
  9128. /**
  9129. * Gets the shadow projection clipping maximum z value.
  9130. */
  9131. shadowMaxZ: number;
  9132. /**
  9133. * Callback defining a custom Projection Matrix Builder.
  9134. * This can be used to override the default projection matrix computation.
  9135. */
  9136. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9137. /**
  9138. * The transformed position. Position of the light in world space taking parenting in account.
  9139. */
  9140. transformedPosition: Vector3;
  9141. /**
  9142. * The transformed direction. Direction of the light in world space taking parenting in account.
  9143. */
  9144. transformedDirection: Vector3;
  9145. private _needProjectionMatrixCompute;
  9146. /**
  9147. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9148. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9149. */
  9150. computeTransformedInformation(): boolean;
  9151. /**
  9152. * Return the depth scale used for the shadow map.
  9153. * @returns the depth scale.
  9154. */
  9155. getDepthScale(): number;
  9156. /**
  9157. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9158. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9159. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9160. */
  9161. getShadowDirection(faceIndex?: number): Vector3;
  9162. /**
  9163. * Returns the ShadowLight absolute position in the World.
  9164. * @returns the position vector in world space
  9165. */
  9166. getAbsolutePosition(): Vector3;
  9167. /**
  9168. * Sets the ShadowLight direction toward the passed target.
  9169. * @param target The point to target in local space
  9170. * @returns the updated ShadowLight direction
  9171. */
  9172. setDirectionToTarget(target: Vector3): Vector3;
  9173. /**
  9174. * Returns the light rotation in euler definition.
  9175. * @returns the x y z rotation in local space.
  9176. */
  9177. getRotation(): Vector3;
  9178. /**
  9179. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9180. * @returns true if a cube texture needs to be use
  9181. */
  9182. needCube(): boolean;
  9183. /**
  9184. * Detects if the projection matrix requires to be recomputed this frame.
  9185. * @returns true if it requires to be recomputed otherwise, false.
  9186. */
  9187. needProjectionMatrixCompute(): boolean;
  9188. /**
  9189. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9190. */
  9191. forceProjectionMatrixCompute(): void;
  9192. /** @hidden */
  9193. _initCache(): void;
  9194. /** @hidden */
  9195. _isSynchronized(): boolean;
  9196. /**
  9197. * Computes the world matrix of the node
  9198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9199. * @returns the world matrix
  9200. */
  9201. computeWorldMatrix(force?: boolean): Matrix;
  9202. /**
  9203. * Gets the minZ used for shadow according to both the scene and the light.
  9204. * @param activeCamera The camera we are returning the min for
  9205. * @returns the depth min z
  9206. */
  9207. getDepthMinZ(activeCamera: Camera): number;
  9208. /**
  9209. * Gets the maxZ used for shadow according to both the scene and the light.
  9210. * @param activeCamera The camera we are returning the max for
  9211. * @returns the depth max z
  9212. */
  9213. getDepthMaxZ(activeCamera: Camera): number;
  9214. /**
  9215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9216. * @param matrix The materix to updated with the projection information
  9217. * @param viewMatrix The transform matrix of the light
  9218. * @param renderList The list of mesh to render in the map
  9219. * @returns The current light
  9220. */
  9221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9222. }
  9223. }
  9224. declare module "babylonjs/Materials/materialHelper" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Engine } from "babylonjs/Engines/engine";
  9228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9229. import { Light } from "babylonjs/Lights/light";
  9230. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9231. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9233. /**
  9234. * "Static Class" containing the most commonly used helper while dealing with material for
  9235. * rendering purpose.
  9236. *
  9237. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9238. *
  9239. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9240. */
  9241. export class MaterialHelper {
  9242. /**
  9243. * Bind the current view position to an effect.
  9244. * @param effect The effect to be bound
  9245. * @param scene The scene the eyes position is used from
  9246. */
  9247. static BindEyePosition(effect: Effect, scene: Scene): void;
  9248. /**
  9249. * Helps preparing the defines values about the UVs in used in the effect.
  9250. * UVs are shared as much as we can accross channels in the shaders.
  9251. * @param texture The texture we are preparing the UVs for
  9252. * @param defines The defines to update
  9253. * @param key The channel key "diffuse", "specular"... used in the shader
  9254. */
  9255. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9256. /**
  9257. * Binds a texture matrix value to its corrsponding uniform
  9258. * @param texture The texture to bind the matrix for
  9259. * @param uniformBuffer The uniform buffer receivin the data
  9260. * @param key The channel key "diffuse", "specular"... used in the shader
  9261. */
  9262. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9263. /**
  9264. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9265. * @param mesh defines the current mesh
  9266. * @param scene defines the current scene
  9267. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9268. * @param pointsCloud defines if point cloud rendering has to be turned on
  9269. * @param fogEnabled defines if fog has to be turned on
  9270. * @param alphaTest defines if alpha testing has to be turned on
  9271. * @param defines defines the current list of defines
  9272. */
  9273. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9274. /**
  9275. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9276. * @param scene defines the current scene
  9277. * @param engine defines the current engine
  9278. * @param defines specifies the list of active defines
  9279. * @param useInstances defines if instances have to be turned on
  9280. * @param useClipPlane defines if clip plane have to be turned on
  9281. */
  9282. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9283. /**
  9284. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9285. * @param mesh The mesh containing the geometry data we will draw
  9286. * @param defines The defines to update
  9287. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9288. * @param useBones Precise whether bones should be used or not (override mesh info)
  9289. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9290. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9291. * @returns false if defines are considered not dirty and have not been checked
  9292. */
  9293. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9294. /**
  9295. * Prepares the defines related to multiview
  9296. * @param scene The scene we are intending to draw
  9297. * @param defines The defines to update
  9298. */
  9299. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9300. /**
  9301. * Prepares the defines related to the light information passed in parameter
  9302. * @param scene The scene we are intending to draw
  9303. * @param mesh The mesh the effect is compiling for
  9304. * @param defines The defines to update
  9305. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9306. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9307. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9308. * @returns true if normals will be required for the rest of the effect
  9309. */
  9310. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9311. /**
  9312. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9313. * that won t be acctive due to defines being turned off.
  9314. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9315. * @param samplersList The samplers list
  9316. * @param defines The defines helping in the list generation
  9317. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9318. */
  9319. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9320. /**
  9321. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9322. * @param defines The defines to update while falling back
  9323. * @param fallbacks The authorized effect fallbacks
  9324. * @param maxSimultaneousLights The maximum number of lights allowed
  9325. * @param rank the current rank of the Effect
  9326. * @returns The newly affected rank
  9327. */
  9328. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9329. /**
  9330. * Prepares the list of attributes required for morph targets according to the effect defines.
  9331. * @param attribs The current list of supported attribs
  9332. * @param mesh The mesh to prepare the morph targets attributes for
  9333. * @param defines The current Defines of the effect
  9334. */
  9335. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9336. /**
  9337. * Prepares the list of attributes required for bones according to the effect defines.
  9338. * @param attribs The current list of supported attribs
  9339. * @param mesh The mesh to prepare the bones attributes for
  9340. * @param defines The current Defines of the effect
  9341. * @param fallbacks The current efffect fallback strategy
  9342. */
  9343. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9344. /**
  9345. * Prepares the list of attributes required for instances according to the effect defines.
  9346. * @param attribs The current list of supported attribs
  9347. * @param defines The current Defines of the effect
  9348. */
  9349. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9350. /**
  9351. * Binds the light shadow information to the effect for the given mesh.
  9352. * @param light The light containing the generator
  9353. * @param scene The scene the lights belongs to
  9354. * @param mesh The mesh we are binding the information to render
  9355. * @param lightIndex The light index in the effect used to render the mesh
  9356. * @param effect The effect we are binding the data to
  9357. */
  9358. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9359. /**
  9360. * Binds the light information to the effect.
  9361. * @param light The light containing the generator
  9362. * @param effect The effect we are binding the data to
  9363. * @param lightIndex The light index in the effect used to render
  9364. */
  9365. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9366. /**
  9367. * Binds the lights information from the scene to the effect for the given mesh.
  9368. * @param scene The scene the lights belongs to
  9369. * @param mesh The mesh we are binding the information to render
  9370. * @param effect The effect we are binding the data to
  9371. * @param defines The generated defines for the effect
  9372. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9373. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9374. */
  9375. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9376. private static _tempFogColor;
  9377. /**
  9378. * Binds the fog information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param linearSpace Defines if the fog effect is applied in linear space
  9383. */
  9384. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9385. /**
  9386. * Binds the bones information from the mesh to the effect.
  9387. * @param mesh The mesh we are binding the information to render
  9388. * @param effect The effect we are binding the data to
  9389. */
  9390. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9391. /**
  9392. * Binds the morph targets information from the mesh to the effect.
  9393. * @param abstractMesh The mesh we are binding the information to render
  9394. * @param effect The effect we are binding the data to
  9395. */
  9396. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9397. /**
  9398. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9399. * @param defines The generated defines used in the effect
  9400. * @param effect The effect we are binding the data to
  9401. * @param scene The scene we are willing to render with logarithmic scale for
  9402. */
  9403. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9404. /**
  9405. * Binds the clip plane information from the scene to the effect.
  9406. * @param scene The scene the clip plane information are extracted from
  9407. * @param effect The effect we are binding the data to
  9408. */
  9409. static BindClipPlane(effect: Effect, scene: Scene): void;
  9410. }
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9413. /** @hidden */
  9414. export var kernelBlurVaryingDeclaration: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9420. /** @hidden */
  9421. export var kernelBlurFragment: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9427. /** @hidden */
  9428. export var kernelBlurFragment2: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9434. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9436. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9437. /** @hidden */
  9438. export var kernelBlurPixelShader: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9444. /** @hidden */
  9445. export var kernelBlurVertex: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9451. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9452. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9453. /** @hidden */
  9454. export var kernelBlurVertexShader: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9460. import { Vector2 } from "babylonjs/Maths/math";
  9461. import { Nullable } from "babylonjs/types";
  9462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9463. import { Camera } from "babylonjs/Cameras/camera";
  9464. import { Effect } from "babylonjs/Materials/effect";
  9465. import { Engine } from "babylonjs/Engines/engine";
  9466. import "babylonjs/Shaders/kernelBlur.fragment";
  9467. import "babylonjs/Shaders/kernelBlur.vertex";
  9468. /**
  9469. * The Blur Post Process which blurs an image based on a kernel and direction.
  9470. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9471. */
  9472. export class BlurPostProcess extends PostProcess {
  9473. /** The direction in which to blur the image. */
  9474. direction: Vector2;
  9475. private blockCompilation;
  9476. protected _kernel: number;
  9477. protected _idealKernel: number;
  9478. protected _packedFloat: boolean;
  9479. private _staticDefines;
  9480. /**
  9481. * Sets the length in pixels of the blur sample region
  9482. */
  9483. /**
  9484. * Gets the length in pixels of the blur sample region
  9485. */
  9486. kernel: number;
  9487. /**
  9488. * Sets wether or not the blur needs to unpack/repack floats
  9489. */
  9490. /**
  9491. * Gets wether or not the blur is unpacking/repacking floats
  9492. */
  9493. packedFloat: boolean;
  9494. /**
  9495. * Creates a new instance BlurPostProcess
  9496. * @param name The name of the effect.
  9497. * @param direction The direction in which to blur the image.
  9498. * @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.
  9499. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9500. * @param camera The camera to apply the render pass to.
  9501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9502. * @param engine The engine which the post process will be applied. (default: current engine)
  9503. * @param reusable If the post process can be reused on the same frame. (default: false)
  9504. * @param textureType Type of textures used when performing the post process. (default: 0)
  9505. * @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)
  9506. */
  9507. constructor(name: string,
  9508. /** The direction in which to blur the image. */
  9509. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9510. /**
  9511. * Updates the effect with the current post process compile time values and recompiles the shader.
  9512. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9513. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9514. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9515. * @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
  9516. * @param onCompiled Called when the shader has been compiled.
  9517. * @param onError Called if there is an error when compiling a shader.
  9518. */
  9519. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9520. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9521. /**
  9522. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9523. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9524. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9525. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9526. * The gaps between physical kernels are compensated for in the weighting of the samples
  9527. * @param idealKernel Ideal blur kernel.
  9528. * @return Nearest best kernel.
  9529. */
  9530. protected _nearestBestKernel(idealKernel: number): number;
  9531. /**
  9532. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9533. * @param x The point on the Gaussian distribution to sample.
  9534. * @return the value of the Gaussian function at x.
  9535. */
  9536. protected _gaussianWeight(x: number): number;
  9537. /**
  9538. * Generates a string that can be used as a floating point number in GLSL.
  9539. * @param x Value to print.
  9540. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9541. * @return GLSL float string.
  9542. */
  9543. protected _glslFloat(x: number, decimalFigures?: number): string;
  9544. }
  9545. }
  9546. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9547. /** @hidden */
  9548. export var shadowMapPixelShader: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9554. /** @hidden */
  9555. export var bonesDeclaration: {
  9556. name: string;
  9557. shader: string;
  9558. };
  9559. }
  9560. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9561. /** @hidden */
  9562. export var morphTargetsVertexGlobalDeclaration: {
  9563. name: string;
  9564. shader: string;
  9565. };
  9566. }
  9567. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9568. /** @hidden */
  9569. export var morphTargetsVertexDeclaration: {
  9570. name: string;
  9571. shader: string;
  9572. };
  9573. }
  9574. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9575. /** @hidden */
  9576. export var instancesDeclaration: {
  9577. name: string;
  9578. shader: string;
  9579. };
  9580. }
  9581. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9582. /** @hidden */
  9583. export var helperFunctions: {
  9584. name: string;
  9585. shader: string;
  9586. };
  9587. }
  9588. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9589. /** @hidden */
  9590. export var morphTargetsVertex: {
  9591. name: string;
  9592. shader: string;
  9593. };
  9594. }
  9595. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9596. /** @hidden */
  9597. export var instancesVertex: {
  9598. name: string;
  9599. shader: string;
  9600. };
  9601. }
  9602. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9603. /** @hidden */
  9604. export var bonesVertex: {
  9605. name: string;
  9606. shader: string;
  9607. };
  9608. }
  9609. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9612. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9613. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9615. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9616. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9617. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9618. /** @hidden */
  9619. export var shadowMapVertexShader: {
  9620. name: string;
  9621. shader: string;
  9622. };
  9623. }
  9624. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9625. /** @hidden */
  9626. export var depthBoxBlurPixelShader: {
  9627. name: string;
  9628. shader: string;
  9629. };
  9630. }
  9631. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9632. import { Nullable } from "babylonjs/types";
  9633. import { Scene } from "babylonjs/scene";
  9634. import { Matrix } from "babylonjs/Maths/math";
  9635. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9637. import { Mesh } from "babylonjs/Meshes/mesh";
  9638. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9639. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9640. import { Effect } from "babylonjs/Materials/effect";
  9641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9642. import "babylonjs/Shaders/shadowMap.fragment";
  9643. import "babylonjs/Shaders/shadowMap.vertex";
  9644. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9645. import { Observable } from "babylonjs/Misc/observable";
  9646. /**
  9647. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9648. */
  9649. export interface ICustomShaderOptions {
  9650. /**
  9651. * Gets or sets the custom shader name to use
  9652. */
  9653. shaderName: string;
  9654. /**
  9655. * The list of attribute names used in the shader
  9656. */
  9657. attributes?: string[];
  9658. /**
  9659. * The list of unifrom names used in the shader
  9660. */
  9661. uniforms?: string[];
  9662. /**
  9663. * The list of sampler names used in the shader
  9664. */
  9665. samplers?: string[];
  9666. /**
  9667. * The list of defines used in the shader
  9668. */
  9669. defines?: string[];
  9670. }
  9671. /**
  9672. * Interface to implement to create a shadow generator compatible with BJS.
  9673. */
  9674. export interface IShadowGenerator {
  9675. /**
  9676. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9677. * @returns The render target texture if present otherwise, null
  9678. */
  9679. getShadowMap(): Nullable<RenderTargetTexture>;
  9680. /**
  9681. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9682. * @returns The render target texture if the shadow map is present otherwise, null
  9683. */
  9684. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9685. /**
  9686. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9687. * @param subMesh The submesh we want to render in the shadow map
  9688. * @param useInstances Defines wether will draw in the map using instances
  9689. * @returns true if ready otherwise, false
  9690. */
  9691. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9692. /**
  9693. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9694. * @param defines Defines of the material we want to update
  9695. * @param lightIndex Index of the light in the enabled light list of the material
  9696. */
  9697. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9698. /**
  9699. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9700. * defined in the generator but impacting the effect).
  9701. * It implies the unifroms available on the materials are the standard BJS ones.
  9702. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9703. * @param effect The effect we are binfing the information for
  9704. */
  9705. bindShadowLight(lightIndex: string, effect: Effect): void;
  9706. /**
  9707. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9708. * (eq to shadow prjection matrix * light transform matrix)
  9709. * @returns The transform matrix used to create the shadow map
  9710. */
  9711. getTransformMatrix(): Matrix;
  9712. /**
  9713. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9714. * Cube and 2D textures for instance.
  9715. */
  9716. recreateShadowMap(): void;
  9717. /**
  9718. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9719. * @param onCompiled Callback triggered at the and of the effects compilation
  9720. * @param options Sets of optional options forcing the compilation with different modes
  9721. */
  9722. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9723. useInstances: boolean;
  9724. }>): void;
  9725. /**
  9726. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9727. * @param options Sets of optional options forcing the compilation with different modes
  9728. * @returns A promise that resolves when the compilation completes
  9729. */
  9730. forceCompilationAsync(options?: Partial<{
  9731. useInstances: boolean;
  9732. }>): Promise<void>;
  9733. /**
  9734. * Serializes the shadow generator setup to a json object.
  9735. * @returns The serialized JSON object
  9736. */
  9737. serialize(): any;
  9738. /**
  9739. * Disposes the Shadow map and related Textures and effects.
  9740. */
  9741. dispose(): void;
  9742. }
  9743. /**
  9744. * Default implementation IShadowGenerator.
  9745. * This is the main object responsible of generating shadows in the framework.
  9746. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9747. */
  9748. export class ShadowGenerator implements IShadowGenerator {
  9749. /**
  9750. * Shadow generator mode None: no filtering applied.
  9751. */
  9752. static readonly FILTER_NONE: number;
  9753. /**
  9754. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9756. */
  9757. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9758. /**
  9759. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9760. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9761. */
  9762. static readonly FILTER_POISSONSAMPLING: number;
  9763. /**
  9764. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9765. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9766. */
  9767. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9768. /**
  9769. * Shadow generator mode ESM: 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_CLOSEEXPONENTIALSHADOWMAP: number;
  9774. /**
  9775. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9776. * edge artifacts on steep falloff.
  9777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9778. */
  9779. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9780. /**
  9781. * Shadow generator mode PCF: Percentage Closer Filtering
  9782. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9783. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9784. */
  9785. static readonly FILTER_PCF: number;
  9786. /**
  9787. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9788. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9789. * Contact Hardening
  9790. */
  9791. static readonly FILTER_PCSS: number;
  9792. /**
  9793. * Reserved for PCF and PCSS
  9794. * Highest Quality.
  9795. *
  9796. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9797. *
  9798. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9799. */
  9800. static readonly QUALITY_HIGH: number;
  9801. /**
  9802. * Reserved for PCF and PCSS
  9803. * Good tradeoff for quality/perf cross devices
  9804. *
  9805. * Execute PCF on a 3*3 kernel.
  9806. *
  9807. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9808. */
  9809. static readonly QUALITY_MEDIUM: number;
  9810. /**
  9811. * Reserved for PCF and PCSS
  9812. * The lowest quality but the fastest.
  9813. *
  9814. * Execute PCF on a 1*1 kernel.
  9815. *
  9816. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9817. */
  9818. static readonly QUALITY_LOW: number;
  9819. /** Gets or sets the custom shader name to use */
  9820. customShaderOptions: ICustomShaderOptions;
  9821. /**
  9822. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9823. */
  9824. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9825. /**
  9826. * Observable triggered before a mesh is rendered in the shadow map.
  9827. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9828. */
  9829. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9830. private _bias;
  9831. /**
  9832. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9833. */
  9834. /**
  9835. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9836. */
  9837. bias: number;
  9838. private _normalBias;
  9839. /**
  9840. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9841. */
  9842. /**
  9843. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9844. */
  9845. normalBias: number;
  9846. private _blurBoxOffset;
  9847. /**
  9848. * Gets the blur box offset: offset applied during the blur pass.
  9849. * Only useful if useKernelBlur = false
  9850. */
  9851. /**
  9852. * Sets the blur box offset: offset applied during the blur pass.
  9853. * Only useful if useKernelBlur = false
  9854. */
  9855. blurBoxOffset: number;
  9856. private _blurScale;
  9857. /**
  9858. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9859. * 2 means half of the size.
  9860. */
  9861. /**
  9862. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9863. * 2 means half of the size.
  9864. */
  9865. blurScale: number;
  9866. private _blurKernel;
  9867. /**
  9868. * Gets the blur kernel: kernel size of the blur pass.
  9869. * Only useful if useKernelBlur = true
  9870. */
  9871. /**
  9872. * Sets the blur kernel: kernel size of the blur pass.
  9873. * Only useful if useKernelBlur = true
  9874. */
  9875. blurKernel: number;
  9876. private _useKernelBlur;
  9877. /**
  9878. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9879. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9880. */
  9881. /**
  9882. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9883. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9884. */
  9885. useKernelBlur: boolean;
  9886. private _depthScale;
  9887. /**
  9888. * Gets the depth scale used in ESM mode.
  9889. */
  9890. /**
  9891. * Sets the depth scale used in ESM mode.
  9892. * This can override the scale stored on the light.
  9893. */
  9894. depthScale: number;
  9895. private _filter;
  9896. /**
  9897. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9898. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9899. */
  9900. /**
  9901. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9902. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9903. */
  9904. filter: number;
  9905. /**
  9906. * Gets if the current filter is set to Poisson Sampling.
  9907. */
  9908. /**
  9909. * Sets the current filter to Poisson Sampling.
  9910. */
  9911. usePoissonSampling: boolean;
  9912. /**
  9913. * Gets if the current filter is set to ESM.
  9914. */
  9915. /**
  9916. * Sets the current filter is to ESM.
  9917. */
  9918. useExponentialShadowMap: boolean;
  9919. /**
  9920. * Gets if the current filter is set to filtered ESM.
  9921. */
  9922. /**
  9923. * Gets if the current filter is set to filtered ESM.
  9924. */
  9925. useBlurExponentialShadowMap: boolean;
  9926. /**
  9927. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9928. * exponential to prevent steep falloff artifacts).
  9929. */
  9930. /**
  9931. * Sets the current filter to "close ESM" (using the inverse of the
  9932. * exponential to prevent steep falloff artifacts).
  9933. */
  9934. useCloseExponentialShadowMap: boolean;
  9935. /**
  9936. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9937. * exponential to prevent steep falloff artifacts).
  9938. */
  9939. /**
  9940. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9941. * exponential to prevent steep falloff artifacts).
  9942. */
  9943. useBlurCloseExponentialShadowMap: boolean;
  9944. /**
  9945. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9946. */
  9947. /**
  9948. * Sets the current filter to "PCF" (percentage closer filtering).
  9949. */
  9950. usePercentageCloserFiltering: boolean;
  9951. private _filteringQuality;
  9952. /**
  9953. * Gets the PCF or PCSS Quality.
  9954. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9955. */
  9956. /**
  9957. * Sets the PCF or PCSS Quality.
  9958. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9959. */
  9960. filteringQuality: number;
  9961. /**
  9962. * Gets if the current filter is set to "PCSS" (contact hardening).
  9963. */
  9964. /**
  9965. * Sets the current filter to "PCSS" (contact hardening).
  9966. */
  9967. useContactHardeningShadow: boolean;
  9968. private _contactHardeningLightSizeUVRatio;
  9969. /**
  9970. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9971. * Using a ratio helps keeping shape stability independently of the map size.
  9972. *
  9973. * It does not account for the light projection as it was having too much
  9974. * instability during the light setup or during light position changes.
  9975. *
  9976. * Only valid if useContactHardeningShadow is true.
  9977. */
  9978. /**
  9979. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9980. * Using a ratio helps keeping shape stability independently of the map size.
  9981. *
  9982. * It does not account for the light projection as it was having too much
  9983. * instability during the light setup or during light position changes.
  9984. *
  9985. * Only valid if useContactHardeningShadow is true.
  9986. */
  9987. contactHardeningLightSizeUVRatio: number;
  9988. private _darkness;
  9989. /**
  9990. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9991. * 0 means strongest and 1 would means no shadow.
  9992. * @returns the darkness.
  9993. */
  9994. getDarkness(): number;
  9995. /**
  9996. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9997. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9998. * @returns the shadow generator allowing fluent coding.
  9999. */
  10000. setDarkness(darkness: number): ShadowGenerator;
  10001. private _transparencyShadow;
  10002. /**
  10003. * Sets the ability to have transparent shadow (boolean).
  10004. * @param transparent True if transparent else False
  10005. * @returns the shadow generator allowing fluent coding
  10006. */
  10007. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10008. private _shadowMap;
  10009. private _shadowMap2;
  10010. /**
  10011. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10012. * @returns The render target texture if present otherwise, null
  10013. */
  10014. getShadowMap(): Nullable<RenderTargetTexture>;
  10015. /**
  10016. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10017. * @returns The render target texture if the shadow map is present otherwise, null
  10018. */
  10019. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10020. /**
  10021. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10022. * @param mesh Mesh to add
  10023. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10024. * @returns the Shadow Generator itself
  10025. */
  10026. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10027. /**
  10028. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10029. * @param mesh Mesh to remove
  10030. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10031. * @returns the Shadow Generator itself
  10032. */
  10033. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10034. /**
  10035. * Controls the extent to which the shadows fade out at the edge of the frustum
  10036. * Used only by directionals and spots
  10037. */
  10038. frustumEdgeFalloff: number;
  10039. private _light;
  10040. /**
  10041. * Returns the associated light object.
  10042. * @returns the light generating the shadow
  10043. */
  10044. getLight(): IShadowLight;
  10045. /**
  10046. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10047. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10048. * It might on the other hand introduce peter panning.
  10049. */
  10050. forceBackFacesOnly: boolean;
  10051. private _scene;
  10052. private _lightDirection;
  10053. private _effect;
  10054. private _viewMatrix;
  10055. private _projectionMatrix;
  10056. private _transformMatrix;
  10057. private _cachedPosition;
  10058. private _cachedDirection;
  10059. private _cachedDefines;
  10060. private _currentRenderID;
  10061. private _boxBlurPostprocess;
  10062. private _kernelBlurXPostprocess;
  10063. private _kernelBlurYPostprocess;
  10064. private _blurPostProcesses;
  10065. private _mapSize;
  10066. private _currentFaceIndex;
  10067. private _currentFaceIndexCache;
  10068. private _textureType;
  10069. private _defaultTextureMatrix;
  10070. /** @hidden */
  10071. static _SceneComponentInitialization: (scene: Scene) => void;
  10072. /**
  10073. * Creates a ShadowGenerator object.
  10074. * A ShadowGenerator is the required tool to use the shadows.
  10075. * Each light casting shadows needs to use its own ShadowGenerator.
  10076. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10077. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10078. * @param light The light object generating the shadows.
  10079. * @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.
  10080. */
  10081. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10082. private _initializeGenerator;
  10083. private _initializeShadowMap;
  10084. private _initializeBlurRTTAndPostProcesses;
  10085. private _renderForShadowMap;
  10086. private _renderSubMeshForShadowMap;
  10087. private _applyFilterValues;
  10088. /**
  10089. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10090. * @param onCompiled Callback triggered at the and of the effects compilation
  10091. * @param options Sets of optional options forcing the compilation with different modes
  10092. */
  10093. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10094. useInstances: boolean;
  10095. }>): void;
  10096. /**
  10097. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10098. * @param options Sets of optional options forcing the compilation with different modes
  10099. * @returns A promise that resolves when the compilation completes
  10100. */
  10101. forceCompilationAsync(options?: Partial<{
  10102. useInstances: boolean;
  10103. }>): Promise<void>;
  10104. /**
  10105. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10106. * @param subMesh The submesh we want to render in the shadow map
  10107. * @param useInstances Defines wether will draw in the map using instances
  10108. * @returns true if ready otherwise, false
  10109. */
  10110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10111. /**
  10112. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10113. * @param defines Defines of the material we want to update
  10114. * @param lightIndex Index of the light in the enabled light list of the material
  10115. */
  10116. prepareDefines(defines: any, lightIndex: number): void;
  10117. /**
  10118. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10119. * defined in the generator but impacting the effect).
  10120. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10121. * @param effect The effect we are binfing the information for
  10122. */
  10123. bindShadowLight(lightIndex: string, effect: Effect): void;
  10124. /**
  10125. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10126. * (eq to shadow prjection matrix * light transform matrix)
  10127. * @returns The transform matrix used to create the shadow map
  10128. */
  10129. getTransformMatrix(): Matrix;
  10130. /**
  10131. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10132. * Cube and 2D textures for instance.
  10133. */
  10134. recreateShadowMap(): void;
  10135. private _disposeBlurPostProcesses;
  10136. private _disposeRTTandPostProcesses;
  10137. /**
  10138. * Disposes the ShadowGenerator.
  10139. * Returns nothing.
  10140. */
  10141. dispose(): void;
  10142. /**
  10143. * Serializes the shadow generator setup to a json object.
  10144. * @returns The serialized JSON object
  10145. */
  10146. serialize(): any;
  10147. /**
  10148. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10149. * @param parsedShadowGenerator The JSON object to parse
  10150. * @param scene The scene to create the shadow map for
  10151. * @returns The parsed shadow generator
  10152. */
  10153. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10154. }
  10155. }
  10156. declare module "babylonjs/Lights/light" {
  10157. import { Nullable } from "babylonjs/types";
  10158. import { Scene } from "babylonjs/scene";
  10159. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10160. import { Node } from "babylonjs/node";
  10161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10162. import { Effect } from "babylonjs/Materials/effect";
  10163. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10164. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10165. /**
  10166. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10167. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10168. * 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.
  10169. */
  10170. export abstract class Light extends Node {
  10171. /**
  10172. * Falloff Default: light is falling off following the material specification:
  10173. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10174. */
  10175. static readonly FALLOFF_DEFAULT: number;
  10176. /**
  10177. * Falloff Physical: light is falling off following the inverse squared distance law.
  10178. */
  10179. static readonly FALLOFF_PHYSICAL: number;
  10180. /**
  10181. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10182. * to enhance interoperability with other engines.
  10183. */
  10184. static readonly FALLOFF_GLTF: number;
  10185. /**
  10186. * Falloff Standard: light is falling off like in the standard material
  10187. * to enhance interoperability with other materials.
  10188. */
  10189. static readonly FALLOFF_STANDARD: number;
  10190. /**
  10191. * If every light affecting the material is in this lightmapMode,
  10192. * material.lightmapTexture adds or multiplies
  10193. * (depends on material.useLightmapAsShadowmap)
  10194. * after every other light calculations.
  10195. */
  10196. static readonly LIGHTMAP_DEFAULT: number;
  10197. /**
  10198. * material.lightmapTexture as only diffuse lighting from this light
  10199. * adds only specular lighting from this light
  10200. * adds dynamic shadows
  10201. */
  10202. static readonly LIGHTMAP_SPECULAR: number;
  10203. /**
  10204. * material.lightmapTexture as only lighting
  10205. * no light calculation from this light
  10206. * only adds dynamic shadows from this light
  10207. */
  10208. static readonly LIGHTMAP_SHADOWSONLY: number;
  10209. /**
  10210. * Each light type uses the default quantity according to its type:
  10211. * point/spot lights use luminous intensity
  10212. * directional lights use illuminance
  10213. */
  10214. static readonly INTENSITYMODE_AUTOMATIC: number;
  10215. /**
  10216. * lumen (lm)
  10217. */
  10218. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10219. /**
  10220. * candela (lm/sr)
  10221. */
  10222. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10223. /**
  10224. * lux (lm/m^2)
  10225. */
  10226. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10227. /**
  10228. * nit (cd/m^2)
  10229. */
  10230. static readonly INTENSITYMODE_LUMINANCE: number;
  10231. /**
  10232. * Light type const id of the point light.
  10233. */
  10234. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10235. /**
  10236. * Light type const id of the directional light.
  10237. */
  10238. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10239. /**
  10240. * Light type const id of the spot light.
  10241. */
  10242. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10243. /**
  10244. * Light type const id of the hemispheric light.
  10245. */
  10246. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10247. /**
  10248. * Diffuse gives the basic color to an object.
  10249. */
  10250. diffuse: Color3;
  10251. /**
  10252. * Specular produces a highlight color on an object.
  10253. * Note: This is note affecting PBR materials.
  10254. */
  10255. specular: Color3;
  10256. /**
  10257. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10258. * falling off base on range or angle.
  10259. * This can be set to any values in Light.FALLOFF_x.
  10260. *
  10261. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10262. * other types of materials.
  10263. */
  10264. falloffType: number;
  10265. /**
  10266. * Strength of the light.
  10267. * Note: By default it is define in the framework own unit.
  10268. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10269. */
  10270. intensity: number;
  10271. private _range;
  10272. protected _inverseSquaredRange: number;
  10273. /**
  10274. * Defines how far from the source the light is impacting in scene units.
  10275. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10276. */
  10277. /**
  10278. * Defines how far from the source the light is impacting in scene units.
  10279. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10280. */
  10281. range: number;
  10282. /**
  10283. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10284. * of light.
  10285. */
  10286. private _photometricScale;
  10287. private _intensityMode;
  10288. /**
  10289. * Gets the photometric scale used to interpret the intensity.
  10290. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10291. */
  10292. /**
  10293. * Sets the photometric scale used to interpret the intensity.
  10294. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10295. */
  10296. intensityMode: number;
  10297. private _radius;
  10298. /**
  10299. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10300. */
  10301. /**
  10302. * sets the light radius used by PBR Materials to simulate soft area lights.
  10303. */
  10304. radius: number;
  10305. private _renderPriority;
  10306. /**
  10307. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10308. * exceeding the number allowed of the materials.
  10309. */
  10310. renderPriority: number;
  10311. private _shadowEnabled;
  10312. /**
  10313. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10314. * the current shadow generator.
  10315. */
  10316. /**
  10317. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10318. * the current shadow generator.
  10319. */
  10320. shadowEnabled: boolean;
  10321. private _includedOnlyMeshes;
  10322. /**
  10323. * Gets the only meshes impacted by this light.
  10324. */
  10325. /**
  10326. * Sets the only meshes impacted by this light.
  10327. */
  10328. includedOnlyMeshes: AbstractMesh[];
  10329. private _excludedMeshes;
  10330. /**
  10331. * Gets the meshes not impacted by this light.
  10332. */
  10333. /**
  10334. * Sets the meshes not impacted by this light.
  10335. */
  10336. excludedMeshes: AbstractMesh[];
  10337. private _excludeWithLayerMask;
  10338. /**
  10339. * Gets the layer id use to find what meshes are not impacted by the light.
  10340. * Inactive if 0
  10341. */
  10342. /**
  10343. * Sets the layer id use to find what meshes are not impacted by the light.
  10344. * Inactive if 0
  10345. */
  10346. excludeWithLayerMask: number;
  10347. private _includeOnlyWithLayerMask;
  10348. /**
  10349. * Gets the layer id use to find what meshes are impacted by the light.
  10350. * Inactive if 0
  10351. */
  10352. /**
  10353. * Sets the layer id use to find what meshes are impacted by the light.
  10354. * Inactive if 0
  10355. */
  10356. includeOnlyWithLayerMask: number;
  10357. private _lightmapMode;
  10358. /**
  10359. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10360. */
  10361. /**
  10362. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10363. */
  10364. lightmapMode: number;
  10365. /**
  10366. * Shadow generator associted to the light.
  10367. * @hidden Internal use only.
  10368. */
  10369. _shadowGenerator: Nullable<IShadowGenerator>;
  10370. /**
  10371. * @hidden Internal use only.
  10372. */
  10373. _excludedMeshesIds: string[];
  10374. /**
  10375. * @hidden Internal use only.
  10376. */
  10377. _includedOnlyMeshesIds: string[];
  10378. /**
  10379. * The current light unifom buffer.
  10380. * @hidden Internal use only.
  10381. */
  10382. _uniformBuffer: UniformBuffer;
  10383. /**
  10384. * Creates a Light object in the scene.
  10385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10386. * @param name The firendly name of the light
  10387. * @param scene The scene the light belongs too
  10388. */
  10389. constructor(name: string, scene: Scene);
  10390. protected abstract _buildUniformLayout(): void;
  10391. /**
  10392. * Sets the passed Effect "effect" with the Light information.
  10393. * @param effect The effect to update
  10394. * @param lightIndex The index of the light in the effect to update
  10395. * @returns The light
  10396. */
  10397. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10398. /**
  10399. * Returns the string "Light".
  10400. * @returns the class name
  10401. */
  10402. getClassName(): string;
  10403. /** @hidden */
  10404. readonly _isLight: boolean;
  10405. /**
  10406. * Converts the light information to a readable string for debug purpose.
  10407. * @param fullDetails Supports for multiple levels of logging within scene loading
  10408. * @returns the human readable light info
  10409. */
  10410. toString(fullDetails?: boolean): string;
  10411. /** @hidden */
  10412. protected _syncParentEnabledState(): void;
  10413. /**
  10414. * Set the enabled state of this node.
  10415. * @param value - the new enabled state
  10416. */
  10417. setEnabled(value: boolean): void;
  10418. /**
  10419. * Returns the Light associated shadow generator if any.
  10420. * @return the associated shadow generator.
  10421. */
  10422. getShadowGenerator(): Nullable<IShadowGenerator>;
  10423. /**
  10424. * Returns a Vector3, the absolute light position in the World.
  10425. * @returns the world space position of the light
  10426. */
  10427. getAbsolutePosition(): Vector3;
  10428. /**
  10429. * Specifies if the light will affect the passed mesh.
  10430. * @param mesh The mesh to test against the light
  10431. * @return true the mesh is affected otherwise, false.
  10432. */
  10433. canAffectMesh(mesh: AbstractMesh): boolean;
  10434. /**
  10435. * Sort function to order lights for rendering.
  10436. * @param a First Light object to compare to second.
  10437. * @param b Second Light object to compare first.
  10438. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10439. */
  10440. static CompareLightsPriority(a: Light, b: Light): number;
  10441. /**
  10442. * Releases resources associated with this node.
  10443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10445. */
  10446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10447. /**
  10448. * Returns the light type ID (integer).
  10449. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10450. */
  10451. getTypeID(): number;
  10452. /**
  10453. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10454. * @returns the scaled intensity in intensity mode unit
  10455. */
  10456. getScaledIntensity(): number;
  10457. /**
  10458. * Returns a new Light object, named "name", from the current one.
  10459. * @param name The name of the cloned light
  10460. * @returns the new created light
  10461. */
  10462. clone(name: string): Nullable<Light>;
  10463. /**
  10464. * Serializes the current light into a Serialization object.
  10465. * @returns the serialized object.
  10466. */
  10467. serialize(): any;
  10468. /**
  10469. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10470. * This new light is named "name" and added to the passed scene.
  10471. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10472. * @param name The friendly name of the light
  10473. * @param scene The scene the new light will belong to
  10474. * @returns the constructor function
  10475. */
  10476. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10477. /**
  10478. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10479. * @param parsedLight The JSON representation of the light
  10480. * @param scene The scene to create the parsed light in
  10481. * @returns the created light after parsing
  10482. */
  10483. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10484. private _hookArrayForExcluded;
  10485. private _hookArrayForIncludedOnly;
  10486. private _resyncMeshes;
  10487. /**
  10488. * Forces the meshes to update their light related information in their rendering used effects
  10489. * @hidden Internal Use Only
  10490. */
  10491. _markMeshesAsLightDirty(): void;
  10492. /**
  10493. * Recomputes the cached photometric scale if needed.
  10494. */
  10495. private _computePhotometricScale;
  10496. /**
  10497. * Returns the Photometric Scale according to the light type and intensity mode.
  10498. */
  10499. private _getPhotometricScale;
  10500. /**
  10501. * Reorder the light in the scene according to their defined priority.
  10502. * @hidden Internal Use Only
  10503. */
  10504. _reorderLightsInScene(): void;
  10505. /**
  10506. * Prepares the list of defines specific to the light type.
  10507. * @param defines the list of defines
  10508. * @param lightIndex defines the index of the light for the effect
  10509. */
  10510. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10511. }
  10512. }
  10513. declare module "babylonjs/Actions/action" {
  10514. import { Observable } from "babylonjs/Misc/observable";
  10515. import { Condition } from "babylonjs/Actions/condition";
  10516. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10517. import { ActionManager } from "babylonjs/Actions/actionManager";
  10518. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10519. /**
  10520. * Interface used to define Action
  10521. */
  10522. export interface IAction {
  10523. /**
  10524. * Trigger for the action
  10525. */
  10526. trigger: number;
  10527. /** Options of the trigger */
  10528. triggerOptions: any;
  10529. /**
  10530. * Gets the trigger parameters
  10531. * @returns the trigger parameters
  10532. */
  10533. getTriggerParameter(): any;
  10534. /**
  10535. * Internal only - executes current action event
  10536. * @hidden
  10537. */
  10538. _executeCurrent(evt?: ActionEvent): void;
  10539. /**
  10540. * Serialize placeholder for child classes
  10541. * @param parent of child
  10542. * @returns the serialized object
  10543. */
  10544. serialize(parent: any): any;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _prepare(): void;
  10550. /**
  10551. * Internal only - manager for action
  10552. * @hidden
  10553. */
  10554. _actionManager: AbstractActionManager;
  10555. }
  10556. /**
  10557. * The action to be carried out following a trigger
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10559. */
  10560. export class Action implements IAction {
  10561. /** the trigger, with or without parameters, for the action */
  10562. triggerOptions: any;
  10563. /**
  10564. * Trigger for the action
  10565. */
  10566. trigger: number;
  10567. /**
  10568. * Internal only - manager for action
  10569. * @hidden
  10570. */
  10571. _actionManager: ActionManager;
  10572. private _nextActiveAction;
  10573. private _child;
  10574. private _condition?;
  10575. private _triggerParameter;
  10576. /**
  10577. * An event triggered prior to action being executed.
  10578. */
  10579. onBeforeExecuteObservable: Observable<Action>;
  10580. /**
  10581. * Creates a new Action
  10582. * @param triggerOptions the trigger, with or without parameters, for the action
  10583. * @param condition an optional determinant of action
  10584. */
  10585. constructor(
  10586. /** the trigger, with or without parameters, for the action */
  10587. triggerOptions: any, condition?: Condition);
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. _prepare(): void;
  10593. /**
  10594. * Gets the trigger parameters
  10595. * @returns the trigger parameters
  10596. */
  10597. getTriggerParameter(): any;
  10598. /**
  10599. * Internal only - executes current action event
  10600. * @hidden
  10601. */
  10602. _executeCurrent(evt?: ActionEvent): void;
  10603. /**
  10604. * Execute placeholder for child classes
  10605. * @param evt optional action event
  10606. */
  10607. execute(evt?: ActionEvent): void;
  10608. /**
  10609. * Skips to next active action
  10610. */
  10611. skipToNextActiveAction(): void;
  10612. /**
  10613. * Adds action to chain of actions, may be a DoNothingAction
  10614. * @param action defines the next action to execute
  10615. * @returns The action passed in
  10616. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10617. */
  10618. then(action: Action): Action;
  10619. /**
  10620. * Internal only
  10621. * @hidden
  10622. */
  10623. _getProperty(propertyPath: string): string;
  10624. /**
  10625. * Internal only
  10626. * @hidden
  10627. */
  10628. _getEffectiveTarget(target: any, propertyPath: string): any;
  10629. /**
  10630. * Serialize placeholder for child classes
  10631. * @param parent of child
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. /**
  10636. * Internal only called by serialize
  10637. * @hidden
  10638. */
  10639. protected _serialize(serializedAction: any, parent?: any): any;
  10640. /**
  10641. * Internal only
  10642. * @hidden
  10643. */
  10644. static _SerializeValueAsString: (value: any) => string;
  10645. /**
  10646. * Internal only
  10647. * @hidden
  10648. */
  10649. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10650. name: string;
  10651. targetType: string;
  10652. value: string;
  10653. };
  10654. }
  10655. }
  10656. declare module "babylonjs/Actions/condition" {
  10657. import { ActionManager } from "babylonjs/Actions/actionManager";
  10658. /**
  10659. * A Condition applied to an Action
  10660. */
  10661. export class Condition {
  10662. /**
  10663. * Internal only - manager for action
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. _evaluationId: number;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. _currentResult: boolean;
  10677. /**
  10678. * Creates a new Condition
  10679. * @param actionManager the manager of the action the condition is applied to
  10680. */
  10681. constructor(actionManager: ActionManager);
  10682. /**
  10683. * Check if the current condition is valid
  10684. * @returns a boolean
  10685. */
  10686. isValid(): boolean;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. _getProperty(propertyPath: string): string;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. _getEffectiveTarget(target: any, propertyPath: string): any;
  10697. /**
  10698. * Serialize placeholder for child classes
  10699. * @returns the serialized object
  10700. */
  10701. serialize(): any;
  10702. /**
  10703. * Internal only
  10704. * @hidden
  10705. */
  10706. protected _serialize(serializedCondition: any): any;
  10707. }
  10708. /**
  10709. * Defines specific conditional operators as extensions of Condition
  10710. */
  10711. export class ValueCondition extends Condition {
  10712. /** path to specify the property of the target the conditional operator uses */
  10713. propertyPath: string;
  10714. /** the value compared by the conditional operator against the current value of the property */
  10715. value: any;
  10716. /** the conditional operator, default ValueCondition.IsEqual */
  10717. operator: number;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private static _IsEqual;
  10723. /**
  10724. * Internal only
  10725. * @hidden
  10726. */
  10727. private static _IsDifferent;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private static _IsGreater;
  10733. /**
  10734. * Internal only
  10735. * @hidden
  10736. */
  10737. private static _IsLesser;
  10738. /**
  10739. * returns the number for IsEqual
  10740. */
  10741. static readonly IsEqual: number;
  10742. /**
  10743. * Returns the number for IsDifferent
  10744. */
  10745. static readonly IsDifferent: number;
  10746. /**
  10747. * Returns the number for IsGreater
  10748. */
  10749. static readonly IsGreater: number;
  10750. /**
  10751. * Returns the number for IsLesser
  10752. */
  10753. static readonly IsLesser: number;
  10754. /**
  10755. * Internal only The action manager for the condition
  10756. * @hidden
  10757. */
  10758. _actionManager: ActionManager;
  10759. /**
  10760. * Internal only
  10761. * @hidden
  10762. */
  10763. private _target;
  10764. /**
  10765. * Internal only
  10766. * @hidden
  10767. */
  10768. private _effectiveTarget;
  10769. /**
  10770. * Internal only
  10771. * @hidden
  10772. */
  10773. private _property;
  10774. /**
  10775. * Creates a new ValueCondition
  10776. * @param actionManager manager for the action the condition applies to
  10777. * @param target for the action
  10778. * @param propertyPath path to specify the property of the target the conditional operator uses
  10779. * @param value the value compared by the conditional operator against the current value of the property
  10780. * @param operator the conditional operator, default ValueCondition.IsEqual
  10781. */
  10782. constructor(actionManager: ActionManager, target: any,
  10783. /** path to specify the property of the target the conditional operator uses */
  10784. propertyPath: string,
  10785. /** the value compared by the conditional operator against the current value of the property */
  10786. value: any,
  10787. /** the conditional operator, default ValueCondition.IsEqual */
  10788. operator?: number);
  10789. /**
  10790. * Compares the given value with the property value for the specified conditional operator
  10791. * @returns the result of the comparison
  10792. */
  10793. isValid(): boolean;
  10794. /**
  10795. * Serialize the ValueCondition into a JSON compatible object
  10796. * @returns serialization object
  10797. */
  10798. serialize(): any;
  10799. /**
  10800. * Gets the name of the conditional operator for the ValueCondition
  10801. * @param operator the conditional operator
  10802. * @returns the name
  10803. */
  10804. static GetOperatorName(operator: number): string;
  10805. }
  10806. /**
  10807. * Defines a predicate condition as an extension of Condition
  10808. */
  10809. export class PredicateCondition extends Condition {
  10810. /** defines the predicate function used to validate the condition */
  10811. predicate: () => boolean;
  10812. /**
  10813. * Internal only - manager for action
  10814. * @hidden
  10815. */
  10816. _actionManager: ActionManager;
  10817. /**
  10818. * Creates a new PredicateCondition
  10819. * @param actionManager manager for the action the condition applies to
  10820. * @param predicate defines the predicate function used to validate the condition
  10821. */
  10822. constructor(actionManager: ActionManager,
  10823. /** defines the predicate function used to validate the condition */
  10824. predicate: () => boolean);
  10825. /**
  10826. * @returns the validity of the predicate condition
  10827. */
  10828. isValid(): boolean;
  10829. }
  10830. /**
  10831. * Defines a state condition as an extension of Condition
  10832. */
  10833. export class StateCondition extends Condition {
  10834. /** Value to compare with target state */
  10835. value: string;
  10836. /**
  10837. * Internal only - manager for action
  10838. * @hidden
  10839. */
  10840. _actionManager: ActionManager;
  10841. /**
  10842. * Internal only
  10843. * @hidden
  10844. */
  10845. private _target;
  10846. /**
  10847. * Creates a new StateCondition
  10848. * @param actionManager manager for the action the condition applies to
  10849. * @param target of the condition
  10850. * @param value to compare with target state
  10851. */
  10852. constructor(actionManager: ActionManager, target: any,
  10853. /** Value to compare with target state */
  10854. value: string);
  10855. /**
  10856. * Gets a boolean indicating if the current condition is met
  10857. * @returns the validity of the state
  10858. */
  10859. isValid(): boolean;
  10860. /**
  10861. * Serialize the StateCondition into a JSON compatible object
  10862. * @returns serialization object
  10863. */
  10864. serialize(): any;
  10865. }
  10866. }
  10867. declare module "babylonjs/Actions/directActions" {
  10868. import { Action } from "babylonjs/Actions/action";
  10869. import { Condition } from "babylonjs/Actions/condition";
  10870. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10871. /**
  10872. * This defines an action responsible to toggle a boolean once triggered.
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10874. */
  10875. export class SwitchBooleanAction extends Action {
  10876. /**
  10877. * The path to the boolean property in the target object
  10878. */
  10879. propertyPath: string;
  10880. private _target;
  10881. private _effectiveTarget;
  10882. private _property;
  10883. /**
  10884. * Instantiate the action
  10885. * @param triggerOptions defines the trigger options
  10886. * @param target defines the object containing the boolean
  10887. * @param propertyPath defines the path to the boolean property in the target object
  10888. * @param condition defines the trigger related conditions
  10889. */
  10890. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10891. /** @hidden */
  10892. _prepare(): void;
  10893. /**
  10894. * Execute the action toggle the boolean value.
  10895. */
  10896. execute(): void;
  10897. /**
  10898. * Serializes the actions and its related information.
  10899. * @param parent defines the object to serialize in
  10900. * @returns the serialized object
  10901. */
  10902. serialize(parent: any): any;
  10903. }
  10904. /**
  10905. * This defines an action responsible to set a the state field of the target
  10906. * to a desired value once triggered.
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10908. */
  10909. export class SetStateAction extends Action {
  10910. /**
  10911. * The value to store in the state field.
  10912. */
  10913. value: string;
  10914. private _target;
  10915. /**
  10916. * Instantiate the action
  10917. * @param triggerOptions defines the trigger options
  10918. * @param target defines the object containing the state property
  10919. * @param value defines the value to store in the state field
  10920. * @param condition defines the trigger related conditions
  10921. */
  10922. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10923. /**
  10924. * Execute the action and store the value on the target state property.
  10925. */
  10926. execute(): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to set a property of the target
  10936. * to a desired value once triggered.
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10938. */
  10939. export class SetValueAction extends Action {
  10940. /**
  10941. * The path of the property to set in the target.
  10942. */
  10943. propertyPath: string;
  10944. /**
  10945. * The value to set in the property
  10946. */
  10947. value: any;
  10948. private _target;
  10949. private _effectiveTarget;
  10950. private _property;
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param target defines the object containing the property
  10955. * @param propertyPath defines the path of the property to set in the target
  10956. * @param value defines the value to set in the property
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10960. /** @hidden */
  10961. _prepare(): void;
  10962. /**
  10963. * Execute the action and set the targetted property to the desired value.
  10964. */
  10965. execute(): void;
  10966. /**
  10967. * Serializes the actions and its related information.
  10968. * @param parent defines the object to serialize in
  10969. * @returns the serialized object
  10970. */
  10971. serialize(parent: any): any;
  10972. }
  10973. /**
  10974. * This defines an action responsible to increment the target value
  10975. * to a desired value once triggered.
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10977. */
  10978. export class IncrementValueAction extends Action {
  10979. /**
  10980. * The path of the property to increment in the target.
  10981. */
  10982. propertyPath: string;
  10983. /**
  10984. * The value we should increment the property by.
  10985. */
  10986. value: any;
  10987. private _target;
  10988. private _effectiveTarget;
  10989. private _property;
  10990. /**
  10991. * Instantiate the action
  10992. * @param triggerOptions defines the trigger options
  10993. * @param target defines the object containing the property
  10994. * @param propertyPath defines the path of the property to increment in the target
  10995. * @param value defines the value value we should increment the property by
  10996. * @param condition defines the trigger related conditions
  10997. */
  10998. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10999. /** @hidden */
  11000. _prepare(): void;
  11001. /**
  11002. * Execute the action and increment the target of the value amount.
  11003. */
  11004. execute(): void;
  11005. /**
  11006. * Serializes the actions and its related information.
  11007. * @param parent defines the object to serialize in
  11008. * @returns the serialized object
  11009. */
  11010. serialize(parent: any): any;
  11011. }
  11012. /**
  11013. * This defines an action responsible to start an animation once triggered.
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11015. */
  11016. export class PlayAnimationAction extends Action {
  11017. /**
  11018. * Where the animation should start (animation frame)
  11019. */
  11020. from: number;
  11021. /**
  11022. * Where the animation should stop (animation frame)
  11023. */
  11024. to: number;
  11025. /**
  11026. * Define if the animation should loop or stop after the first play.
  11027. */
  11028. loop?: boolean;
  11029. private _target;
  11030. /**
  11031. * Instantiate the action
  11032. * @param triggerOptions defines the trigger options
  11033. * @param target defines the target animation or animation name
  11034. * @param from defines from where the animation should start (animation frame)
  11035. * @param end defines where the animation should stop (animation frame)
  11036. * @param loop defines if the animation should loop or stop after the first play
  11037. * @param condition defines the trigger related conditions
  11038. */
  11039. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11040. /** @hidden */
  11041. _prepare(): void;
  11042. /**
  11043. * Execute the action and play the animation.
  11044. */
  11045. execute(): void;
  11046. /**
  11047. * Serializes the actions and its related information.
  11048. * @param parent defines the object to serialize in
  11049. * @returns the serialized object
  11050. */
  11051. serialize(parent: any): any;
  11052. }
  11053. /**
  11054. * This defines an action responsible to stop an animation once triggered.
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11056. */
  11057. export class StopAnimationAction extends Action {
  11058. private _target;
  11059. /**
  11060. * Instantiate the action
  11061. * @param triggerOptions defines the trigger options
  11062. * @param target defines the target animation or animation name
  11063. * @param condition defines the trigger related conditions
  11064. */
  11065. constructor(triggerOptions: any, target: any, condition?: Condition);
  11066. /** @hidden */
  11067. _prepare(): void;
  11068. /**
  11069. * Execute the action and stop the animation.
  11070. */
  11071. execute(): void;
  11072. /**
  11073. * Serializes the actions and its related information.
  11074. * @param parent defines the object to serialize in
  11075. * @returns the serialized object
  11076. */
  11077. serialize(parent: any): any;
  11078. }
  11079. /**
  11080. * This defines an action responsible that does nothing once triggered.
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11082. */
  11083. export class DoNothingAction extends Action {
  11084. /**
  11085. * Instantiate the action
  11086. * @param triggerOptions defines the trigger options
  11087. * @param condition defines the trigger related conditions
  11088. */
  11089. constructor(triggerOptions?: any, condition?: Condition);
  11090. /**
  11091. * Execute the action and do nothing.
  11092. */
  11093. execute(): void;
  11094. /**
  11095. * Serializes the actions and its related information.
  11096. * @param parent defines the object to serialize in
  11097. * @returns the serialized object
  11098. */
  11099. serialize(parent: any): any;
  11100. }
  11101. /**
  11102. * This defines an action responsible to trigger several actions once triggered.
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11104. */
  11105. export class CombineAction extends Action {
  11106. /**
  11107. * The list of aggregated animations to run.
  11108. */
  11109. children: Action[];
  11110. /**
  11111. * Instantiate the action
  11112. * @param triggerOptions defines the trigger options
  11113. * @param children defines the list of aggregated animations to run
  11114. * @param condition defines the trigger related conditions
  11115. */
  11116. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11117. /** @hidden */
  11118. _prepare(): void;
  11119. /**
  11120. * Execute the action and executes all the aggregated actions.
  11121. */
  11122. execute(evt: ActionEvent): void;
  11123. /**
  11124. * Serializes the actions and its related information.
  11125. * @param parent defines the object to serialize in
  11126. * @returns the serialized object
  11127. */
  11128. serialize(parent: any): any;
  11129. }
  11130. /**
  11131. * This defines an action responsible to run code (external event) once triggered.
  11132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11133. */
  11134. export class ExecuteCodeAction extends Action {
  11135. /**
  11136. * The callback function to run.
  11137. */
  11138. func: (evt: ActionEvent) => void;
  11139. /**
  11140. * Instantiate the action
  11141. * @param triggerOptions defines the trigger options
  11142. * @param func defines the callback function to run
  11143. * @param condition defines the trigger related conditions
  11144. */
  11145. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11146. /**
  11147. * Execute the action and run the attached code.
  11148. */
  11149. execute(evt: ActionEvent): void;
  11150. }
  11151. /**
  11152. * This defines an action responsible to set the parent property of the target once triggered.
  11153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11154. */
  11155. export class SetParentAction extends Action {
  11156. private _parent;
  11157. private _target;
  11158. /**
  11159. * Instantiate the action
  11160. * @param triggerOptions defines the trigger options
  11161. * @param target defines the target containing the parent property
  11162. * @param parent defines from where the animation should start (animation frame)
  11163. * @param condition defines the trigger related conditions
  11164. */
  11165. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11166. /** @hidden */
  11167. _prepare(): void;
  11168. /**
  11169. * Execute the action and set the parent property.
  11170. */
  11171. execute(): void;
  11172. /**
  11173. * Serializes the actions and its related information.
  11174. * @param parent defines the object to serialize in
  11175. * @returns the serialized object
  11176. */
  11177. serialize(parent: any): any;
  11178. }
  11179. }
  11180. declare module "babylonjs/Actions/actionManager" {
  11181. import { Nullable } from "babylonjs/types";
  11182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11183. import { Scene } from "babylonjs/scene";
  11184. import { IAction } from "babylonjs/Actions/action";
  11185. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11186. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11187. /**
  11188. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11189. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11191. */
  11192. export class ActionManager extends AbstractActionManager {
  11193. /**
  11194. * Nothing
  11195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11196. */
  11197. static readonly NothingTrigger: number;
  11198. /**
  11199. * On pick
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnPickTrigger: number;
  11203. /**
  11204. * On left pick
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnLeftPickTrigger: number;
  11208. /**
  11209. * On right pick
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnRightPickTrigger: number;
  11213. /**
  11214. * On center pick
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnCenterPickTrigger: number;
  11218. /**
  11219. * On pick down
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnPickDownTrigger: number;
  11223. /**
  11224. * On double pick
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11226. */
  11227. static readonly OnDoublePickTrigger: number;
  11228. /**
  11229. * On pick up
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnPickUpTrigger: number;
  11233. /**
  11234. * On pick out.
  11235. * This trigger will only be raised if you also declared a OnPickDown
  11236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11237. */
  11238. static readonly OnPickOutTrigger: number;
  11239. /**
  11240. * On long press
  11241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11242. */
  11243. static readonly OnLongPressTrigger: number;
  11244. /**
  11245. * On pointer over
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11247. */
  11248. static readonly OnPointerOverTrigger: number;
  11249. /**
  11250. * On pointer out
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11252. */
  11253. static readonly OnPointerOutTrigger: number;
  11254. /**
  11255. * On every frame
  11256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11257. */
  11258. static readonly OnEveryFrameTrigger: number;
  11259. /**
  11260. * On intersection enter
  11261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11262. */
  11263. static readonly OnIntersectionEnterTrigger: number;
  11264. /**
  11265. * On intersection exit
  11266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11267. */
  11268. static readonly OnIntersectionExitTrigger: number;
  11269. /**
  11270. * On key down
  11271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11272. */
  11273. static readonly OnKeyDownTrigger: number;
  11274. /**
  11275. * On key up
  11276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11277. */
  11278. static readonly OnKeyUpTrigger: number;
  11279. private _scene;
  11280. /**
  11281. * Creates a new action manager
  11282. * @param scene defines the hosting scene
  11283. */
  11284. constructor(scene: Scene);
  11285. /**
  11286. * Releases all associated resources
  11287. */
  11288. dispose(): void;
  11289. /**
  11290. * Gets hosting scene
  11291. * @returns the hosting scene
  11292. */
  11293. getScene(): Scene;
  11294. /**
  11295. * Does this action manager handles actions of any of the given triggers
  11296. * @param triggers defines the triggers to be tested
  11297. * @return a boolean indicating whether one (or more) of the triggers is handled
  11298. */
  11299. hasSpecificTriggers(triggers: number[]): boolean;
  11300. /**
  11301. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11302. * speed.
  11303. * @param triggerA defines the trigger to be tested
  11304. * @param triggerB defines the trigger to be tested
  11305. * @return a boolean indicating whether one (or more) of the triggers is handled
  11306. */
  11307. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11308. /**
  11309. * Does this action manager handles actions of a given trigger
  11310. * @param trigger defines the trigger to be tested
  11311. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11312. * @return whether the trigger is handled
  11313. */
  11314. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11315. /**
  11316. * Does this action manager has pointer triggers
  11317. */
  11318. readonly hasPointerTriggers: boolean;
  11319. /**
  11320. * Does this action manager has pick triggers
  11321. */
  11322. readonly hasPickTriggers: boolean;
  11323. /**
  11324. * Registers an action to this action manager
  11325. * @param action defines the action to be registered
  11326. * @return the action amended (prepared) after registration
  11327. */
  11328. registerAction(action: IAction): Nullable<IAction>;
  11329. /**
  11330. * Unregisters an action to this action manager
  11331. * @param action defines the action to be unregistered
  11332. * @return a boolean indicating whether the action has been unregistered
  11333. */
  11334. unregisterAction(action: IAction): Boolean;
  11335. /**
  11336. * Process a specific trigger
  11337. * @param trigger defines the trigger to process
  11338. * @param evt defines the event details to be processed
  11339. */
  11340. processTrigger(trigger: number, evt?: IActionEvent): void;
  11341. /** @hidden */
  11342. _getEffectiveTarget(target: any, propertyPath: string): any;
  11343. /** @hidden */
  11344. _getProperty(propertyPath: string): string;
  11345. /**
  11346. * Serialize this manager to a JSON object
  11347. * @param name defines the property name to store this manager
  11348. * @returns a JSON representation of this manager
  11349. */
  11350. serialize(name: string): any;
  11351. /**
  11352. * Creates a new ActionManager from a JSON data
  11353. * @param parsedActions defines the JSON data to read from
  11354. * @param object defines the hosting mesh
  11355. * @param scene defines the hosting scene
  11356. */
  11357. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11358. /**
  11359. * Get a trigger name by index
  11360. * @param trigger defines the trigger index
  11361. * @returns a trigger name
  11362. */
  11363. static GetTriggerName(trigger: number): string;
  11364. }
  11365. }
  11366. declare module "babylonjs/Culling/ray" {
  11367. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11368. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11370. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11371. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11372. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11373. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11374. /**
  11375. * Class representing a ray with position and direction
  11376. */
  11377. export class Ray {
  11378. /** origin point */
  11379. origin: Vector3;
  11380. /** direction */
  11381. direction: Vector3;
  11382. /** length of the ray */
  11383. length: number;
  11384. private static readonly TmpVector3;
  11385. private _tmpRay;
  11386. /**
  11387. * Creates a new ray
  11388. * @param origin origin point
  11389. * @param direction direction
  11390. * @param length length of the ray
  11391. */
  11392. constructor(
  11393. /** origin point */
  11394. origin: Vector3,
  11395. /** direction */
  11396. direction: Vector3,
  11397. /** length of the ray */
  11398. length?: number);
  11399. /**
  11400. * Checks if the ray intersects a box
  11401. * @param minimum bound of the box
  11402. * @param maximum bound of the box
  11403. * @param intersectionTreshold extra extend to be added to the box in all direction
  11404. * @returns if the box was hit
  11405. */
  11406. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11407. /**
  11408. * Checks if the ray intersects a box
  11409. * @param box the bounding box to check
  11410. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11411. * @returns if the box was hit
  11412. */
  11413. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11414. /**
  11415. * If the ray hits a sphere
  11416. * @param sphere the bounding sphere to check
  11417. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11418. * @returns true if it hits the sphere
  11419. */
  11420. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11421. /**
  11422. * If the ray hits a triange
  11423. * @param vertex0 triangle vertex
  11424. * @param vertex1 triangle vertex
  11425. * @param vertex2 triangle vertex
  11426. * @returns intersection information if hit
  11427. */
  11428. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11429. /**
  11430. * Checks if ray intersects a plane
  11431. * @param plane the plane to check
  11432. * @returns the distance away it was hit
  11433. */
  11434. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11435. /**
  11436. * Checks if ray intersects a mesh
  11437. * @param mesh the mesh to check
  11438. * @param fastCheck if only the bounding box should checked
  11439. * @returns picking info of the intersecton
  11440. */
  11441. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11442. /**
  11443. * Checks if ray intersects a mesh
  11444. * @param meshes the meshes to check
  11445. * @param fastCheck if only the bounding box should checked
  11446. * @param results array to store result in
  11447. * @returns Array of picking infos
  11448. */
  11449. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11450. private _comparePickingInfo;
  11451. private static smallnum;
  11452. private static rayl;
  11453. /**
  11454. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11455. * @param sega the first point of the segment to test the intersection against
  11456. * @param segb the second point of the segment to test the intersection against
  11457. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11458. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11459. */
  11460. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11461. /**
  11462. * Update the ray from viewport position
  11463. * @param x position
  11464. * @param y y position
  11465. * @param viewportWidth viewport width
  11466. * @param viewportHeight viewport height
  11467. * @param world world matrix
  11468. * @param view view matrix
  11469. * @param projection projection matrix
  11470. * @returns this ray updated
  11471. */
  11472. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11473. /**
  11474. * Creates a ray with origin and direction of 0,0,0
  11475. * @returns the new ray
  11476. */
  11477. static Zero(): Ray;
  11478. /**
  11479. * Creates a new ray from screen space and viewport
  11480. * @param x position
  11481. * @param y y position
  11482. * @param viewportWidth viewport width
  11483. * @param viewportHeight viewport height
  11484. * @param world world matrix
  11485. * @param view view matrix
  11486. * @param projection projection matrix
  11487. * @returns new ray
  11488. */
  11489. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11490. /**
  11491. * 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
  11492. * transformed to the given world matrix.
  11493. * @param origin The origin point
  11494. * @param end The end point
  11495. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11496. * @returns the new ray
  11497. */
  11498. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11499. /**
  11500. * Transforms a ray by a matrix
  11501. * @param ray ray to transform
  11502. * @param matrix matrix to apply
  11503. * @returns the resulting new ray
  11504. */
  11505. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11506. /**
  11507. * Transforms a ray by a matrix
  11508. * @param ray ray to transform
  11509. * @param matrix matrix to apply
  11510. * @param result ray to store result in
  11511. */
  11512. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11513. /**
  11514. * Unproject a ray from screen space to object space
  11515. * @param sourceX defines the screen space x coordinate to use
  11516. * @param sourceY defines the screen space y coordinate to use
  11517. * @param viewportWidth defines the current width of the viewport
  11518. * @param viewportHeight defines the current height of the viewport
  11519. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11520. * @param view defines the view matrix to use
  11521. * @param projection defines the projection matrix to use
  11522. */
  11523. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11524. }
  11525. /**
  11526. * Type used to define predicate used to select faces when a mesh intersection is detected
  11527. */
  11528. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11529. module "babylonjs/scene" {
  11530. interface Scene {
  11531. /** @hidden */
  11532. _tempPickingRay: Nullable<Ray>;
  11533. /** @hidden */
  11534. _cachedRayForTransform: Ray;
  11535. /** @hidden */
  11536. _pickWithRayInverseMatrix: Matrix;
  11537. /** @hidden */
  11538. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11539. /** @hidden */
  11540. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11541. }
  11542. }
  11543. }
  11544. declare module "babylonjs/sceneComponent" {
  11545. import { Scene } from "babylonjs/scene";
  11546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11548. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11549. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11550. import { Nullable } from "babylonjs/types";
  11551. import { Camera } from "babylonjs/Cameras/camera";
  11552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11554. import { AbstractScene } from "babylonjs/abstractScene";
  11555. /**
  11556. * Groups all the scene component constants in one place to ease maintenance.
  11557. * @hidden
  11558. */
  11559. export class SceneComponentConstants {
  11560. static readonly NAME_EFFECTLAYER: string;
  11561. static readonly NAME_LAYER: string;
  11562. static readonly NAME_LENSFLARESYSTEM: string;
  11563. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11564. static readonly NAME_PARTICLESYSTEM: string;
  11565. static readonly NAME_GAMEPAD: string;
  11566. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11567. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11568. static readonly NAME_DEPTHRENDERER: string;
  11569. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11570. static readonly NAME_SPRITE: string;
  11571. static readonly NAME_OUTLINERENDERER: string;
  11572. static readonly NAME_PROCEDURALTEXTURE: string;
  11573. static readonly NAME_SHADOWGENERATOR: string;
  11574. static readonly NAME_OCTREE: string;
  11575. static readonly NAME_PHYSICSENGINE: string;
  11576. static readonly NAME_AUDIO: string;
  11577. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11578. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11579. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11581. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11582. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11583. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11584. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11585. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11586. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11587. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11588. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11589. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11590. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11591. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11592. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11593. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11594. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11595. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11596. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11597. static readonly STEP_AFTERRENDER_AUDIO: number;
  11598. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11599. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11600. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11601. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11602. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11603. static readonly STEP_POINTERMOVE_SPRITE: number;
  11604. static readonly STEP_POINTERDOWN_SPRITE: number;
  11605. static readonly STEP_POINTERUP_SPRITE: number;
  11606. }
  11607. /**
  11608. * This represents a scene component.
  11609. *
  11610. * This is used to decouple the dependency the scene is having on the different workloads like
  11611. * layers, post processes...
  11612. */
  11613. export interface ISceneComponent {
  11614. /**
  11615. * The name of the component. Each component must have a unique name.
  11616. */
  11617. name: string;
  11618. /**
  11619. * The scene the component belongs to.
  11620. */
  11621. scene: Scene;
  11622. /**
  11623. * Register the component to one instance of a scene.
  11624. */
  11625. register(): void;
  11626. /**
  11627. * Rebuilds the elements related to this component in case of
  11628. * context lost for instance.
  11629. */
  11630. rebuild(): void;
  11631. /**
  11632. * Disposes the component and the associated ressources.
  11633. */
  11634. dispose(): void;
  11635. }
  11636. /**
  11637. * This represents a SERIALIZABLE scene component.
  11638. *
  11639. * This extends Scene Component to add Serialization methods on top.
  11640. */
  11641. export interface ISceneSerializableComponent extends ISceneComponent {
  11642. /**
  11643. * Adds all the element from the container to the scene
  11644. * @param container the container holding the elements
  11645. */
  11646. addFromContainer(container: AbstractScene): void;
  11647. /**
  11648. * Removes all the elements in the container from the scene
  11649. * @param container contains the elements to remove
  11650. * @param dispose if the removed element should be disposed (default: false)
  11651. */
  11652. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11653. /**
  11654. * Serializes the component data to the specified json object
  11655. * @param serializationObject The object to serialize to
  11656. */
  11657. serialize(serializationObject: any): void;
  11658. }
  11659. /**
  11660. * Strong typing of a Mesh related stage step action
  11661. */
  11662. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11663. /**
  11664. * Strong typing of a Evaluate Sub Mesh related stage step action
  11665. */
  11666. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11667. /**
  11668. * Strong typing of a Active Mesh related stage step action
  11669. */
  11670. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11671. /**
  11672. * Strong typing of a Camera related stage step action
  11673. */
  11674. export type CameraStageAction = (camera: Camera) => void;
  11675. /**
  11676. * Strong typing of a Render Target related stage step action
  11677. */
  11678. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11679. /**
  11680. * Strong typing of a RenderingGroup related stage step action
  11681. */
  11682. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11683. /**
  11684. * Strong typing of a Mesh Render related stage step action
  11685. */
  11686. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11687. /**
  11688. * Strong typing of a simple stage step action
  11689. */
  11690. export type SimpleStageAction = () => void;
  11691. /**
  11692. * Strong typing of a render target action.
  11693. */
  11694. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11695. /**
  11696. * Strong typing of a pointer move action.
  11697. */
  11698. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11699. /**
  11700. * Strong typing of a pointer up/down action.
  11701. */
  11702. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11703. /**
  11704. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11705. * @hidden
  11706. */
  11707. export class Stage<T extends Function> extends Array<{
  11708. index: number;
  11709. component: ISceneComponent;
  11710. action: T;
  11711. }> {
  11712. /**
  11713. * Hide ctor from the rest of the world.
  11714. * @param items The items to add.
  11715. */
  11716. private constructor();
  11717. /**
  11718. * Creates a new Stage.
  11719. * @returns A new instance of a Stage
  11720. */
  11721. static Create<T extends Function>(): Stage<T>;
  11722. /**
  11723. * Registers a step in an ordered way in the targeted stage.
  11724. * @param index Defines the position to register the step in
  11725. * @param component Defines the component attached to the step
  11726. * @param action Defines the action to launch during the step
  11727. */
  11728. registerStep(index: number, component: ISceneComponent, action: T): void;
  11729. /**
  11730. * Clears all the steps from the stage.
  11731. */
  11732. clear(): void;
  11733. }
  11734. }
  11735. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11736. import { Nullable } from "babylonjs/types";
  11737. import { Observable } from "babylonjs/Misc/observable";
  11738. import { Scene } from "babylonjs/scene";
  11739. import { Sprite } from "babylonjs/Sprites/sprite";
  11740. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11741. import { Ray } from "babylonjs/Culling/ray";
  11742. import { Camera } from "babylonjs/Cameras/camera";
  11743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11744. import { ISceneComponent } from "babylonjs/sceneComponent";
  11745. module "babylonjs/scene" {
  11746. interface Scene {
  11747. /** @hidden */
  11748. _pointerOverSprite: Nullable<Sprite>;
  11749. /** @hidden */
  11750. _pickedDownSprite: Nullable<Sprite>;
  11751. /** @hidden */
  11752. _tempSpritePickingRay: Nullable<Ray>;
  11753. /**
  11754. * All of the sprite managers added to this scene
  11755. * @see http://doc.babylonjs.com/babylon101/sprites
  11756. */
  11757. spriteManagers: Array<ISpriteManager>;
  11758. /**
  11759. * An event triggered when sprites rendering is about to start
  11760. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11761. */
  11762. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11763. /**
  11764. * An event triggered when sprites rendering is done
  11765. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11766. */
  11767. onAfterSpritesRenderingObservable: Observable<Scene>;
  11768. /** @hidden */
  11769. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11770. /** Launch a ray to try to pick a sprite in the scene
  11771. * @param x position on screen
  11772. * @param y position on screen
  11773. * @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
  11774. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11775. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11776. * @returns a PickingInfo
  11777. */
  11778. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11779. /** Use the given ray to pick a sprite in the scene
  11780. * @param ray The ray (in world space) to use to pick meshes
  11781. * @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
  11782. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11783. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11784. * @returns a PickingInfo
  11785. */
  11786. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11787. /**
  11788. * Force the sprite under the pointer
  11789. * @param sprite defines the sprite to use
  11790. */
  11791. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11792. /**
  11793. * Gets the sprite under the pointer
  11794. * @returns a Sprite or null if no sprite is under the pointer
  11795. */
  11796. getPointerOverSprite(): Nullable<Sprite>;
  11797. }
  11798. }
  11799. /**
  11800. * Defines the sprite scene component responsible to manage sprites
  11801. * in a given scene.
  11802. */
  11803. export class SpriteSceneComponent implements ISceneComponent {
  11804. /**
  11805. * The component name helpfull to identify the component in the list of scene components.
  11806. */
  11807. readonly name: string;
  11808. /**
  11809. * The scene the component belongs to.
  11810. */
  11811. scene: Scene;
  11812. /** @hidden */
  11813. private _spritePredicate;
  11814. /**
  11815. * Creates a new instance of the component for the given scene
  11816. * @param scene Defines the scene to register the component in
  11817. */
  11818. constructor(scene: Scene);
  11819. /**
  11820. * Registers the component in a given scene
  11821. */
  11822. register(): void;
  11823. /**
  11824. * Rebuilds the elements related to this component in case of
  11825. * context lost for instance.
  11826. */
  11827. rebuild(): void;
  11828. /**
  11829. * Disposes the component and the associated ressources.
  11830. */
  11831. dispose(): void;
  11832. private _pickSpriteButKeepRay;
  11833. private _pointerMove;
  11834. private _pointerDown;
  11835. private _pointerUp;
  11836. }
  11837. }
  11838. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11839. /** @hidden */
  11840. export var fogFragmentDeclaration: {
  11841. name: string;
  11842. shader: string;
  11843. };
  11844. }
  11845. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11846. /** @hidden */
  11847. export var fogFragment: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Shaders/sprites.fragment" {
  11853. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11854. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11855. /** @hidden */
  11856. export var spritesPixelShader: {
  11857. name: string;
  11858. shader: string;
  11859. };
  11860. }
  11861. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11862. /** @hidden */
  11863. export var fogVertexDeclaration: {
  11864. name: string;
  11865. shader: string;
  11866. };
  11867. }
  11868. declare module "babylonjs/Shaders/sprites.vertex" {
  11869. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11870. /** @hidden */
  11871. export var spritesVertexShader: {
  11872. name: string;
  11873. shader: string;
  11874. };
  11875. }
  11876. declare module "babylonjs/Sprites/spriteManager" {
  11877. import { IDisposable, Scene } from "babylonjs/scene";
  11878. import { Nullable } from "babylonjs/types";
  11879. import { Observable } from "babylonjs/Misc/observable";
  11880. import { Sprite } from "babylonjs/Sprites/sprite";
  11881. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11882. import { Camera } from "babylonjs/Cameras/camera";
  11883. import { Texture } from "babylonjs/Materials/Textures/texture";
  11884. import "babylonjs/Shaders/sprites.fragment";
  11885. import "babylonjs/Shaders/sprites.vertex";
  11886. import { Ray } from "babylonjs/Culling/ray";
  11887. /**
  11888. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11889. */
  11890. export interface ISpriteManager extends IDisposable {
  11891. /**
  11892. * Restricts the camera to viewing objects with the same layerMask.
  11893. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11894. */
  11895. layerMask: number;
  11896. /**
  11897. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11898. */
  11899. isPickable: boolean;
  11900. /**
  11901. * Specifies the rendering group id for this mesh (0 by default)
  11902. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11903. */
  11904. renderingGroupId: number;
  11905. /**
  11906. * Defines the list of sprites managed by the manager.
  11907. */
  11908. sprites: Array<Sprite>;
  11909. /**
  11910. * Tests the intersection of a sprite with a specific ray.
  11911. * @param ray The ray we are sending to test the collision
  11912. * @param camera The camera space we are sending rays in
  11913. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11914. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11915. * @returns picking info or null.
  11916. */
  11917. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11918. /**
  11919. * Renders the list of sprites on screen.
  11920. */
  11921. render(): void;
  11922. }
  11923. /**
  11924. * Class used to manage multiple sprites on the same spritesheet
  11925. * @see http://doc.babylonjs.com/babylon101/sprites
  11926. */
  11927. export class SpriteManager implements ISpriteManager {
  11928. /** defines the manager's name */
  11929. name: string;
  11930. /** Gets the list of sprites */
  11931. sprites: Sprite[];
  11932. /** Gets or sets the rendering group id (0 by default) */
  11933. renderingGroupId: number;
  11934. /** Gets or sets camera layer mask */
  11935. layerMask: number;
  11936. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11937. fogEnabled: boolean;
  11938. /** Gets or sets a boolean indicating if the sprites are pickable */
  11939. isPickable: boolean;
  11940. /** Defines the default width of a cell in the spritesheet */
  11941. cellWidth: number;
  11942. /** Defines the default height of a cell in the spritesheet */
  11943. cellHeight: number;
  11944. /**
  11945. * An event triggered when the manager is disposed.
  11946. */
  11947. onDisposeObservable: Observable<SpriteManager>;
  11948. private _onDisposeObserver;
  11949. /**
  11950. * Callback called when the manager is disposed
  11951. */
  11952. onDispose: () => void;
  11953. private _capacity;
  11954. private _spriteTexture;
  11955. private _epsilon;
  11956. private _scene;
  11957. private _vertexData;
  11958. private _buffer;
  11959. private _vertexBuffers;
  11960. private _indexBuffer;
  11961. private _effectBase;
  11962. private _effectFog;
  11963. /**
  11964. * Gets or sets the spritesheet texture
  11965. */
  11966. texture: Texture;
  11967. /**
  11968. * Creates a new sprite manager
  11969. * @param name defines the manager's name
  11970. * @param imgUrl defines the sprite sheet url
  11971. * @param capacity defines the maximum allowed number of sprites
  11972. * @param cellSize defines the size of a sprite cell
  11973. * @param scene defines the hosting scene
  11974. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11975. * @param samplingMode defines the smapling mode to use with spritesheet
  11976. */
  11977. constructor(
  11978. /** defines the manager's name */
  11979. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11980. private _appendSpriteVertex;
  11981. /**
  11982. * Intersects the sprites with a ray
  11983. * @param ray defines the ray to intersect with
  11984. * @param camera defines the current active camera
  11985. * @param predicate defines a predicate used to select candidate sprites
  11986. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11987. * @returns null if no hit or a PickingInfo
  11988. */
  11989. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11990. /**
  11991. * Render all child sprites
  11992. */
  11993. render(): void;
  11994. /**
  11995. * Release associated resources
  11996. */
  11997. dispose(): void;
  11998. }
  11999. }
  12000. declare module "babylonjs/Sprites/sprite" {
  12001. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12002. import { Nullable } from "babylonjs/types";
  12003. import { ActionManager } from "babylonjs/Actions/actionManager";
  12004. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12005. /**
  12006. * Class used to represent a sprite
  12007. * @see http://doc.babylonjs.com/babylon101/sprites
  12008. */
  12009. export class Sprite {
  12010. /** defines the name */
  12011. name: string;
  12012. /** Gets or sets the current world position */
  12013. position: Vector3;
  12014. /** Gets or sets the main color */
  12015. color: Color4;
  12016. /** Gets or sets the width */
  12017. width: number;
  12018. /** Gets or sets the height */
  12019. height: number;
  12020. /** Gets or sets rotation angle */
  12021. angle: number;
  12022. /** Gets or sets the cell index in the sprite sheet */
  12023. cellIndex: number;
  12024. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12025. invertU: number;
  12026. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12027. invertV: number;
  12028. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12029. disposeWhenFinishedAnimating: boolean;
  12030. /** Gets the list of attached animations */
  12031. animations: Animation[];
  12032. /** Gets or sets a boolean indicating if the sprite can be picked */
  12033. isPickable: boolean;
  12034. /**
  12035. * Gets or sets the associated action manager
  12036. */
  12037. actionManager: Nullable<ActionManager>;
  12038. private _animationStarted;
  12039. private _loopAnimation;
  12040. private _fromIndex;
  12041. private _toIndex;
  12042. private _delay;
  12043. private _direction;
  12044. private _manager;
  12045. private _time;
  12046. private _onAnimationEnd;
  12047. /**
  12048. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12049. */
  12050. isVisible: boolean;
  12051. /**
  12052. * Gets or sets the sprite size
  12053. */
  12054. size: number;
  12055. /**
  12056. * Creates a new Sprite
  12057. * @param name defines the name
  12058. * @param manager defines the manager
  12059. */
  12060. constructor(
  12061. /** defines the name */
  12062. name: string, manager: ISpriteManager);
  12063. /**
  12064. * Starts an animation
  12065. * @param from defines the initial key
  12066. * @param to defines the end key
  12067. * @param loop defines if the animation must loop
  12068. * @param delay defines the start delay (in ms)
  12069. * @param onAnimationEnd defines a callback to call when animation ends
  12070. */
  12071. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12072. /** Stops current animation (if any) */
  12073. stopAnimation(): void;
  12074. /** @hidden */
  12075. _animate(deltaTime: number): void;
  12076. /** Release associated resources */
  12077. dispose(): void;
  12078. }
  12079. }
  12080. declare module "babylonjs/Collisions/pickingInfo" {
  12081. import { Nullable } from "babylonjs/types";
  12082. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12084. import { Sprite } from "babylonjs/Sprites/sprite";
  12085. import { Ray } from "babylonjs/Culling/ray";
  12086. /**
  12087. * Information about the result of picking within a scene
  12088. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12089. */
  12090. export class PickingInfo {
  12091. /** @hidden */
  12092. _pickingUnavailable: boolean;
  12093. /**
  12094. * If the pick collided with an object
  12095. */
  12096. hit: boolean;
  12097. /**
  12098. * Distance away where the pick collided
  12099. */
  12100. distance: number;
  12101. /**
  12102. * The location of pick collision
  12103. */
  12104. pickedPoint: Nullable<Vector3>;
  12105. /**
  12106. * The mesh corresponding the the pick collision
  12107. */
  12108. pickedMesh: Nullable<AbstractMesh>;
  12109. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12110. bu: number;
  12111. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12112. bv: number;
  12113. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12114. faceId: number;
  12115. /** Id of the the submesh that was picked */
  12116. subMeshId: number;
  12117. /** If a sprite was picked, this will be the sprite the pick collided with */
  12118. pickedSprite: Nullable<Sprite>;
  12119. /**
  12120. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12121. */
  12122. originMesh: Nullable<AbstractMesh>;
  12123. /**
  12124. * The ray that was used to perform the picking.
  12125. */
  12126. ray: Nullable<Ray>;
  12127. /**
  12128. * Gets the normal correspodning to the face the pick collided with
  12129. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12130. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12131. * @returns The normal correspodning to the face the pick collided with
  12132. */
  12133. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12134. /**
  12135. * Gets the texture coordinates of where the pick occured
  12136. * @returns the vector containing the coordnates of the texture
  12137. */
  12138. getTextureCoordinates(): Nullable<Vector2>;
  12139. }
  12140. }
  12141. declare module "babylonjs/Events/pointerEvents" {
  12142. import { Nullable } from "babylonjs/types";
  12143. import { Vector2 } from "babylonjs/Maths/math";
  12144. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12145. import { Ray } from "babylonjs/Culling/ray";
  12146. /**
  12147. * Gather the list of pointer event types as constants.
  12148. */
  12149. export class PointerEventTypes {
  12150. /**
  12151. * 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.
  12152. */
  12153. static readonly POINTERDOWN: number;
  12154. /**
  12155. * The pointerup event is fired when a pointer is no longer active.
  12156. */
  12157. static readonly POINTERUP: number;
  12158. /**
  12159. * The pointermove event is fired when a pointer changes coordinates.
  12160. */
  12161. static readonly POINTERMOVE: number;
  12162. /**
  12163. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12164. */
  12165. static readonly POINTERWHEEL: number;
  12166. /**
  12167. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12168. */
  12169. static readonly POINTERPICK: number;
  12170. /**
  12171. * The pointertap event is fired when a the object has been touched and released without drag.
  12172. */
  12173. static readonly POINTERTAP: number;
  12174. /**
  12175. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12176. */
  12177. static readonly POINTERDOUBLETAP: number;
  12178. }
  12179. /**
  12180. * Base class of pointer info types.
  12181. */
  12182. export class PointerInfoBase {
  12183. /**
  12184. * Defines the type of event (PointerEventTypes)
  12185. */
  12186. type: number;
  12187. /**
  12188. * Defines the related dom event
  12189. */
  12190. event: PointerEvent | MouseWheelEvent;
  12191. /**
  12192. * Instantiates the base class of pointers info.
  12193. * @param type Defines the type of event (PointerEventTypes)
  12194. * @param event Defines the related dom event
  12195. */
  12196. constructor(
  12197. /**
  12198. * Defines the type of event (PointerEventTypes)
  12199. */
  12200. type: number,
  12201. /**
  12202. * Defines the related dom event
  12203. */
  12204. event: PointerEvent | MouseWheelEvent);
  12205. }
  12206. /**
  12207. * This class is used to store pointer related info for the onPrePointerObservable event.
  12208. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12209. */
  12210. export class PointerInfoPre extends PointerInfoBase {
  12211. /**
  12212. * Ray from a pointer if availible (eg. 6dof controller)
  12213. */
  12214. ray: Nullable<Ray>;
  12215. /**
  12216. * Defines the local position of the pointer on the canvas.
  12217. */
  12218. localPosition: Vector2;
  12219. /**
  12220. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12221. */
  12222. skipOnPointerObservable: boolean;
  12223. /**
  12224. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12225. * @param type Defines the type of event (PointerEventTypes)
  12226. * @param event Defines the related dom event
  12227. * @param localX Defines the local x coordinates of the pointer when the event occured
  12228. * @param localY Defines the local y coordinates of the pointer when the event occured
  12229. */
  12230. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12231. }
  12232. /**
  12233. * This type contains all the data related to a pointer event in Babylon.js.
  12234. * 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.
  12235. */
  12236. export class PointerInfo extends PointerInfoBase {
  12237. /**
  12238. * Defines the picking info associated to the info (if any)\
  12239. */
  12240. pickInfo: Nullable<PickingInfo>;
  12241. /**
  12242. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12243. * @param type Defines the type of event (PointerEventTypes)
  12244. * @param event Defines the related dom event
  12245. * @param pickInfo Defines the picking info associated to the info (if any)\
  12246. */
  12247. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12248. /**
  12249. * Defines the picking info associated to the info (if any)\
  12250. */
  12251. pickInfo: Nullable<PickingInfo>);
  12252. }
  12253. /**
  12254. * Data relating to a touch event on the screen.
  12255. */
  12256. export interface PointerTouch {
  12257. /**
  12258. * X coordinate of touch.
  12259. */
  12260. x: number;
  12261. /**
  12262. * Y coordinate of touch.
  12263. */
  12264. y: number;
  12265. /**
  12266. * Id of touch. Unique for each finger.
  12267. */
  12268. pointerId: number;
  12269. /**
  12270. * Event type passed from DOM.
  12271. */
  12272. type: any;
  12273. }
  12274. }
  12275. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12276. import { Observable } from "babylonjs/Misc/observable";
  12277. import { Nullable } from "babylonjs/types";
  12278. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12280. /**
  12281. * Manage the mouse inputs to control the movement of a free camera.
  12282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12283. */
  12284. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12285. /**
  12286. * Define if touch is enabled in the mouse input
  12287. */
  12288. touchEnabled: boolean;
  12289. /**
  12290. * Defines the camera the input is attached to.
  12291. */
  12292. camera: FreeCamera;
  12293. /**
  12294. * Defines the buttons associated with the input to handle camera move.
  12295. */
  12296. buttons: number[];
  12297. /**
  12298. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12299. */
  12300. angularSensibility: number;
  12301. private _pointerInput;
  12302. private _onMouseMove;
  12303. private _observer;
  12304. private previousPosition;
  12305. /**
  12306. * Observable for when a pointer move event occurs containing the move offset
  12307. */
  12308. onPointerMovedObservable: Observable<{
  12309. offsetX: number;
  12310. offsetY: number;
  12311. }>;
  12312. /**
  12313. * @hidden
  12314. * If the camera should be rotated automatically based on pointer movement
  12315. */
  12316. _allowCameraRotation: boolean;
  12317. /**
  12318. * Manage the mouse inputs to control the movement of a free camera.
  12319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12320. * @param touchEnabled Defines if touch is enabled or not
  12321. */
  12322. constructor(
  12323. /**
  12324. * Define if touch is enabled in the mouse input
  12325. */
  12326. touchEnabled?: boolean);
  12327. /**
  12328. * Attach the input controls to a specific dom element to get the input from.
  12329. * @param element Defines the element the controls should be listened from
  12330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12331. */
  12332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12333. /**
  12334. * Called on JS contextmenu event.
  12335. * Override this method to provide functionality.
  12336. */
  12337. protected onContextMenu(evt: PointerEvent): void;
  12338. /**
  12339. * Detach the current controls from the specified dom element.
  12340. * @param element Defines the element to stop listening the inputs from
  12341. */
  12342. detachControl(element: Nullable<HTMLElement>): void;
  12343. /**
  12344. * Gets the class name of the current intput.
  12345. * @returns the class name
  12346. */
  12347. getClassName(): string;
  12348. /**
  12349. * Get the friendly name associated with the input class.
  12350. * @returns the input friendly name
  12351. */
  12352. getSimpleName(): string;
  12353. }
  12354. }
  12355. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12356. import { Nullable } from "babylonjs/types";
  12357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12359. /**
  12360. * Manage the touch inputs to control the movement of a free camera.
  12361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12362. */
  12363. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12364. /**
  12365. * Defines the camera the input is attached to.
  12366. */
  12367. camera: FreeCamera;
  12368. /**
  12369. * Defines the touch sensibility for rotation.
  12370. * The higher the faster.
  12371. */
  12372. touchAngularSensibility: number;
  12373. /**
  12374. * Defines the touch sensibility for move.
  12375. * The higher the faster.
  12376. */
  12377. touchMoveSensibility: number;
  12378. private _offsetX;
  12379. private _offsetY;
  12380. private _pointerPressed;
  12381. private _pointerInput;
  12382. private _observer;
  12383. private _onLostFocus;
  12384. /**
  12385. * Attach the input controls to a specific dom element to get the input from.
  12386. * @param element Defines the element the controls should be listened from
  12387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12388. */
  12389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12390. /**
  12391. * Detach the current controls from the specified dom element.
  12392. * @param element Defines the element to stop listening the inputs from
  12393. */
  12394. detachControl(element: Nullable<HTMLElement>): void;
  12395. /**
  12396. * Update the current camera state depending on the inputs that have been used this frame.
  12397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12398. */
  12399. checkInputs(): void;
  12400. /**
  12401. * Gets the class name of the current intput.
  12402. * @returns the class name
  12403. */
  12404. getClassName(): string;
  12405. /**
  12406. * Get the friendly name associated with the input class.
  12407. * @returns the input friendly name
  12408. */
  12409. getSimpleName(): string;
  12410. }
  12411. }
  12412. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12413. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12414. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12415. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12416. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12417. import { Nullable } from "babylonjs/types";
  12418. /**
  12419. * Default Inputs manager for the FreeCamera.
  12420. * It groups all the default supported inputs for ease of use.
  12421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12422. */
  12423. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12424. /**
  12425. * @hidden
  12426. */
  12427. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12428. /**
  12429. * @hidden
  12430. */
  12431. _mouseInput: Nullable<FreeCameraMouseInput>;
  12432. /**
  12433. * Instantiates a new FreeCameraInputsManager.
  12434. * @param camera Defines the camera the inputs belong to
  12435. */
  12436. constructor(camera: FreeCamera);
  12437. /**
  12438. * Add keyboard input support to the input manager.
  12439. * @returns the current input manager
  12440. */
  12441. addKeyboard(): FreeCameraInputsManager;
  12442. /**
  12443. * Add mouse input support to the input manager.
  12444. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12445. * @returns the current input manager
  12446. */
  12447. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12448. /**
  12449. * Removes the mouse input support from the manager
  12450. * @returns the current input manager
  12451. */
  12452. removeMouse(): FreeCameraInputsManager;
  12453. /**
  12454. * Add touch input support to the input manager.
  12455. * @returns the current input manager
  12456. */
  12457. addTouch(): FreeCameraInputsManager;
  12458. }
  12459. }
  12460. declare module "babylonjs/Cameras/freeCamera" {
  12461. import { Vector3 } from "babylonjs/Maths/math";
  12462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12463. import { Scene } from "babylonjs/scene";
  12464. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12465. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12466. /**
  12467. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12468. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12469. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12470. */
  12471. export class FreeCamera extends TargetCamera {
  12472. /**
  12473. * Define the collision ellipsoid of the camera.
  12474. * This is helpful to simulate a camera body like the player body around the camera
  12475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12476. */
  12477. ellipsoid: Vector3;
  12478. /**
  12479. * Define an offset for the position of the ellipsoid around the camera.
  12480. * This can be helpful to determine the center of the body near the gravity center of the body
  12481. * instead of its head.
  12482. */
  12483. ellipsoidOffset: Vector3;
  12484. /**
  12485. * Enable or disable collisions of the camera with the rest of the scene objects.
  12486. */
  12487. checkCollisions: boolean;
  12488. /**
  12489. * Enable or disable gravity on the camera.
  12490. */
  12491. applyGravity: boolean;
  12492. /**
  12493. * Define the input manager associated to the camera.
  12494. */
  12495. inputs: FreeCameraInputsManager;
  12496. /**
  12497. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12498. * Higher values reduce sensitivity.
  12499. */
  12500. /**
  12501. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12502. * Higher values reduce sensitivity.
  12503. */
  12504. angularSensibility: number;
  12505. /**
  12506. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12507. */
  12508. keysUp: number[];
  12509. /**
  12510. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12511. */
  12512. keysDown: number[];
  12513. /**
  12514. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12515. */
  12516. keysLeft: number[];
  12517. /**
  12518. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12519. */
  12520. keysRight: number[];
  12521. /**
  12522. * Event raised when the camera collide with a mesh in the scene.
  12523. */
  12524. onCollide: (collidedMesh: AbstractMesh) => void;
  12525. private _collider;
  12526. private _needMoveForGravity;
  12527. private _oldPosition;
  12528. private _diffPosition;
  12529. private _newPosition;
  12530. /** @hidden */
  12531. _localDirection: Vector3;
  12532. /** @hidden */
  12533. _transformedDirection: Vector3;
  12534. /**
  12535. * Instantiates a Free Camera.
  12536. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12537. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12538. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12539. * @param name Define the name of the camera in the scene
  12540. * @param position Define the start position of the camera in the scene
  12541. * @param scene Define the scene the camera belongs to
  12542. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12543. */
  12544. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12545. /**
  12546. * Attached controls to the current camera.
  12547. * @param element Defines the element the controls should be listened from
  12548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12549. */
  12550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12551. /**
  12552. * Detach the current controls from the camera.
  12553. * The camera will stop reacting to inputs.
  12554. * @param element Defines the element to stop listening the inputs from
  12555. */
  12556. detachControl(element: HTMLElement): void;
  12557. private _collisionMask;
  12558. /**
  12559. * Define a collision mask to limit the list of object the camera can collide with
  12560. */
  12561. collisionMask: number;
  12562. /** @hidden */
  12563. _collideWithWorld(displacement: Vector3): void;
  12564. private _onCollisionPositionChange;
  12565. /** @hidden */
  12566. _checkInputs(): void;
  12567. /** @hidden */
  12568. _decideIfNeedsToMove(): boolean;
  12569. /** @hidden */
  12570. _updatePosition(): void;
  12571. /**
  12572. * Destroy the camera and release the current resources hold by it.
  12573. */
  12574. dispose(): void;
  12575. /**
  12576. * Gets the current object class name.
  12577. * @return the class name
  12578. */
  12579. getClassName(): string;
  12580. }
  12581. }
  12582. declare module "babylonjs/Gamepads/gamepad" {
  12583. import { Observable } from "babylonjs/Misc/observable";
  12584. /**
  12585. * Represents a gamepad control stick position
  12586. */
  12587. export class StickValues {
  12588. /**
  12589. * The x component of the control stick
  12590. */
  12591. x: number;
  12592. /**
  12593. * The y component of the control stick
  12594. */
  12595. y: number;
  12596. /**
  12597. * Initializes the gamepad x and y control stick values
  12598. * @param x The x component of the gamepad control stick value
  12599. * @param y The y component of the gamepad control stick value
  12600. */
  12601. constructor(
  12602. /**
  12603. * The x component of the control stick
  12604. */
  12605. x: number,
  12606. /**
  12607. * The y component of the control stick
  12608. */
  12609. y: number);
  12610. }
  12611. /**
  12612. * An interface which manages callbacks for gamepad button changes
  12613. */
  12614. export interface GamepadButtonChanges {
  12615. /**
  12616. * Called when a gamepad has been changed
  12617. */
  12618. changed: boolean;
  12619. /**
  12620. * Called when a gamepad press event has been triggered
  12621. */
  12622. pressChanged: boolean;
  12623. /**
  12624. * Called when a touch event has been triggered
  12625. */
  12626. touchChanged: boolean;
  12627. /**
  12628. * Called when a value has changed
  12629. */
  12630. valueChanged: boolean;
  12631. }
  12632. /**
  12633. * Represents a gamepad
  12634. */
  12635. export class Gamepad {
  12636. /**
  12637. * The id of the gamepad
  12638. */
  12639. id: string;
  12640. /**
  12641. * The index of the gamepad
  12642. */
  12643. index: number;
  12644. /**
  12645. * The browser gamepad
  12646. */
  12647. browserGamepad: any;
  12648. /**
  12649. * Specifies what type of gamepad this represents
  12650. */
  12651. type: number;
  12652. private _leftStick;
  12653. private _rightStick;
  12654. /** @hidden */
  12655. _isConnected: boolean;
  12656. private _leftStickAxisX;
  12657. private _leftStickAxisY;
  12658. private _rightStickAxisX;
  12659. private _rightStickAxisY;
  12660. /**
  12661. * Triggered when the left control stick has been changed
  12662. */
  12663. private _onleftstickchanged;
  12664. /**
  12665. * Triggered when the right control stick has been changed
  12666. */
  12667. private _onrightstickchanged;
  12668. /**
  12669. * Represents a gamepad controller
  12670. */
  12671. static GAMEPAD: number;
  12672. /**
  12673. * Represents a generic controller
  12674. */
  12675. static GENERIC: number;
  12676. /**
  12677. * Represents an XBox controller
  12678. */
  12679. static XBOX: number;
  12680. /**
  12681. * Represents a pose-enabled controller
  12682. */
  12683. static POSE_ENABLED: number;
  12684. /**
  12685. * Specifies whether the left control stick should be Y-inverted
  12686. */
  12687. protected _invertLeftStickY: boolean;
  12688. /**
  12689. * Specifies if the gamepad has been connected
  12690. */
  12691. readonly isConnected: boolean;
  12692. /**
  12693. * Initializes the gamepad
  12694. * @param id The id of the gamepad
  12695. * @param index The index of the gamepad
  12696. * @param browserGamepad The browser gamepad
  12697. * @param leftStickX The x component of the left joystick
  12698. * @param leftStickY The y component of the left joystick
  12699. * @param rightStickX The x component of the right joystick
  12700. * @param rightStickY The y component of the right joystick
  12701. */
  12702. constructor(
  12703. /**
  12704. * The id of the gamepad
  12705. */
  12706. id: string,
  12707. /**
  12708. * The index of the gamepad
  12709. */
  12710. index: number,
  12711. /**
  12712. * The browser gamepad
  12713. */
  12714. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12715. /**
  12716. * Callback triggered when the left joystick has changed
  12717. * @param callback
  12718. */
  12719. onleftstickchanged(callback: (values: StickValues) => void): void;
  12720. /**
  12721. * Callback triggered when the right joystick has changed
  12722. * @param callback
  12723. */
  12724. onrightstickchanged(callback: (values: StickValues) => void): void;
  12725. /**
  12726. * Gets the left joystick
  12727. */
  12728. /**
  12729. * Sets the left joystick values
  12730. */
  12731. leftStick: StickValues;
  12732. /**
  12733. * Gets the right joystick
  12734. */
  12735. /**
  12736. * Sets the right joystick value
  12737. */
  12738. rightStick: StickValues;
  12739. /**
  12740. * Updates the gamepad joystick positions
  12741. */
  12742. update(): void;
  12743. /**
  12744. * Disposes the gamepad
  12745. */
  12746. dispose(): void;
  12747. }
  12748. /**
  12749. * Represents a generic gamepad
  12750. */
  12751. export class GenericPad extends Gamepad {
  12752. private _buttons;
  12753. private _onbuttondown;
  12754. private _onbuttonup;
  12755. /**
  12756. * Observable triggered when a button has been pressed
  12757. */
  12758. onButtonDownObservable: Observable<number>;
  12759. /**
  12760. * Observable triggered when a button has been released
  12761. */
  12762. onButtonUpObservable: Observable<number>;
  12763. /**
  12764. * Callback triggered when a button has been pressed
  12765. * @param callback Called when a button has been pressed
  12766. */
  12767. onbuttondown(callback: (buttonPressed: number) => void): void;
  12768. /**
  12769. * Callback triggered when a button has been released
  12770. * @param callback Called when a button has been released
  12771. */
  12772. onbuttonup(callback: (buttonReleased: number) => void): void;
  12773. /**
  12774. * Initializes the generic gamepad
  12775. * @param id The id of the generic gamepad
  12776. * @param index The index of the generic gamepad
  12777. * @param browserGamepad The browser gamepad
  12778. */
  12779. constructor(id: string, index: number, browserGamepad: any);
  12780. private _setButtonValue;
  12781. /**
  12782. * Updates the generic gamepad
  12783. */
  12784. update(): void;
  12785. /**
  12786. * Disposes the generic gamepad
  12787. */
  12788. dispose(): void;
  12789. }
  12790. }
  12791. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12792. import { Observable } from "babylonjs/Misc/observable";
  12793. import { Nullable } from "babylonjs/types";
  12794. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12795. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12797. import { Ray } from "babylonjs/Culling/ray";
  12798. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12799. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12800. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12801. /**
  12802. * Defines the types of pose enabled controllers that are supported
  12803. */
  12804. export enum PoseEnabledControllerType {
  12805. /**
  12806. * HTC Vive
  12807. */
  12808. VIVE = 0,
  12809. /**
  12810. * Oculus Rift
  12811. */
  12812. OCULUS = 1,
  12813. /**
  12814. * Windows mixed reality
  12815. */
  12816. WINDOWS = 2,
  12817. /**
  12818. * Samsung gear VR
  12819. */
  12820. GEAR_VR = 3,
  12821. /**
  12822. * Google Daydream
  12823. */
  12824. DAYDREAM = 4,
  12825. /**
  12826. * Generic
  12827. */
  12828. GENERIC = 5
  12829. }
  12830. /**
  12831. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12832. */
  12833. export interface MutableGamepadButton {
  12834. /**
  12835. * Value of the button/trigger
  12836. */
  12837. value: number;
  12838. /**
  12839. * If the button/trigger is currently touched
  12840. */
  12841. touched: boolean;
  12842. /**
  12843. * If the button/trigger is currently pressed
  12844. */
  12845. pressed: boolean;
  12846. }
  12847. /**
  12848. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12849. * @hidden
  12850. */
  12851. export interface ExtendedGamepadButton extends GamepadButton {
  12852. /**
  12853. * If the button/trigger is currently pressed
  12854. */
  12855. readonly pressed: boolean;
  12856. /**
  12857. * If the button/trigger is currently touched
  12858. */
  12859. readonly touched: boolean;
  12860. /**
  12861. * Value of the button/trigger
  12862. */
  12863. readonly value: number;
  12864. }
  12865. /** @hidden */
  12866. export interface _GamePadFactory {
  12867. /**
  12868. * Returns wether or not the current gamepad can be created for this type of controller.
  12869. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12870. * @returns true if it can be created, otherwise false
  12871. */
  12872. canCreate(gamepadInfo: any): boolean;
  12873. /**
  12874. * Creates a new instance of the Gamepad.
  12875. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12876. * @returns the new gamepad instance
  12877. */
  12878. create(gamepadInfo: any): Gamepad;
  12879. }
  12880. /**
  12881. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12882. */
  12883. export class PoseEnabledControllerHelper {
  12884. /** @hidden */
  12885. static _ControllerFactories: _GamePadFactory[];
  12886. /** @hidden */
  12887. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12888. /**
  12889. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12890. * @param vrGamepad the gamepad to initialized
  12891. * @returns a vr controller of the type the gamepad identified as
  12892. */
  12893. static InitiateController(vrGamepad: any): Gamepad;
  12894. }
  12895. /**
  12896. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12897. */
  12898. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12899. private _deviceRoomPosition;
  12900. private _deviceRoomRotationQuaternion;
  12901. /**
  12902. * The device position in babylon space
  12903. */
  12904. devicePosition: Vector3;
  12905. /**
  12906. * The device rotation in babylon space
  12907. */
  12908. deviceRotationQuaternion: Quaternion;
  12909. /**
  12910. * The scale factor of the device in babylon space
  12911. */
  12912. deviceScaleFactor: number;
  12913. /**
  12914. * (Likely devicePosition should be used instead) The device position in its room space
  12915. */
  12916. position: Vector3;
  12917. /**
  12918. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12919. */
  12920. rotationQuaternion: Quaternion;
  12921. /**
  12922. * The type of controller (Eg. Windows mixed reality)
  12923. */
  12924. controllerType: PoseEnabledControllerType;
  12925. protected _calculatedPosition: Vector3;
  12926. private _calculatedRotation;
  12927. /**
  12928. * The raw pose from the device
  12929. */
  12930. rawPose: DevicePose;
  12931. private _trackPosition;
  12932. private _maxRotationDistFromHeadset;
  12933. private _draggedRoomRotation;
  12934. /**
  12935. * @hidden
  12936. */
  12937. _disableTrackPosition(fixedPosition: Vector3): void;
  12938. /**
  12939. * Internal, the mesh attached to the controller
  12940. * @hidden
  12941. */
  12942. _mesh: Nullable<AbstractMesh>;
  12943. private _poseControlledCamera;
  12944. private _leftHandSystemQuaternion;
  12945. /**
  12946. * Internal, matrix used to convert room space to babylon space
  12947. * @hidden
  12948. */
  12949. _deviceToWorld: Matrix;
  12950. /**
  12951. * Node to be used when casting a ray from the controller
  12952. * @hidden
  12953. */
  12954. _pointingPoseNode: Nullable<TransformNode>;
  12955. /**
  12956. * Name of the child mesh that can be used to cast a ray from the controller
  12957. */
  12958. static readonly POINTING_POSE: string;
  12959. /**
  12960. * Creates a new PoseEnabledController from a gamepad
  12961. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12962. */
  12963. constructor(browserGamepad: any);
  12964. private _workingMatrix;
  12965. /**
  12966. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12967. */
  12968. update(): void;
  12969. /**
  12970. * Updates only the pose device and mesh without doing any button event checking
  12971. */
  12972. protected _updatePoseAndMesh(): void;
  12973. /**
  12974. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12975. * @param poseData raw pose fromthe device
  12976. */
  12977. updateFromDevice(poseData: DevicePose): void;
  12978. /**
  12979. * @hidden
  12980. */
  12981. _meshAttachedObservable: Observable<AbstractMesh>;
  12982. /**
  12983. * Attaches a mesh to the controller
  12984. * @param mesh the mesh to be attached
  12985. */
  12986. attachToMesh(mesh: AbstractMesh): void;
  12987. /**
  12988. * Attaches the controllers mesh to a camera
  12989. * @param camera the camera the mesh should be attached to
  12990. */
  12991. attachToPoseControlledCamera(camera: TargetCamera): void;
  12992. /**
  12993. * Disposes of the controller
  12994. */
  12995. dispose(): void;
  12996. /**
  12997. * The mesh that is attached to the controller
  12998. */
  12999. readonly mesh: Nullable<AbstractMesh>;
  13000. /**
  13001. * Gets the ray of the controller in the direction the controller is pointing
  13002. * @param length the length the resulting ray should be
  13003. * @returns a ray in the direction the controller is pointing
  13004. */
  13005. getForwardRay(length?: number): Ray;
  13006. }
  13007. }
  13008. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13009. import { Observable } from "babylonjs/Misc/observable";
  13010. import { Scene } from "babylonjs/scene";
  13011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13012. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13013. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13014. /**
  13015. * Defines the WebVRController object that represents controllers tracked in 3D space
  13016. */
  13017. export abstract class WebVRController extends PoseEnabledController {
  13018. /**
  13019. * Internal, the default controller model for the controller
  13020. */
  13021. protected _defaultModel: AbstractMesh;
  13022. /**
  13023. * Fired when the trigger state has changed
  13024. */
  13025. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13026. /**
  13027. * Fired when the main button state has changed
  13028. */
  13029. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13030. /**
  13031. * Fired when the secondary button state has changed
  13032. */
  13033. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13034. /**
  13035. * Fired when the pad state has changed
  13036. */
  13037. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13038. /**
  13039. * Fired when controllers stick values have changed
  13040. */
  13041. onPadValuesChangedObservable: Observable<StickValues>;
  13042. /**
  13043. * Array of button availible on the controller
  13044. */
  13045. protected _buttons: Array<MutableGamepadButton>;
  13046. private _onButtonStateChange;
  13047. /**
  13048. * Fired when a controller button's state has changed
  13049. * @param callback the callback containing the button that was modified
  13050. */
  13051. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13052. /**
  13053. * X and Y axis corrisponding to the controllers joystick
  13054. */
  13055. pad: StickValues;
  13056. /**
  13057. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13058. */
  13059. hand: string;
  13060. /**
  13061. * The default controller model for the controller
  13062. */
  13063. readonly defaultModel: AbstractMesh;
  13064. /**
  13065. * Creates a new WebVRController from a gamepad
  13066. * @param vrGamepad the gamepad that the WebVRController should be created from
  13067. */
  13068. constructor(vrGamepad: any);
  13069. /**
  13070. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13071. */
  13072. update(): void;
  13073. /**
  13074. * Function to be called when a button is modified
  13075. */
  13076. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13077. /**
  13078. * Loads a mesh and attaches it to the controller
  13079. * @param scene the scene the mesh should be added to
  13080. * @param meshLoaded callback for when the mesh has been loaded
  13081. */
  13082. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13083. private _setButtonValue;
  13084. private _changes;
  13085. private _checkChanges;
  13086. /**
  13087. * Disposes of th webVRCOntroller
  13088. */
  13089. dispose(): void;
  13090. }
  13091. }
  13092. declare module "babylonjs/Lights/hemisphericLight" {
  13093. import { Nullable } from "babylonjs/types";
  13094. import { Scene } from "babylonjs/scene";
  13095. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13096. import { Effect } from "babylonjs/Materials/effect";
  13097. import { Light } from "babylonjs/Lights/light";
  13098. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13099. /**
  13100. * The HemisphericLight simulates the ambient environment light,
  13101. * so the passed direction is the light reflection direction, not the incoming direction.
  13102. */
  13103. export class HemisphericLight extends Light {
  13104. /**
  13105. * The groundColor is the light in the opposite direction to the one specified during creation.
  13106. * 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.
  13107. */
  13108. groundColor: Color3;
  13109. /**
  13110. * The light reflection direction, not the incoming direction.
  13111. */
  13112. direction: Vector3;
  13113. /**
  13114. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13115. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13116. * The HemisphericLight can't cast shadows.
  13117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13118. * @param name The friendly name of the light
  13119. * @param direction The direction of the light reflection
  13120. * @param scene The scene the light belongs to
  13121. */
  13122. constructor(name: string, direction: Vector3, scene: Scene);
  13123. protected _buildUniformLayout(): void;
  13124. /**
  13125. * Returns the string "HemisphericLight".
  13126. * @return The class name
  13127. */
  13128. getClassName(): string;
  13129. /**
  13130. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13131. * Returns the updated direction.
  13132. * @param target The target the direction should point to
  13133. * @return The computed direction
  13134. */
  13135. setDirectionToTarget(target: Vector3): Vector3;
  13136. /**
  13137. * Returns the shadow generator associated to the light.
  13138. * @returns Always null for hemispheric lights because it does not support shadows.
  13139. */
  13140. getShadowGenerator(): Nullable<IShadowGenerator>;
  13141. /**
  13142. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13143. * @param effect The effect to update
  13144. * @param lightIndex The index of the light in the effect to update
  13145. * @returns The hemispheric light
  13146. */
  13147. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13148. /**
  13149. * Computes the world matrix of the node
  13150. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13151. * @param useWasUpdatedFlag defines a reserved property
  13152. * @returns the world matrix
  13153. */
  13154. computeWorldMatrix(): Matrix;
  13155. /**
  13156. * Returns the integer 3.
  13157. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13158. */
  13159. getTypeID(): number;
  13160. /**
  13161. * Prepares the list of defines specific to the light type.
  13162. * @param defines the list of defines
  13163. * @param lightIndex defines the index of the light for the effect
  13164. */
  13165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13166. }
  13167. }
  13168. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13169. /** @hidden */
  13170. export var vrMultiviewToSingleviewPixelShader: {
  13171. name: string;
  13172. shader: string;
  13173. };
  13174. }
  13175. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13176. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13177. import { Scene } from "babylonjs/scene";
  13178. /**
  13179. * Renders to multiple views with a single draw call
  13180. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13181. */
  13182. export class MultiviewRenderTarget extends RenderTargetTexture {
  13183. /**
  13184. * Creates a multiview render target
  13185. * @param scene scene used with the render target
  13186. * @param size the size of the render target (used for each view)
  13187. */
  13188. constructor(scene: Scene, size?: number | {
  13189. width: number;
  13190. height: number;
  13191. } | {
  13192. ratio: number;
  13193. });
  13194. /**
  13195. * @hidden
  13196. * @param faceIndex the face index, if its a cube texture
  13197. */
  13198. _bindFrameBuffer(faceIndex?: number): void;
  13199. /**
  13200. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13201. * @returns the view count
  13202. */
  13203. getViewCount(): number;
  13204. }
  13205. }
  13206. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13207. import { Camera } from "babylonjs/Cameras/camera";
  13208. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13209. import { Nullable } from "babylonjs/types";
  13210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13211. import { Matrix } from "babylonjs/Maths/math";
  13212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13213. module "babylonjs/Engines/engine" {
  13214. interface Engine {
  13215. /**
  13216. * Creates a new multiview render target
  13217. * @param width defines the width of the texture
  13218. * @param height defines the height of the texture
  13219. * @returns the created multiview texture
  13220. */
  13221. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13222. /**
  13223. * Binds a multiview framebuffer to be drawn to
  13224. * @param multiviewTexture texture to bind
  13225. */
  13226. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13227. }
  13228. }
  13229. module "babylonjs/Cameras/camera" {
  13230. interface Camera {
  13231. /**
  13232. * @hidden
  13233. * 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)
  13234. */
  13235. _useMultiviewToSingleView: boolean;
  13236. /**
  13237. * @hidden
  13238. * 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)
  13239. */
  13240. _multiviewTexture: Nullable<RenderTargetTexture>;
  13241. /**
  13242. * @hidden
  13243. * ensures the multiview texture of the camera exists and has the specified width/height
  13244. * @param width height to set on the multiview texture
  13245. * @param height width to set on the multiview texture
  13246. */
  13247. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13248. }
  13249. }
  13250. module "babylonjs/scene" {
  13251. interface Scene {
  13252. /** @hidden */
  13253. _transformMatrixR: Matrix;
  13254. /** @hidden */
  13255. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13256. /** @hidden */
  13257. _createMultiviewUbo(): void;
  13258. /** @hidden */
  13259. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13260. /** @hidden */
  13261. _renderMultiviewToSingleView(camera: Camera): void;
  13262. }
  13263. }
  13264. }
  13265. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13266. import { Camera } from "babylonjs/Cameras/camera";
  13267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13268. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13269. import "babylonjs/Engines/Extensions/engine.multiview";
  13270. /**
  13271. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13272. * This will not be used for webXR as it supports displaying texture arrays directly
  13273. */
  13274. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13275. /**
  13276. * Initializes a VRMultiviewToSingleview
  13277. * @param name name of the post process
  13278. * @param camera camera to be applied to
  13279. * @param scaleFactor scaling factor to the size of the output texture
  13280. */
  13281. constructor(name: string, camera: Camera, scaleFactor: number);
  13282. }
  13283. }
  13284. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13285. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13286. import { Nullable } from "babylonjs/types";
  13287. import { Observable } from "babylonjs/Misc/observable";
  13288. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13289. import { Scene } from "babylonjs/scene";
  13290. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13291. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13292. import { Node } from "babylonjs/node";
  13293. import { Ray } from "babylonjs/Culling/ray";
  13294. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13295. /**
  13296. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13297. * IMPORTANT!! The data is right-hand data.
  13298. * @export
  13299. * @interface DevicePose
  13300. */
  13301. export interface DevicePose {
  13302. /**
  13303. * The position of the device, values in array are [x,y,z].
  13304. */
  13305. readonly position: Nullable<Float32Array>;
  13306. /**
  13307. * The linearVelocity of the device, values in array are [x,y,z].
  13308. */
  13309. readonly linearVelocity: Nullable<Float32Array>;
  13310. /**
  13311. * The linearAcceleration of the device, values in array are [x,y,z].
  13312. */
  13313. readonly linearAcceleration: Nullable<Float32Array>;
  13314. /**
  13315. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13316. */
  13317. readonly orientation: Nullable<Float32Array>;
  13318. /**
  13319. * The angularVelocity of the device, values in array are [x,y,z].
  13320. */
  13321. readonly angularVelocity: Nullable<Float32Array>;
  13322. /**
  13323. * The angularAcceleration of the device, values in array are [x,y,z].
  13324. */
  13325. readonly angularAcceleration: Nullable<Float32Array>;
  13326. }
  13327. /**
  13328. * Interface representing a pose controlled object in Babylon.
  13329. * A pose controlled object has both regular pose values as well as pose values
  13330. * from an external device such as a VR head mounted display
  13331. */
  13332. export interface PoseControlled {
  13333. /**
  13334. * The position of the object in babylon space.
  13335. */
  13336. position: Vector3;
  13337. /**
  13338. * The rotation quaternion of the object in babylon space.
  13339. */
  13340. rotationQuaternion: Quaternion;
  13341. /**
  13342. * The position of the device in babylon space.
  13343. */
  13344. devicePosition?: Vector3;
  13345. /**
  13346. * The rotation quaternion of the device in babylon space.
  13347. */
  13348. deviceRotationQuaternion: Quaternion;
  13349. /**
  13350. * The raw pose coming from the device.
  13351. */
  13352. rawPose: Nullable<DevicePose>;
  13353. /**
  13354. * The scale of the device to be used when translating from device space to babylon space.
  13355. */
  13356. deviceScaleFactor: number;
  13357. /**
  13358. * Updates the poseControlled values based on the input device pose.
  13359. * @param poseData the pose data to update the object with
  13360. */
  13361. updateFromDevice(poseData: DevicePose): void;
  13362. }
  13363. /**
  13364. * Set of options to customize the webVRCamera
  13365. */
  13366. export interface WebVROptions {
  13367. /**
  13368. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13369. */
  13370. trackPosition?: boolean;
  13371. /**
  13372. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13373. */
  13374. positionScale?: number;
  13375. /**
  13376. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13377. */
  13378. displayName?: string;
  13379. /**
  13380. * Should the native controller meshes be initialized. (default: true)
  13381. */
  13382. controllerMeshes?: boolean;
  13383. /**
  13384. * Creating a default HemiLight only on controllers. (default: true)
  13385. */
  13386. defaultLightingOnControllers?: boolean;
  13387. /**
  13388. * If you don't want to use the default VR button of the helper. (default: false)
  13389. */
  13390. useCustomVRButton?: boolean;
  13391. /**
  13392. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13393. */
  13394. customVRButton?: HTMLButtonElement;
  13395. /**
  13396. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13397. */
  13398. rayLength?: number;
  13399. /**
  13400. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13401. */
  13402. defaultHeight?: number;
  13403. /**
  13404. * If multiview should be used if availible (default: false)
  13405. */
  13406. useMultiview?: boolean;
  13407. }
  13408. /**
  13409. * This represents a WebVR camera.
  13410. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13411. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13412. */
  13413. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13414. private webVROptions;
  13415. /**
  13416. * @hidden
  13417. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13418. */
  13419. _vrDevice: any;
  13420. /**
  13421. * The rawPose of the vrDevice.
  13422. */
  13423. rawPose: Nullable<DevicePose>;
  13424. private _onVREnabled;
  13425. private _specsVersion;
  13426. private _attached;
  13427. private _frameData;
  13428. protected _descendants: Array<Node>;
  13429. private _deviceRoomPosition;
  13430. /** @hidden */
  13431. _deviceRoomRotationQuaternion: Quaternion;
  13432. private _standingMatrix;
  13433. /**
  13434. * Represents device position in babylon space.
  13435. */
  13436. devicePosition: Vector3;
  13437. /**
  13438. * Represents device rotation in babylon space.
  13439. */
  13440. deviceRotationQuaternion: Quaternion;
  13441. /**
  13442. * The scale of the device to be used when translating from device space to babylon space.
  13443. */
  13444. deviceScaleFactor: number;
  13445. private _deviceToWorld;
  13446. private _worldToDevice;
  13447. /**
  13448. * References to the webVR controllers for the vrDevice.
  13449. */
  13450. controllers: Array<WebVRController>;
  13451. /**
  13452. * Emits an event when a controller is attached.
  13453. */
  13454. onControllersAttachedObservable: Observable<WebVRController[]>;
  13455. /**
  13456. * Emits an event when a controller's mesh has been loaded;
  13457. */
  13458. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13459. /**
  13460. * Emits an event when the HMD's pose has been updated.
  13461. */
  13462. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13463. private _poseSet;
  13464. /**
  13465. * If the rig cameras be used as parent instead of this camera.
  13466. */
  13467. rigParenting: boolean;
  13468. private _lightOnControllers;
  13469. private _defaultHeight?;
  13470. /**
  13471. * Instantiates a WebVRFreeCamera.
  13472. * @param name The name of the WebVRFreeCamera
  13473. * @param position The starting anchor position for the camera
  13474. * @param scene The scene the camera belongs to
  13475. * @param webVROptions a set of customizable options for the webVRCamera
  13476. */
  13477. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13478. /**
  13479. * Gets the device distance from the ground in meters.
  13480. * @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.
  13481. */
  13482. deviceDistanceToRoomGround(): number;
  13483. /**
  13484. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13485. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13486. */
  13487. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13488. /**
  13489. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13490. * @returns A promise with a boolean set to if the standing matrix is supported.
  13491. */
  13492. useStandingMatrixAsync(): Promise<boolean>;
  13493. /**
  13494. * Disposes the camera
  13495. */
  13496. dispose(): void;
  13497. /**
  13498. * Gets a vrController by name.
  13499. * @param name The name of the controller to retreive
  13500. * @returns the controller matching the name specified or null if not found
  13501. */
  13502. getControllerByName(name: string): Nullable<WebVRController>;
  13503. private _leftController;
  13504. /**
  13505. * The controller corrisponding to the users left hand.
  13506. */
  13507. readonly leftController: Nullable<WebVRController>;
  13508. private _rightController;
  13509. /**
  13510. * The controller corrisponding to the users right hand.
  13511. */
  13512. readonly rightController: Nullable<WebVRController>;
  13513. /**
  13514. * Casts a ray forward from the vrCamera's gaze.
  13515. * @param length Length of the ray (default: 100)
  13516. * @returns the ray corrisponding to the gaze
  13517. */
  13518. getForwardRay(length?: number): Ray;
  13519. /**
  13520. * @hidden
  13521. * Updates the camera based on device's frame data
  13522. */
  13523. _checkInputs(): void;
  13524. /**
  13525. * Updates the poseControlled values based on the input device pose.
  13526. * @param poseData Pose coming from the device
  13527. */
  13528. updateFromDevice(poseData: DevicePose): void;
  13529. private _htmlElementAttached;
  13530. private _detachIfAttached;
  13531. /**
  13532. * WebVR's attach control will start broadcasting frames to the device.
  13533. * Note that in certain browsers (chrome for example) this function must be called
  13534. * within a user-interaction callback. Example:
  13535. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13536. *
  13537. * @param element html element to attach the vrDevice to
  13538. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13539. */
  13540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13541. /**
  13542. * Detaches the camera from the html element and disables VR
  13543. *
  13544. * @param element html element to detach from
  13545. */
  13546. detachControl(element: HTMLElement): void;
  13547. /**
  13548. * @returns the name of this class
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Calls resetPose on the vrDisplay
  13553. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13554. */
  13555. resetToCurrentRotation(): void;
  13556. /**
  13557. * @hidden
  13558. * Updates the rig cameras (left and right eye)
  13559. */
  13560. _updateRigCameras(): void;
  13561. private _workingVector;
  13562. private _oneVector;
  13563. private _workingMatrix;
  13564. private updateCacheCalled;
  13565. private _correctPositionIfNotTrackPosition;
  13566. /**
  13567. * @hidden
  13568. * Updates the cached values of the camera
  13569. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13570. */
  13571. _updateCache(ignoreParentClass?: boolean): void;
  13572. /**
  13573. * @hidden
  13574. * Get current device position in babylon world
  13575. */
  13576. _computeDevicePosition(): void;
  13577. /**
  13578. * Updates the current device position and rotation in the babylon world
  13579. */
  13580. update(): void;
  13581. /**
  13582. * @hidden
  13583. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13584. * @returns an identity matrix
  13585. */
  13586. _getViewMatrix(): Matrix;
  13587. private _tmpMatrix;
  13588. /**
  13589. * This function is called by the two RIG cameras.
  13590. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13591. * @hidden
  13592. */
  13593. _getWebVRViewMatrix(): Matrix;
  13594. /** @hidden */
  13595. _getWebVRProjectionMatrix(): Matrix;
  13596. private _onGamepadConnectedObserver;
  13597. private _onGamepadDisconnectedObserver;
  13598. private _updateCacheWhenTrackingDisabledObserver;
  13599. /**
  13600. * Initializes the controllers and their meshes
  13601. */
  13602. initControllers(): void;
  13603. }
  13604. }
  13605. declare module "babylonjs/PostProcesses/postProcess" {
  13606. import { Nullable } from "babylonjs/types";
  13607. import { SmartArray } from "babylonjs/Misc/smartArray";
  13608. import { Observable } from "babylonjs/Misc/observable";
  13609. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13610. import { Camera } from "babylonjs/Cameras/camera";
  13611. import { Effect } from "babylonjs/Materials/effect";
  13612. import "babylonjs/Shaders/postprocess.vertex";
  13613. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13615. import { Engine } from "babylonjs/Engines/engine";
  13616. /**
  13617. * Size options for a post process
  13618. */
  13619. export type PostProcessOptions = {
  13620. width: number;
  13621. height: number;
  13622. };
  13623. /**
  13624. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13625. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13626. */
  13627. export class PostProcess {
  13628. /** Name of the PostProcess. */
  13629. name: string;
  13630. /**
  13631. * Gets or sets the unique id of the post process
  13632. */
  13633. uniqueId: number;
  13634. /**
  13635. * Width of the texture to apply the post process on
  13636. */
  13637. width: number;
  13638. /**
  13639. * Height of the texture to apply the post process on
  13640. */
  13641. height: number;
  13642. /**
  13643. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13644. * @hidden
  13645. */
  13646. _outputTexture: Nullable<InternalTexture>;
  13647. /**
  13648. * Sampling mode used by the shader
  13649. * See https://doc.babylonjs.com/classes/3.1/texture
  13650. */
  13651. renderTargetSamplingMode: number;
  13652. /**
  13653. * Clear color to use when screen clearing
  13654. */
  13655. clearColor: Color4;
  13656. /**
  13657. * If the buffer needs to be cleared before applying the post process. (default: true)
  13658. * Should be set to false if shader will overwrite all previous pixels.
  13659. */
  13660. autoClear: boolean;
  13661. /**
  13662. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13663. */
  13664. alphaMode: number;
  13665. /**
  13666. * Sets the setAlphaBlendConstants of the babylon engine
  13667. */
  13668. alphaConstants: Color4;
  13669. /**
  13670. * Animations to be used for the post processing
  13671. */
  13672. animations: import("babylonjs/Animations/animation").Animation[];
  13673. /**
  13674. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13675. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13676. */
  13677. enablePixelPerfectMode: boolean;
  13678. /**
  13679. * Force the postprocess to be applied without taking in account viewport
  13680. */
  13681. forceFullscreenViewport: boolean;
  13682. /**
  13683. * List of inspectable custom properties (used by the Inspector)
  13684. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13685. */
  13686. inspectableCustomProperties: IInspectable[];
  13687. /**
  13688. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13689. *
  13690. * | Value | Type | Description |
  13691. * | ----- | ----------------------------------- | ----------- |
  13692. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13693. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13694. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13695. *
  13696. */
  13697. scaleMode: number;
  13698. /**
  13699. * Force textures to be a power of two (default: false)
  13700. */
  13701. alwaysForcePOT: boolean;
  13702. private _samples;
  13703. /**
  13704. * Number of sample textures (default: 1)
  13705. */
  13706. samples: number;
  13707. /**
  13708. * Modify the scale of the post process to be the same as the viewport (default: false)
  13709. */
  13710. adaptScaleToCurrentViewport: boolean;
  13711. private _camera;
  13712. private _scene;
  13713. private _engine;
  13714. private _options;
  13715. private _reusable;
  13716. private _textureType;
  13717. /**
  13718. * Smart array of input and output textures for the post process.
  13719. * @hidden
  13720. */
  13721. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13722. /**
  13723. * The index in _textures that corresponds to the output texture.
  13724. * @hidden
  13725. */
  13726. _currentRenderTextureInd: number;
  13727. private _effect;
  13728. private _samplers;
  13729. private _fragmentUrl;
  13730. private _vertexUrl;
  13731. private _parameters;
  13732. private _scaleRatio;
  13733. protected _indexParameters: any;
  13734. private _shareOutputWithPostProcess;
  13735. private _texelSize;
  13736. private _forcedOutputTexture;
  13737. /**
  13738. * Returns the fragment url or shader name used in the post process.
  13739. * @returns the fragment url or name in the shader store.
  13740. */
  13741. getEffectName(): string;
  13742. /**
  13743. * An event triggered when the postprocess is activated.
  13744. */
  13745. onActivateObservable: Observable<Camera>;
  13746. private _onActivateObserver;
  13747. /**
  13748. * A function that is added to the onActivateObservable
  13749. */
  13750. onActivate: Nullable<(camera: Camera) => void>;
  13751. /**
  13752. * An event triggered when the postprocess changes its size.
  13753. */
  13754. onSizeChangedObservable: Observable<PostProcess>;
  13755. private _onSizeChangedObserver;
  13756. /**
  13757. * A function that is added to the onSizeChangedObservable
  13758. */
  13759. onSizeChanged: (postProcess: PostProcess) => void;
  13760. /**
  13761. * An event triggered when the postprocess applies its effect.
  13762. */
  13763. onApplyObservable: Observable<Effect>;
  13764. private _onApplyObserver;
  13765. /**
  13766. * A function that is added to the onApplyObservable
  13767. */
  13768. onApply: (effect: Effect) => void;
  13769. /**
  13770. * An event triggered before rendering the postprocess
  13771. */
  13772. onBeforeRenderObservable: Observable<Effect>;
  13773. private _onBeforeRenderObserver;
  13774. /**
  13775. * A function that is added to the onBeforeRenderObservable
  13776. */
  13777. onBeforeRender: (effect: Effect) => void;
  13778. /**
  13779. * An event triggered after rendering the postprocess
  13780. */
  13781. onAfterRenderObservable: Observable<Effect>;
  13782. private _onAfterRenderObserver;
  13783. /**
  13784. * A function that is added to the onAfterRenderObservable
  13785. */
  13786. onAfterRender: (efect: Effect) => void;
  13787. /**
  13788. * 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
  13789. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13790. */
  13791. inputTexture: InternalTexture;
  13792. /**
  13793. * Gets the camera which post process is applied to.
  13794. * @returns The camera the post process is applied to.
  13795. */
  13796. getCamera(): Camera;
  13797. /**
  13798. * Gets the texel size of the postprocess.
  13799. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13800. */
  13801. readonly texelSize: Vector2;
  13802. /**
  13803. * Creates a new instance PostProcess
  13804. * @param name The name of the PostProcess.
  13805. * @param fragmentUrl The url of the fragment shader to be used.
  13806. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13807. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13808. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13809. * @param camera The camera to apply the render pass to.
  13810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13811. * @param engine The engine which the post process will be applied. (default: current engine)
  13812. * @param reusable If the post process can be reused on the same frame. (default: false)
  13813. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13814. * @param textureType Type of textures used when performing the post process. (default: 0)
  13815. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13816. * @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
  13817. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13818. */
  13819. constructor(
  13820. /** Name of the PostProcess. */
  13821. 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);
  13822. /**
  13823. * Gets a string idenfifying the name of the class
  13824. * @returns "PostProcess" string
  13825. */
  13826. getClassName(): string;
  13827. /**
  13828. * Gets the engine which this post process belongs to.
  13829. * @returns The engine the post process was enabled with.
  13830. */
  13831. getEngine(): Engine;
  13832. /**
  13833. * The effect that is created when initializing the post process.
  13834. * @returns The created effect corrisponding the the postprocess.
  13835. */
  13836. getEffect(): Effect;
  13837. /**
  13838. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13839. * @param postProcess The post process to share the output with.
  13840. * @returns This post process.
  13841. */
  13842. shareOutputWith(postProcess: PostProcess): PostProcess;
  13843. /**
  13844. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13845. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13846. */
  13847. useOwnOutput(): void;
  13848. /**
  13849. * Updates the effect with the current post process compile time values and recompiles the shader.
  13850. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13851. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13852. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13853. * @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
  13854. * @param onCompiled Called when the shader has been compiled.
  13855. * @param onError Called if there is an error when compiling a shader.
  13856. */
  13857. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13858. /**
  13859. * The post process is reusable if it can be used multiple times within one frame.
  13860. * @returns If the post process is reusable
  13861. */
  13862. isReusable(): boolean;
  13863. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13864. markTextureDirty(): void;
  13865. /**
  13866. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13867. * 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.
  13868. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13869. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13870. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13871. * @returns The target texture that was bound to be written to.
  13872. */
  13873. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13874. /**
  13875. * If the post process is supported.
  13876. */
  13877. readonly isSupported: boolean;
  13878. /**
  13879. * The aspect ratio of the output texture.
  13880. */
  13881. readonly aspectRatio: number;
  13882. /**
  13883. * Get a value indicating if the post-process is ready to be used
  13884. * @returns true if the post-process is ready (shader is compiled)
  13885. */
  13886. isReady(): boolean;
  13887. /**
  13888. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13889. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13890. */
  13891. apply(): Nullable<Effect>;
  13892. private _disposeTextures;
  13893. /**
  13894. * Disposes the post process.
  13895. * @param camera The camera to dispose the post process on.
  13896. */
  13897. dispose(camera?: Camera): void;
  13898. }
  13899. }
  13900. declare module "babylonjs/PostProcesses/postProcessManager" {
  13901. import { Nullable } from "babylonjs/types";
  13902. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13903. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13904. import { Scene } from "babylonjs/scene";
  13905. /**
  13906. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13907. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13908. */
  13909. export class PostProcessManager {
  13910. private _scene;
  13911. private _indexBuffer;
  13912. private _vertexBuffers;
  13913. /**
  13914. * Creates a new instance PostProcess
  13915. * @param scene The scene that the post process is associated with.
  13916. */
  13917. constructor(scene: Scene);
  13918. private _prepareBuffers;
  13919. private _buildIndexBuffer;
  13920. /**
  13921. * Rebuilds the vertex buffers of the manager.
  13922. * @hidden
  13923. */
  13924. _rebuild(): void;
  13925. /**
  13926. * Prepares a frame to be run through a post process.
  13927. * @param sourceTexture The input texture to the post procesess. (default: null)
  13928. * @param postProcesses An array of post processes to be run. (default: null)
  13929. * @returns True if the post processes were able to be run.
  13930. * @hidden
  13931. */
  13932. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13933. /**
  13934. * Manually render a set of post processes to a texture.
  13935. * @param postProcesses An array of post processes to be run.
  13936. * @param targetTexture The target texture to render to.
  13937. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13938. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13939. * @param lodLevel defines which lod of the texture to render to
  13940. */
  13941. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13942. /**
  13943. * Finalize the result of the output of the postprocesses.
  13944. * @param doNotPresent If true the result will not be displayed to the screen.
  13945. * @param targetTexture The target texture to render to.
  13946. * @param faceIndex The index of the face to bind the target texture to.
  13947. * @param postProcesses The array of post processes to render.
  13948. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13949. * @hidden
  13950. */
  13951. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13952. /**
  13953. * Disposes of the post process manager.
  13954. */
  13955. dispose(): void;
  13956. }
  13957. }
  13958. declare module "babylonjs/Layers/layerSceneComponent" {
  13959. import { Scene } from "babylonjs/scene";
  13960. import { ISceneComponent } from "babylonjs/sceneComponent";
  13961. import { Layer } from "babylonjs/Layers/layer";
  13962. module "babylonjs/abstractScene" {
  13963. interface AbstractScene {
  13964. /**
  13965. * The list of layers (background and foreground) of the scene
  13966. */
  13967. layers: Array<Layer>;
  13968. }
  13969. }
  13970. /**
  13971. * Defines the layer scene component responsible to manage any layers
  13972. * in a given scene.
  13973. */
  13974. export class LayerSceneComponent implements ISceneComponent {
  13975. /**
  13976. * The component name helpfull to identify the component in the list of scene components.
  13977. */
  13978. readonly name: string;
  13979. /**
  13980. * The scene the component belongs to.
  13981. */
  13982. scene: Scene;
  13983. private _engine;
  13984. /**
  13985. * Creates a new instance of the component for the given scene
  13986. * @param scene Defines the scene to register the component in
  13987. */
  13988. constructor(scene: Scene);
  13989. /**
  13990. * Registers the component in a given scene
  13991. */
  13992. register(): void;
  13993. /**
  13994. * Rebuilds the elements related to this component in case of
  13995. * context lost for instance.
  13996. */
  13997. rebuild(): void;
  13998. /**
  13999. * Disposes the component and the associated ressources.
  14000. */
  14001. dispose(): void;
  14002. private _draw;
  14003. private _drawCameraPredicate;
  14004. private _drawCameraBackground;
  14005. private _drawCameraForeground;
  14006. private _drawRenderTargetPredicate;
  14007. private _drawRenderTargetBackground;
  14008. private _drawRenderTargetForeground;
  14009. }
  14010. }
  14011. declare module "babylonjs/Shaders/layer.fragment" {
  14012. /** @hidden */
  14013. export var layerPixelShader: {
  14014. name: string;
  14015. shader: string;
  14016. };
  14017. }
  14018. declare module "babylonjs/Shaders/layer.vertex" {
  14019. /** @hidden */
  14020. export var layerVertexShader: {
  14021. name: string;
  14022. shader: string;
  14023. };
  14024. }
  14025. declare module "babylonjs/Layers/layer" {
  14026. import { Observable } from "babylonjs/Misc/observable";
  14027. import { Nullable } from "babylonjs/types";
  14028. import { Scene } from "babylonjs/scene";
  14029. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14030. import { Texture } from "babylonjs/Materials/Textures/texture";
  14031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14032. import "babylonjs/Shaders/layer.fragment";
  14033. import "babylonjs/Shaders/layer.vertex";
  14034. /**
  14035. * This represents a full screen 2d layer.
  14036. * This can be useful to display a picture in the background of your scene for instance.
  14037. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14038. */
  14039. export class Layer {
  14040. /**
  14041. * Define the name of the layer.
  14042. */
  14043. name: string;
  14044. /**
  14045. * Define the texture the layer should display.
  14046. */
  14047. texture: Nullable<Texture>;
  14048. /**
  14049. * Is the layer in background or foreground.
  14050. */
  14051. isBackground: boolean;
  14052. /**
  14053. * Define the color of the layer (instead of texture).
  14054. */
  14055. color: Color4;
  14056. /**
  14057. * Define the scale of the layer in order to zoom in out of the texture.
  14058. */
  14059. scale: Vector2;
  14060. /**
  14061. * Define an offset for the layer in order to shift the texture.
  14062. */
  14063. offset: Vector2;
  14064. /**
  14065. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14066. */
  14067. alphaBlendingMode: number;
  14068. /**
  14069. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14070. * Alpha test will not mix with the background color in case of transparency.
  14071. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14072. */
  14073. alphaTest: boolean;
  14074. /**
  14075. * Define a mask to restrict the layer to only some of the scene cameras.
  14076. */
  14077. layerMask: number;
  14078. /**
  14079. * Define the list of render target the layer is visible into.
  14080. */
  14081. renderTargetTextures: RenderTargetTexture[];
  14082. /**
  14083. * Define if the layer is only used in renderTarget or if it also
  14084. * renders in the main frame buffer of the canvas.
  14085. */
  14086. renderOnlyInRenderTargetTextures: boolean;
  14087. private _scene;
  14088. private _vertexBuffers;
  14089. private _indexBuffer;
  14090. private _effect;
  14091. private _alphaTestEffect;
  14092. /**
  14093. * An event triggered when the layer is disposed.
  14094. */
  14095. onDisposeObservable: Observable<Layer>;
  14096. private _onDisposeObserver;
  14097. /**
  14098. * Back compatibility with callback before the onDisposeObservable existed.
  14099. * The set callback will be triggered when the layer has been disposed.
  14100. */
  14101. onDispose: () => void;
  14102. /**
  14103. * An event triggered before rendering the scene
  14104. */
  14105. onBeforeRenderObservable: Observable<Layer>;
  14106. private _onBeforeRenderObserver;
  14107. /**
  14108. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14109. * The set callback will be triggered just before rendering the layer.
  14110. */
  14111. onBeforeRender: () => void;
  14112. /**
  14113. * An event triggered after rendering the scene
  14114. */
  14115. onAfterRenderObservable: Observable<Layer>;
  14116. private _onAfterRenderObserver;
  14117. /**
  14118. * Back compatibility with callback before the onAfterRenderObservable existed.
  14119. * The set callback will be triggered just after rendering the layer.
  14120. */
  14121. onAfterRender: () => void;
  14122. /**
  14123. * Instantiates a new layer.
  14124. * This represents a full screen 2d layer.
  14125. * This can be useful to display a picture in the background of your scene for instance.
  14126. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14127. * @param name Define the name of the layer in the scene
  14128. * @param imgUrl Define the url of the texture to display in the layer
  14129. * @param scene Define the scene the layer belongs to
  14130. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14131. * @param color Defines a color for the layer
  14132. */
  14133. constructor(
  14134. /**
  14135. * Define the name of the layer.
  14136. */
  14137. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14138. private _createIndexBuffer;
  14139. /** @hidden */
  14140. _rebuild(): void;
  14141. /**
  14142. * Renders the layer in the scene.
  14143. */
  14144. render(): void;
  14145. /**
  14146. * Disposes and releases the associated ressources.
  14147. */
  14148. dispose(): void;
  14149. }
  14150. }
  14151. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14152. import { Scene } from "babylonjs/scene";
  14153. import { ISceneComponent } from "babylonjs/sceneComponent";
  14154. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14155. module "babylonjs/abstractScene" {
  14156. interface AbstractScene {
  14157. /**
  14158. * The list of procedural textures added to the scene
  14159. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14160. */
  14161. proceduralTextures: Array<ProceduralTexture>;
  14162. }
  14163. }
  14164. /**
  14165. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14166. * in a given scene.
  14167. */
  14168. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14169. /**
  14170. * The component name helpfull to identify the component in the list of scene components.
  14171. */
  14172. readonly name: string;
  14173. /**
  14174. * The scene the component belongs to.
  14175. */
  14176. scene: Scene;
  14177. /**
  14178. * Creates a new instance of the component for the given scene
  14179. * @param scene Defines the scene to register the component in
  14180. */
  14181. constructor(scene: Scene);
  14182. /**
  14183. * Registers the component in a given scene
  14184. */
  14185. register(): void;
  14186. /**
  14187. * Rebuilds the elements related to this component in case of
  14188. * context lost for instance.
  14189. */
  14190. rebuild(): void;
  14191. /**
  14192. * Disposes the component and the associated ressources.
  14193. */
  14194. dispose(): void;
  14195. private _beforeClear;
  14196. }
  14197. }
  14198. declare module "babylonjs/Shaders/procedural.vertex" {
  14199. /** @hidden */
  14200. export var proceduralVertexShader: {
  14201. name: string;
  14202. shader: string;
  14203. };
  14204. }
  14205. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14206. import { Observable } from "babylonjs/Misc/observable";
  14207. import { Nullable } from "babylonjs/types";
  14208. import { Scene } from "babylonjs/scene";
  14209. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14210. import { Effect } from "babylonjs/Materials/effect";
  14211. import { Texture } from "babylonjs/Materials/Textures/texture";
  14212. import "babylonjs/Shaders/procedural.vertex";
  14213. /**
  14214. * 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.
  14215. * This is the base class of any Procedural texture and contains most of the shareable code.
  14216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14217. */
  14218. export class ProceduralTexture extends Texture {
  14219. isCube: boolean;
  14220. /**
  14221. * Define if the texture is enabled or not (disabled texture will not render)
  14222. */
  14223. isEnabled: boolean;
  14224. /**
  14225. * Define if the texture must be cleared before rendering (default is true)
  14226. */
  14227. autoClear: boolean;
  14228. /**
  14229. * Callback called when the texture is generated
  14230. */
  14231. onGenerated: () => void;
  14232. /**
  14233. * Event raised when the texture is generated
  14234. */
  14235. onGeneratedObservable: Observable<ProceduralTexture>;
  14236. /** @hidden */
  14237. _generateMipMaps: boolean;
  14238. /** @hidden **/
  14239. _effect: Effect;
  14240. /** @hidden */
  14241. _textures: {
  14242. [key: string]: Texture;
  14243. };
  14244. private _size;
  14245. private _currentRefreshId;
  14246. private _refreshRate;
  14247. private _vertexBuffers;
  14248. private _indexBuffer;
  14249. private _uniforms;
  14250. private _samplers;
  14251. private _fragment;
  14252. private _floats;
  14253. private _ints;
  14254. private _floatsArrays;
  14255. private _colors3;
  14256. private _colors4;
  14257. private _vectors2;
  14258. private _vectors3;
  14259. private _matrices;
  14260. private _fallbackTexture;
  14261. private _fallbackTextureUsed;
  14262. private _engine;
  14263. private _cachedDefines;
  14264. private _contentUpdateId;
  14265. private _contentData;
  14266. /**
  14267. * Instantiates a new procedural texture.
  14268. * 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.
  14269. * This is the base class of any Procedural texture and contains most of the shareable code.
  14270. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14271. * @param name Define the name of the texture
  14272. * @param size Define the size of the texture to create
  14273. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14274. * @param scene Define the scene the texture belongs to
  14275. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14276. * @param generateMipMaps Define if the texture should creates mip maps or not
  14277. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14278. */
  14279. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14280. /**
  14281. * The effect that is created when initializing the post process.
  14282. * @returns The created effect corrisponding the the postprocess.
  14283. */
  14284. getEffect(): Effect;
  14285. /**
  14286. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14287. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14288. */
  14289. getContent(): Nullable<ArrayBufferView>;
  14290. private _createIndexBuffer;
  14291. /** @hidden */
  14292. _rebuild(): void;
  14293. /**
  14294. * Resets the texture in order to recreate its associated resources.
  14295. * This can be called in case of context loss
  14296. */
  14297. reset(): void;
  14298. protected _getDefines(): string;
  14299. /**
  14300. * Is the texture ready to be used ? (rendered at least once)
  14301. * @returns true if ready, otherwise, false.
  14302. */
  14303. isReady(): boolean;
  14304. /**
  14305. * Resets the refresh counter of the texture and start bak from scratch.
  14306. * Could be useful to regenerate the texture if it is setup to render only once.
  14307. */
  14308. resetRefreshCounter(): void;
  14309. /**
  14310. * Set the fragment shader to use in order to render the texture.
  14311. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14312. */
  14313. setFragment(fragment: any): void;
  14314. /**
  14315. * Define the refresh rate of the texture or the rendering frequency.
  14316. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14317. */
  14318. refreshRate: number;
  14319. /** @hidden */
  14320. _shouldRender(): boolean;
  14321. /**
  14322. * Get the size the texture is rendering at.
  14323. * @returns the size (texture is always squared)
  14324. */
  14325. getRenderSize(): number;
  14326. /**
  14327. * Resize the texture to new value.
  14328. * @param size Define the new size the texture should have
  14329. * @param generateMipMaps Define whether the new texture should create mip maps
  14330. */
  14331. resize(size: number, generateMipMaps: boolean): void;
  14332. private _checkUniform;
  14333. /**
  14334. * Set a texture in the shader program used to render.
  14335. * @param name Define the name of the uniform samplers as defined in the shader
  14336. * @param texture Define the texture to bind to this sampler
  14337. * @return the texture itself allowing "fluent" like uniform updates
  14338. */
  14339. setTexture(name: string, texture: Texture): ProceduralTexture;
  14340. /**
  14341. * Set a float in the shader.
  14342. * @param name Define the name of the uniform as defined in the shader
  14343. * @param value Define the value to give to the uniform
  14344. * @return the texture itself allowing "fluent" like uniform updates
  14345. */
  14346. setFloat(name: string, value: number): ProceduralTexture;
  14347. /**
  14348. * Set a int in the shader.
  14349. * @param name Define the name of the uniform as defined in the shader
  14350. * @param value Define the value to give to the uniform
  14351. * @return the texture itself allowing "fluent" like uniform updates
  14352. */
  14353. setInt(name: string, value: number): ProceduralTexture;
  14354. /**
  14355. * Set an array of floats in the shader.
  14356. * @param name Define the name of the uniform as defined in the shader
  14357. * @param value Define the value to give to the uniform
  14358. * @return the texture itself allowing "fluent" like uniform updates
  14359. */
  14360. setFloats(name: string, value: number[]): ProceduralTexture;
  14361. /**
  14362. * Set a vec3 in the shader from a Color3.
  14363. * @param name Define the name of the uniform as defined in the shader
  14364. * @param value Define the value to give to the uniform
  14365. * @return the texture itself allowing "fluent" like uniform updates
  14366. */
  14367. setColor3(name: string, value: Color3): ProceduralTexture;
  14368. /**
  14369. * Set a vec4 in the shader from a Color4.
  14370. * @param name Define the name of the uniform as defined in the shader
  14371. * @param value Define the value to give to the uniform
  14372. * @return the texture itself allowing "fluent" like uniform updates
  14373. */
  14374. setColor4(name: string, value: Color4): ProceduralTexture;
  14375. /**
  14376. * Set a vec2 in the shader from a Vector2.
  14377. * @param name Define the name of the uniform as defined in the shader
  14378. * @param value Define the value to give to the uniform
  14379. * @return the texture itself allowing "fluent" like uniform updates
  14380. */
  14381. setVector2(name: string, value: Vector2): ProceduralTexture;
  14382. /**
  14383. * Set a vec3 in the shader from a Vector3.
  14384. * @param name Define the name of the uniform as defined in the shader
  14385. * @param value Define the value to give to the uniform
  14386. * @return the texture itself allowing "fluent" like uniform updates
  14387. */
  14388. setVector3(name: string, value: Vector3): ProceduralTexture;
  14389. /**
  14390. * Set a mat4 in the shader from a MAtrix.
  14391. * @param name Define the name of the uniform as defined in the shader
  14392. * @param value Define the value to give to the uniform
  14393. * @return the texture itself allowing "fluent" like uniform updates
  14394. */
  14395. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14396. /**
  14397. * Render the texture to its associated render target.
  14398. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14399. */
  14400. render(useCameraPostProcess?: boolean): void;
  14401. /**
  14402. * Clone the texture.
  14403. * @returns the cloned texture
  14404. */
  14405. clone(): ProceduralTexture;
  14406. /**
  14407. * Dispose the texture and release its asoociated resources.
  14408. */
  14409. dispose(): void;
  14410. }
  14411. }
  14412. declare module "babylonjs/Particles/baseParticleSystem" {
  14413. import { Nullable } from "babylonjs/types";
  14414. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14416. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14417. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14418. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14419. import { Scene } from "babylonjs/scene";
  14420. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14421. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14422. import { Texture } from "babylonjs/Materials/Textures/texture";
  14423. import { Animation } from "babylonjs/Animations/animation";
  14424. /**
  14425. * This represents the base class for particle system in Babylon.
  14426. * 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.
  14427. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14428. * @example https://doc.babylonjs.com/babylon101/particles
  14429. */
  14430. export class BaseParticleSystem {
  14431. /**
  14432. * Source color is added to the destination color without alpha affecting the result
  14433. */
  14434. static BLENDMODE_ONEONE: number;
  14435. /**
  14436. * Blend current color and particle color using particle’s alpha
  14437. */
  14438. static BLENDMODE_STANDARD: number;
  14439. /**
  14440. * Add current color and particle color multiplied by particle’s alpha
  14441. */
  14442. static BLENDMODE_ADD: number;
  14443. /**
  14444. * Multiply current color with particle color
  14445. */
  14446. static BLENDMODE_MULTIPLY: number;
  14447. /**
  14448. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14449. */
  14450. static BLENDMODE_MULTIPLYADD: number;
  14451. /**
  14452. * List of animations used by the particle system.
  14453. */
  14454. animations: Animation[];
  14455. /**
  14456. * The id of the Particle system.
  14457. */
  14458. id: string;
  14459. /**
  14460. * The friendly name of the Particle system.
  14461. */
  14462. name: string;
  14463. /**
  14464. * The rendering group used by the Particle system to chose when to render.
  14465. */
  14466. renderingGroupId: number;
  14467. /**
  14468. * The emitter represents the Mesh or position we are attaching the particle system to.
  14469. */
  14470. emitter: Nullable<AbstractMesh | Vector3>;
  14471. /**
  14472. * The maximum number of particles to emit per frame
  14473. */
  14474. emitRate: number;
  14475. /**
  14476. * If you want to launch only a few particles at once, that can be done, as well.
  14477. */
  14478. manualEmitCount: number;
  14479. /**
  14480. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14481. */
  14482. updateSpeed: number;
  14483. /**
  14484. * The amount of time the particle system is running (depends of the overall update speed).
  14485. */
  14486. targetStopDuration: number;
  14487. /**
  14488. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14489. */
  14490. disposeOnStop: boolean;
  14491. /**
  14492. * Minimum power of emitting particles.
  14493. */
  14494. minEmitPower: number;
  14495. /**
  14496. * Maximum power of emitting particles.
  14497. */
  14498. maxEmitPower: number;
  14499. /**
  14500. * Minimum life time of emitting particles.
  14501. */
  14502. minLifeTime: number;
  14503. /**
  14504. * Maximum life time of emitting particles.
  14505. */
  14506. maxLifeTime: number;
  14507. /**
  14508. * Minimum Size of emitting particles.
  14509. */
  14510. minSize: number;
  14511. /**
  14512. * Maximum Size of emitting particles.
  14513. */
  14514. maxSize: number;
  14515. /**
  14516. * Minimum scale of emitting particles on X axis.
  14517. */
  14518. minScaleX: number;
  14519. /**
  14520. * Maximum scale of emitting particles on X axis.
  14521. */
  14522. maxScaleX: number;
  14523. /**
  14524. * Minimum scale of emitting particles on Y axis.
  14525. */
  14526. minScaleY: number;
  14527. /**
  14528. * Maximum scale of emitting particles on Y axis.
  14529. */
  14530. maxScaleY: number;
  14531. /**
  14532. * Gets or sets the minimal initial rotation in radians.
  14533. */
  14534. minInitialRotation: number;
  14535. /**
  14536. * Gets or sets the maximal initial rotation in radians.
  14537. */
  14538. maxInitialRotation: number;
  14539. /**
  14540. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14541. */
  14542. minAngularSpeed: number;
  14543. /**
  14544. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14545. */
  14546. maxAngularSpeed: number;
  14547. /**
  14548. * The texture used to render each particle. (this can be a spritesheet)
  14549. */
  14550. particleTexture: Nullable<Texture>;
  14551. /**
  14552. * The layer mask we are rendering the particles through.
  14553. */
  14554. layerMask: number;
  14555. /**
  14556. * This can help using your own shader to render the particle system.
  14557. * The according effect will be created
  14558. */
  14559. customShader: any;
  14560. /**
  14561. * By default particle system starts as soon as they are created. This prevents the
  14562. * automatic start to happen and let you decide when to start emitting particles.
  14563. */
  14564. preventAutoStart: boolean;
  14565. private _noiseTexture;
  14566. /**
  14567. * Gets or sets a texture used to add random noise to particle positions
  14568. */
  14569. noiseTexture: Nullable<ProceduralTexture>;
  14570. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14571. noiseStrength: Vector3;
  14572. /**
  14573. * Callback triggered when the particle animation is ending.
  14574. */
  14575. onAnimationEnd: Nullable<() => void>;
  14576. /**
  14577. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14578. */
  14579. blendMode: number;
  14580. /**
  14581. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14582. * to override the particles.
  14583. */
  14584. forceDepthWrite: boolean;
  14585. /** 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 */
  14586. preWarmCycles: number;
  14587. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14588. preWarmStepOffset: number;
  14589. /**
  14590. * 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)
  14591. */
  14592. spriteCellChangeSpeed: number;
  14593. /**
  14594. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14595. */
  14596. startSpriteCellID: number;
  14597. /**
  14598. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14599. */
  14600. endSpriteCellID: number;
  14601. /**
  14602. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14603. */
  14604. spriteCellWidth: number;
  14605. /**
  14606. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14607. */
  14608. spriteCellHeight: number;
  14609. /**
  14610. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14611. */
  14612. spriteRandomStartCell: boolean;
  14613. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14614. translationPivot: Vector2;
  14615. /** @hidden */
  14616. protected _isAnimationSheetEnabled: boolean;
  14617. /**
  14618. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14619. */
  14620. beginAnimationOnStart: boolean;
  14621. /**
  14622. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14623. */
  14624. beginAnimationFrom: number;
  14625. /**
  14626. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14627. */
  14628. beginAnimationTo: number;
  14629. /**
  14630. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14631. */
  14632. beginAnimationLoop: boolean;
  14633. /**
  14634. * Gets or sets a world offset applied to all particles
  14635. */
  14636. worldOffset: Vector3;
  14637. /**
  14638. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14639. */
  14640. isAnimationSheetEnabled: boolean;
  14641. /**
  14642. * Get hosting scene
  14643. * @returns the scene
  14644. */
  14645. getScene(): Scene;
  14646. /**
  14647. * You can use gravity if you want to give an orientation to your particles.
  14648. */
  14649. gravity: Vector3;
  14650. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14651. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14652. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14653. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14654. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14655. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14656. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14657. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14658. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14659. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14660. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14661. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14662. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14663. /**
  14664. * Defines the delay in milliseconds before starting the system (0 by default)
  14665. */
  14666. startDelay: number;
  14667. /**
  14668. * Gets the current list of drag gradients.
  14669. * You must use addDragGradient and removeDragGradient to udpate this list
  14670. * @returns the list of drag gradients
  14671. */
  14672. getDragGradients(): Nullable<Array<FactorGradient>>;
  14673. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14674. limitVelocityDamping: number;
  14675. /**
  14676. * Gets the current list of limit velocity gradients.
  14677. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14678. * @returns the list of limit velocity gradients
  14679. */
  14680. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Gets the current list of color gradients.
  14683. * You must use addColorGradient and removeColorGradient to udpate this list
  14684. * @returns the list of color gradients
  14685. */
  14686. getColorGradients(): Nullable<Array<ColorGradient>>;
  14687. /**
  14688. * Gets the current list of size gradients.
  14689. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14690. * @returns the list of size gradients
  14691. */
  14692. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of color remap gradients.
  14695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14696. * @returns the list of color remap gradients
  14697. */
  14698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Gets the current list of alpha remap gradients.
  14701. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14702. * @returns the list of alpha remap gradients
  14703. */
  14704. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Gets the current list of life time gradients.
  14707. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14708. * @returns the list of life time gradients
  14709. */
  14710. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14711. /**
  14712. * Gets the current list of angular speed gradients.
  14713. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14714. * @returns the list of angular speed gradients
  14715. */
  14716. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Gets the current list of velocity gradients.
  14719. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14720. * @returns the list of velocity gradients
  14721. */
  14722. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14723. /**
  14724. * Gets the current list of start size gradients.
  14725. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14726. * @returns the list of start size gradients
  14727. */
  14728. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14729. /**
  14730. * Gets the current list of emit rate gradients.
  14731. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14732. * @returns the list of emit rate gradients
  14733. */
  14734. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14737. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14738. */
  14739. direction1: Vector3;
  14740. /**
  14741. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14742. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14743. */
  14744. direction2: Vector3;
  14745. /**
  14746. * 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.
  14747. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14748. */
  14749. minEmitBox: Vector3;
  14750. /**
  14751. * 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.
  14752. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14753. */
  14754. maxEmitBox: Vector3;
  14755. /**
  14756. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14757. */
  14758. color1: Color4;
  14759. /**
  14760. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14761. */
  14762. color2: Color4;
  14763. /**
  14764. * Color the particle will have at the end of its lifetime
  14765. */
  14766. colorDead: Color4;
  14767. /**
  14768. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14769. */
  14770. textureMask: Color4;
  14771. /**
  14772. * The particle emitter type defines the emitter used by the particle system.
  14773. * It can be for example box, sphere, or cone...
  14774. */
  14775. particleEmitterType: IParticleEmitterType;
  14776. /** @hidden */
  14777. _isSubEmitter: boolean;
  14778. /**
  14779. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14780. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14781. */
  14782. billboardMode: number;
  14783. protected _isBillboardBased: boolean;
  14784. /**
  14785. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14786. */
  14787. isBillboardBased: boolean;
  14788. /**
  14789. * The scene the particle system belongs to.
  14790. */
  14791. protected _scene: Scene;
  14792. /**
  14793. * Local cache of defines for image processing.
  14794. */
  14795. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14796. /**
  14797. * Default configuration related to image processing available in the standard Material.
  14798. */
  14799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14800. /**
  14801. * Gets the image processing configuration used either in this material.
  14802. */
  14803. /**
  14804. * Sets the Default image processing configuration used either in the this material.
  14805. *
  14806. * If sets to null, the scene one is in use.
  14807. */
  14808. imageProcessingConfiguration: ImageProcessingConfiguration;
  14809. /**
  14810. * Attaches a new image processing configuration to the Standard Material.
  14811. * @param configuration
  14812. */
  14813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14814. /** @hidden */
  14815. protected _reset(): void;
  14816. /** @hidden */
  14817. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14818. /**
  14819. * Instantiates a particle system.
  14820. * 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.
  14821. * @param name The name of the particle system
  14822. */
  14823. constructor(name: string);
  14824. /**
  14825. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14828. * @returns the emitter
  14829. */
  14830. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14831. /**
  14832. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14833. * @param radius The radius of the hemisphere to emit from
  14834. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14835. * @returns the emitter
  14836. */
  14837. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14838. /**
  14839. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14840. * @param radius The radius of the sphere to emit from
  14841. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14842. * @returns the emitter
  14843. */
  14844. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14845. /**
  14846. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14847. * @param radius The radius of the sphere to emit from
  14848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14850. * @returns the emitter
  14851. */
  14852. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14853. /**
  14854. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14855. * @param radius The radius of the emission cylinder
  14856. * @param height The height of the emission cylinder
  14857. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14858. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14859. * @returns the emitter
  14860. */
  14861. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14862. /**
  14863. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14864. * @param radius The radius of the cylinder to emit from
  14865. * @param height The height of the emission cylinder
  14866. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14867. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14868. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14869. * @returns the emitter
  14870. */
  14871. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14872. /**
  14873. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14874. * @param radius The radius of the cone to emit from
  14875. * @param angle The base angle of the cone
  14876. * @returns the emitter
  14877. */
  14878. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14879. /**
  14880. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14883. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14884. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14885. * @returns the emitter
  14886. */
  14887. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14888. }
  14889. }
  14890. declare module "babylonjs/Particles/subEmitter" {
  14891. import { Scene } from "babylonjs/scene";
  14892. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14893. /**
  14894. * Type of sub emitter
  14895. */
  14896. export enum SubEmitterType {
  14897. /**
  14898. * Attached to the particle over it's lifetime
  14899. */
  14900. ATTACHED = 0,
  14901. /**
  14902. * Created when the particle dies
  14903. */
  14904. END = 1
  14905. }
  14906. /**
  14907. * Sub emitter class used to emit particles from an existing particle
  14908. */
  14909. export class SubEmitter {
  14910. /**
  14911. * the particle system to be used by the sub emitter
  14912. */
  14913. particleSystem: ParticleSystem;
  14914. /**
  14915. * Type of the submitter (Default: END)
  14916. */
  14917. type: SubEmitterType;
  14918. /**
  14919. * 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)
  14920. * Note: This only is supported when using an emitter of type Mesh
  14921. */
  14922. inheritDirection: boolean;
  14923. /**
  14924. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14925. */
  14926. inheritedVelocityAmount: number;
  14927. /**
  14928. * Creates a sub emitter
  14929. * @param particleSystem the particle system to be used by the sub emitter
  14930. */
  14931. constructor(
  14932. /**
  14933. * the particle system to be used by the sub emitter
  14934. */
  14935. particleSystem: ParticleSystem);
  14936. /**
  14937. * Clones the sub emitter
  14938. * @returns the cloned sub emitter
  14939. */
  14940. clone(): SubEmitter;
  14941. /**
  14942. * Serialize current object to a JSON object
  14943. * @returns the serialized object
  14944. */
  14945. serialize(): any;
  14946. /** @hidden */
  14947. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14948. /**
  14949. * Creates a new SubEmitter from a serialized JSON version
  14950. * @param serializationObject defines the JSON object to read from
  14951. * @param scene defines the hosting scene
  14952. * @param rootUrl defines the rootUrl for data loading
  14953. * @returns a new SubEmitter
  14954. */
  14955. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14956. /** Release associated resources */
  14957. dispose(): void;
  14958. }
  14959. }
  14960. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14961. /** @hidden */
  14962. export var clipPlaneFragmentDeclaration: {
  14963. name: string;
  14964. shader: string;
  14965. };
  14966. }
  14967. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14968. /** @hidden */
  14969. export var imageProcessingDeclaration: {
  14970. name: string;
  14971. shader: string;
  14972. };
  14973. }
  14974. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14975. /** @hidden */
  14976. export var imageProcessingFunctions: {
  14977. name: string;
  14978. shader: string;
  14979. };
  14980. }
  14981. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14982. /** @hidden */
  14983. export var clipPlaneFragment: {
  14984. name: string;
  14985. shader: string;
  14986. };
  14987. }
  14988. declare module "babylonjs/Shaders/particles.fragment" {
  14989. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14992. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14994. /** @hidden */
  14995. export var particlesPixelShader: {
  14996. name: string;
  14997. shader: string;
  14998. };
  14999. }
  15000. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15001. /** @hidden */
  15002. export var clipPlaneVertexDeclaration: {
  15003. name: string;
  15004. shader: string;
  15005. };
  15006. }
  15007. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15008. /** @hidden */
  15009. export var clipPlaneVertex: {
  15010. name: string;
  15011. shader: string;
  15012. };
  15013. }
  15014. declare module "babylonjs/Shaders/particles.vertex" {
  15015. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15016. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15017. /** @hidden */
  15018. export var particlesVertexShader: {
  15019. name: string;
  15020. shader: string;
  15021. };
  15022. }
  15023. declare module "babylonjs/Particles/particleSystem" {
  15024. import { Nullable } from "babylonjs/types";
  15025. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15026. import { Observable } from "babylonjs/Misc/observable";
  15027. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15028. import { Effect } from "babylonjs/Materials/effect";
  15029. import { Scene, IDisposable } from "babylonjs/scene";
  15030. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15031. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15032. import { Particle } from "babylonjs/Particles/particle";
  15033. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15034. import "babylonjs/Shaders/particles.fragment";
  15035. import "babylonjs/Shaders/particles.vertex";
  15036. /**
  15037. * This represents a particle system in Babylon.
  15038. * 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.
  15039. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15040. * @example https://doc.babylonjs.com/babylon101/particles
  15041. */
  15042. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15043. /**
  15044. * Billboard mode will only apply to Y axis
  15045. */
  15046. static readonly BILLBOARDMODE_Y: number;
  15047. /**
  15048. * Billboard mode will apply to all axes
  15049. */
  15050. static readonly BILLBOARDMODE_ALL: number;
  15051. /**
  15052. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15053. */
  15054. static readonly BILLBOARDMODE_STRETCHED: number;
  15055. /**
  15056. * This function can be defined to provide custom update for active particles.
  15057. * This function will be called instead of regular update (age, position, color, etc.).
  15058. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15059. */
  15060. updateFunction: (particles: Particle[]) => void;
  15061. private _emitterWorldMatrix;
  15062. /**
  15063. * This function can be defined to specify initial direction for every new particle.
  15064. * It by default use the emitterType defined function
  15065. */
  15066. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15067. /**
  15068. * This function can be defined to specify initial position for every new particle.
  15069. * It by default use the emitterType defined function
  15070. */
  15071. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15072. /**
  15073. * @hidden
  15074. */
  15075. _inheritedVelocityOffset: Vector3;
  15076. /**
  15077. * An event triggered when the system is disposed
  15078. */
  15079. onDisposeObservable: Observable<ParticleSystem>;
  15080. private _onDisposeObserver;
  15081. /**
  15082. * Sets a callback that will be triggered when the system is disposed
  15083. */
  15084. onDispose: () => void;
  15085. private _particles;
  15086. private _epsilon;
  15087. private _capacity;
  15088. private _stockParticles;
  15089. private _newPartsExcess;
  15090. private _vertexData;
  15091. private _vertexBuffer;
  15092. private _vertexBuffers;
  15093. private _spriteBuffer;
  15094. private _indexBuffer;
  15095. private _effect;
  15096. private _customEffect;
  15097. private _cachedDefines;
  15098. private _scaledColorStep;
  15099. private _colorDiff;
  15100. private _scaledDirection;
  15101. private _scaledGravity;
  15102. private _currentRenderId;
  15103. private _alive;
  15104. private _useInstancing;
  15105. private _started;
  15106. private _stopped;
  15107. private _actualFrame;
  15108. private _scaledUpdateSpeed;
  15109. private _vertexBufferSize;
  15110. /** @hidden */
  15111. _currentEmitRateGradient: Nullable<FactorGradient>;
  15112. /** @hidden */
  15113. _currentEmitRate1: number;
  15114. /** @hidden */
  15115. _currentEmitRate2: number;
  15116. /** @hidden */
  15117. _currentStartSizeGradient: Nullable<FactorGradient>;
  15118. /** @hidden */
  15119. _currentStartSize1: number;
  15120. /** @hidden */
  15121. _currentStartSize2: number;
  15122. private readonly _rawTextureWidth;
  15123. private _rampGradientsTexture;
  15124. private _useRampGradients;
  15125. /** Gets or sets a boolean indicating that ramp gradients must be used
  15126. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15127. */
  15128. useRampGradients: boolean;
  15129. /**
  15130. * 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.
  15131. * 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: [])
  15132. */
  15133. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15134. private _subEmitters;
  15135. /**
  15136. * @hidden
  15137. * If the particle systems emitter should be disposed when the particle system is disposed
  15138. */
  15139. _disposeEmitterOnDispose: boolean;
  15140. /**
  15141. * The current active Sub-systems, this property is used by the root particle system only.
  15142. */
  15143. activeSubSystems: Array<ParticleSystem>;
  15144. private _rootParticleSystem;
  15145. /**
  15146. * Gets the current list of active particles
  15147. */
  15148. readonly particles: Particle[];
  15149. /**
  15150. * Returns the string "ParticleSystem"
  15151. * @returns a string containing the class name
  15152. */
  15153. getClassName(): string;
  15154. /**
  15155. * Instantiates a particle system.
  15156. * 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.
  15157. * @param name The name of the particle system
  15158. * @param capacity The max number of particles alive at the same time
  15159. * @param scene The scene the particle system belongs to
  15160. * @param customEffect a custom effect used to change the way particles are rendered by default
  15161. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15162. * @param epsilon Offset used to render the particles
  15163. */
  15164. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15165. private _addFactorGradient;
  15166. private _removeFactorGradient;
  15167. /**
  15168. * Adds a new life time gradient
  15169. * @param gradient defines the gradient to use (between 0 and 1)
  15170. * @param factor defines the life time factor to affect to the specified gradient
  15171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15172. * @returns the current particle system
  15173. */
  15174. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15175. /**
  15176. * Remove a specific life time gradient
  15177. * @param gradient defines the gradient to remove
  15178. * @returns the current particle system
  15179. */
  15180. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15181. /**
  15182. * Adds a new size gradient
  15183. * @param gradient defines the gradient to use (between 0 and 1)
  15184. * @param factor defines the size factor to affect to the specified gradient
  15185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15186. * @returns the current particle system
  15187. */
  15188. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15189. /**
  15190. * Remove a specific size gradient
  15191. * @param gradient defines the gradient to remove
  15192. * @returns the current particle system
  15193. */
  15194. removeSizeGradient(gradient: number): IParticleSystem;
  15195. /**
  15196. * Adds a new color remap gradient
  15197. * @param gradient defines the gradient to use (between 0 and 1)
  15198. * @param min defines the color remap minimal range
  15199. * @param max defines the color remap maximal range
  15200. * @returns the current particle system
  15201. */
  15202. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15203. /**
  15204. * Remove a specific color remap gradient
  15205. * @param gradient defines the gradient to remove
  15206. * @returns the current particle system
  15207. */
  15208. removeColorRemapGradient(gradient: number): IParticleSystem;
  15209. /**
  15210. * Adds a new alpha remap gradient
  15211. * @param gradient defines the gradient to use (between 0 and 1)
  15212. * @param min defines the alpha remap minimal range
  15213. * @param max defines the alpha remap maximal range
  15214. * @returns the current particle system
  15215. */
  15216. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15217. /**
  15218. * Remove a specific alpha remap gradient
  15219. * @param gradient defines the gradient to remove
  15220. * @returns the current particle system
  15221. */
  15222. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15223. /**
  15224. * Adds a new angular speed gradient
  15225. * @param gradient defines the gradient to use (between 0 and 1)
  15226. * @param factor defines the angular speed to affect to the specified gradient
  15227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15228. * @returns the current particle system
  15229. */
  15230. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15231. /**
  15232. * Remove a specific angular speed gradient
  15233. * @param gradient defines the gradient to remove
  15234. * @returns the current particle system
  15235. */
  15236. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15237. /**
  15238. * Adds a new velocity gradient
  15239. * @param gradient defines the gradient to use (between 0 and 1)
  15240. * @param factor defines the velocity to affect to the specified gradient
  15241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15242. * @returns the current particle system
  15243. */
  15244. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15245. /**
  15246. * Remove a specific velocity gradient
  15247. * @param gradient defines the gradient to remove
  15248. * @returns the current particle system
  15249. */
  15250. removeVelocityGradient(gradient: number): IParticleSystem;
  15251. /**
  15252. * Adds a new limit velocity gradient
  15253. * @param gradient defines the gradient to use (between 0 and 1)
  15254. * @param factor defines the limit velocity value to affect to the specified gradient
  15255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15256. * @returns the current particle system
  15257. */
  15258. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15259. /**
  15260. * Remove a specific limit velocity gradient
  15261. * @param gradient defines the gradient to remove
  15262. * @returns the current particle system
  15263. */
  15264. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15265. /**
  15266. * Adds a new drag gradient
  15267. * @param gradient defines the gradient to use (between 0 and 1)
  15268. * @param factor defines the drag value to affect to the specified gradient
  15269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15270. * @returns the current particle system
  15271. */
  15272. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15273. /**
  15274. * Remove a specific drag gradient
  15275. * @param gradient defines the gradient to remove
  15276. * @returns the current particle system
  15277. */
  15278. removeDragGradient(gradient: number): IParticleSystem;
  15279. /**
  15280. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15281. * @param gradient defines the gradient to use (between 0 and 1)
  15282. * @param factor defines the emit rate value to affect to the specified gradient
  15283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15284. * @returns the current particle system
  15285. */
  15286. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15287. /**
  15288. * Remove a specific emit rate gradient
  15289. * @param gradient defines the gradient to remove
  15290. * @returns the current particle system
  15291. */
  15292. removeEmitRateGradient(gradient: number): IParticleSystem;
  15293. /**
  15294. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15295. * @param gradient defines the gradient to use (between 0 and 1)
  15296. * @param factor defines the start size value to affect to the specified gradient
  15297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15298. * @returns the current particle system
  15299. */
  15300. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15301. /**
  15302. * Remove a specific start size gradient
  15303. * @param gradient defines the gradient to remove
  15304. * @returns the current particle system
  15305. */
  15306. removeStartSizeGradient(gradient: number): IParticleSystem;
  15307. private _createRampGradientTexture;
  15308. /**
  15309. * Gets the current list of ramp gradients.
  15310. * You must use addRampGradient and removeRampGradient to udpate this list
  15311. * @returns the list of ramp gradients
  15312. */
  15313. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15314. /**
  15315. * Adds a new ramp gradient used to remap particle colors
  15316. * @param gradient defines the gradient to use (between 0 and 1)
  15317. * @param color defines the color to affect to the specified gradient
  15318. * @returns the current particle system
  15319. */
  15320. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15321. /**
  15322. * Remove a specific ramp gradient
  15323. * @param gradient defines the gradient to remove
  15324. * @returns the current particle system
  15325. */
  15326. removeRampGradient(gradient: number): ParticleSystem;
  15327. /**
  15328. * Adds a new color gradient
  15329. * @param gradient defines the gradient to use (between 0 and 1)
  15330. * @param color1 defines the color to affect to the specified gradient
  15331. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15332. * @returns this particle system
  15333. */
  15334. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15335. /**
  15336. * Remove a specific color gradient
  15337. * @param gradient defines the gradient to remove
  15338. * @returns this particle system
  15339. */
  15340. removeColorGradient(gradient: number): IParticleSystem;
  15341. private _fetchR;
  15342. protected _reset(): void;
  15343. private _resetEffect;
  15344. private _createVertexBuffers;
  15345. private _createIndexBuffer;
  15346. /**
  15347. * Gets the maximum number of particles active at the same time.
  15348. * @returns The max number of active particles.
  15349. */
  15350. getCapacity(): number;
  15351. /**
  15352. * Gets whether there are still active particles in the system.
  15353. * @returns True if it is alive, otherwise false.
  15354. */
  15355. isAlive(): boolean;
  15356. /**
  15357. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15358. * @returns True if it has been started, otherwise false.
  15359. */
  15360. isStarted(): boolean;
  15361. private _prepareSubEmitterInternalArray;
  15362. /**
  15363. * Starts the particle system and begins to emit
  15364. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15365. */
  15366. start(delay?: number): void;
  15367. /**
  15368. * Stops the particle system.
  15369. * @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.
  15370. */
  15371. stop(stopSubEmitters?: boolean): void;
  15372. /**
  15373. * Remove all active particles
  15374. */
  15375. reset(): void;
  15376. /**
  15377. * @hidden (for internal use only)
  15378. */
  15379. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15380. /**
  15381. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15382. * Its lifetime will start back at 0.
  15383. */
  15384. recycleParticle: (particle: Particle) => void;
  15385. private _stopSubEmitters;
  15386. private _createParticle;
  15387. private _removeFromRoot;
  15388. private _emitFromParticle;
  15389. private _update;
  15390. /** @hidden */
  15391. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15392. /** @hidden */
  15393. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15394. /** @hidden */
  15395. private _getEffect;
  15396. /**
  15397. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15398. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15399. */
  15400. animate(preWarmOnly?: boolean): void;
  15401. private _appendParticleVertices;
  15402. /**
  15403. * Rebuilds the particle system.
  15404. */
  15405. rebuild(): void;
  15406. /**
  15407. * Is this system ready to be used/rendered
  15408. * @return true if the system is ready
  15409. */
  15410. isReady(): boolean;
  15411. private _render;
  15412. /**
  15413. * Renders the particle system in its current state.
  15414. * @returns the current number of particles
  15415. */
  15416. render(): number;
  15417. /**
  15418. * Disposes the particle system and free the associated resources
  15419. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15420. */
  15421. dispose(disposeTexture?: boolean): void;
  15422. /**
  15423. * Clones the particle system.
  15424. * @param name The name of the cloned object
  15425. * @param newEmitter The new emitter to use
  15426. * @returns the cloned particle system
  15427. */
  15428. clone(name: string, newEmitter: any): ParticleSystem;
  15429. /**
  15430. * Serializes the particle system to a JSON object.
  15431. * @returns the JSON object
  15432. */
  15433. serialize(): any;
  15434. /** @hidden */
  15435. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15436. /** @hidden */
  15437. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15438. /**
  15439. * Parses a JSON object to create a particle system.
  15440. * @param parsedParticleSystem The JSON object to parse
  15441. * @param scene The scene to create the particle system in
  15442. * @param rootUrl The root url to use to load external dependencies like texture
  15443. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15444. * @returns the Parsed particle system
  15445. */
  15446. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15447. }
  15448. }
  15449. declare module "babylonjs/Particles/particle" {
  15450. import { Nullable } from "babylonjs/types";
  15451. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15452. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15453. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15454. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15455. /**
  15456. * A particle represents one of the element emitted by a particle system.
  15457. * This is mainly define by its coordinates, direction, velocity and age.
  15458. */
  15459. export class Particle {
  15460. /**
  15461. * The particle system the particle belongs to.
  15462. */
  15463. particleSystem: ParticleSystem;
  15464. private static _Count;
  15465. /**
  15466. * Unique ID of the particle
  15467. */
  15468. id: number;
  15469. /**
  15470. * The world position of the particle in the scene.
  15471. */
  15472. position: Vector3;
  15473. /**
  15474. * The world direction of the particle in the scene.
  15475. */
  15476. direction: Vector3;
  15477. /**
  15478. * The color of the particle.
  15479. */
  15480. color: Color4;
  15481. /**
  15482. * The color change of the particle per step.
  15483. */
  15484. colorStep: Color4;
  15485. /**
  15486. * Defines how long will the life of the particle be.
  15487. */
  15488. lifeTime: number;
  15489. /**
  15490. * The current age of the particle.
  15491. */
  15492. age: number;
  15493. /**
  15494. * The current size of the particle.
  15495. */
  15496. size: number;
  15497. /**
  15498. * The current scale of the particle.
  15499. */
  15500. scale: Vector2;
  15501. /**
  15502. * The current angle of the particle.
  15503. */
  15504. angle: number;
  15505. /**
  15506. * Defines how fast is the angle changing.
  15507. */
  15508. angularSpeed: number;
  15509. /**
  15510. * Defines the cell index used by the particle to be rendered from a sprite.
  15511. */
  15512. cellIndex: number;
  15513. /**
  15514. * The information required to support color remapping
  15515. */
  15516. remapData: Vector4;
  15517. /** @hidden */
  15518. _randomCellOffset?: number;
  15519. /** @hidden */
  15520. _initialDirection: Nullable<Vector3>;
  15521. /** @hidden */
  15522. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15523. /** @hidden */
  15524. _initialStartSpriteCellID: number;
  15525. /** @hidden */
  15526. _initialEndSpriteCellID: number;
  15527. /** @hidden */
  15528. _currentColorGradient: Nullable<ColorGradient>;
  15529. /** @hidden */
  15530. _currentColor1: Color4;
  15531. /** @hidden */
  15532. _currentColor2: Color4;
  15533. /** @hidden */
  15534. _currentSizeGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentSize1: number;
  15537. /** @hidden */
  15538. _currentSize2: number;
  15539. /** @hidden */
  15540. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15541. /** @hidden */
  15542. _currentAngularSpeed1: number;
  15543. /** @hidden */
  15544. _currentAngularSpeed2: number;
  15545. /** @hidden */
  15546. _currentVelocityGradient: Nullable<FactorGradient>;
  15547. /** @hidden */
  15548. _currentVelocity1: number;
  15549. /** @hidden */
  15550. _currentVelocity2: number;
  15551. /** @hidden */
  15552. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15553. /** @hidden */
  15554. _currentLimitVelocity1: number;
  15555. /** @hidden */
  15556. _currentLimitVelocity2: number;
  15557. /** @hidden */
  15558. _currentDragGradient: Nullable<FactorGradient>;
  15559. /** @hidden */
  15560. _currentDrag1: number;
  15561. /** @hidden */
  15562. _currentDrag2: number;
  15563. /** @hidden */
  15564. _randomNoiseCoordinates1: Vector3;
  15565. /** @hidden */
  15566. _randomNoiseCoordinates2: Vector3;
  15567. /**
  15568. * Creates a new instance Particle
  15569. * @param particleSystem the particle system the particle belongs to
  15570. */
  15571. constructor(
  15572. /**
  15573. * The particle system the particle belongs to.
  15574. */
  15575. particleSystem: ParticleSystem);
  15576. private updateCellInfoFromSystem;
  15577. /**
  15578. * Defines how the sprite cell index is updated for the particle
  15579. */
  15580. updateCellIndex(): void;
  15581. /** @hidden */
  15582. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15583. /** @hidden */
  15584. _inheritParticleInfoToSubEmitters(): void;
  15585. /** @hidden */
  15586. _reset(): void;
  15587. /**
  15588. * Copy the properties of particle to another one.
  15589. * @param other the particle to copy the information to.
  15590. */
  15591. copyTo(other: Particle): void;
  15592. }
  15593. }
  15594. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15595. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15596. import { Effect } from "babylonjs/Materials/effect";
  15597. import { Particle } from "babylonjs/Particles/particle";
  15598. /**
  15599. * Particle emitter represents a volume emitting particles.
  15600. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15601. */
  15602. export interface IParticleEmitterType {
  15603. /**
  15604. * Called by the particle System when the direction is computed for the created particle.
  15605. * @param worldMatrix is the world matrix of the particle system
  15606. * @param directionToUpdate is the direction vector to update with the result
  15607. * @param particle is the particle we are computed the direction for
  15608. */
  15609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15610. /**
  15611. * Called by the particle System when the position is computed for the created particle.
  15612. * @param worldMatrix is the world matrix of the particle system
  15613. * @param positionToUpdate is the position vector to update with the result
  15614. * @param particle is the particle we are computed the position for
  15615. */
  15616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15617. /**
  15618. * Clones the current emitter and returns a copy of it
  15619. * @returns the new emitter
  15620. */
  15621. clone(): IParticleEmitterType;
  15622. /**
  15623. * Called by the GPUParticleSystem to setup the update shader
  15624. * @param effect defines the update shader
  15625. */
  15626. applyToShader(effect: Effect): void;
  15627. /**
  15628. * Returns a string to use to update the GPU particles update shader
  15629. * @returns the effect defines string
  15630. */
  15631. getEffectDefines(): string;
  15632. /**
  15633. * Returns a string representing the class name
  15634. * @returns a string containing the class name
  15635. */
  15636. getClassName(): string;
  15637. /**
  15638. * Serializes the particle system to a JSON object.
  15639. * @returns the JSON object
  15640. */
  15641. serialize(): any;
  15642. /**
  15643. * Parse properties from a JSON object
  15644. * @param serializationObject defines the JSON object
  15645. */
  15646. parse(serializationObject: any): void;
  15647. }
  15648. }
  15649. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15650. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15651. import { Effect } from "babylonjs/Materials/effect";
  15652. import { Particle } from "babylonjs/Particles/particle";
  15653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15654. /**
  15655. * Particle emitter emitting particles from the inside of a box.
  15656. * It emits the particles randomly between 2 given directions.
  15657. */
  15658. export class BoxParticleEmitter implements IParticleEmitterType {
  15659. /**
  15660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15661. */
  15662. direction1: Vector3;
  15663. /**
  15664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15665. */
  15666. direction2: Vector3;
  15667. /**
  15668. * 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.
  15669. */
  15670. minEmitBox: Vector3;
  15671. /**
  15672. * 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.
  15673. */
  15674. maxEmitBox: Vector3;
  15675. /**
  15676. * Creates a new instance BoxParticleEmitter
  15677. */
  15678. constructor();
  15679. /**
  15680. * Called by the particle System when the direction is computed for the created particle.
  15681. * @param worldMatrix is the world matrix of the particle system
  15682. * @param directionToUpdate is the direction vector to update with the result
  15683. * @param particle is the particle we are computed the direction for
  15684. */
  15685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15686. /**
  15687. * Called by the particle System when the position is computed for the created particle.
  15688. * @param worldMatrix is the world matrix of the particle system
  15689. * @param positionToUpdate is the position vector to update with the result
  15690. * @param particle is the particle we are computed the position for
  15691. */
  15692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15693. /**
  15694. * Clones the current emitter and returns a copy of it
  15695. * @returns the new emitter
  15696. */
  15697. clone(): BoxParticleEmitter;
  15698. /**
  15699. * Called by the GPUParticleSystem to setup the update shader
  15700. * @param effect defines the update shader
  15701. */
  15702. applyToShader(effect: Effect): void;
  15703. /**
  15704. * Returns a string to use to update the GPU particles update shader
  15705. * @returns a string containng the defines string
  15706. */
  15707. getEffectDefines(): string;
  15708. /**
  15709. * Returns the string "BoxParticleEmitter"
  15710. * @returns a string containing the class name
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Serializes the particle system to a JSON object.
  15715. * @returns the JSON object
  15716. */
  15717. serialize(): any;
  15718. /**
  15719. * Parse properties from a JSON object
  15720. * @param serializationObject defines the JSON object
  15721. */
  15722. parse(serializationObject: any): void;
  15723. }
  15724. }
  15725. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15726. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15727. import { Effect } from "babylonjs/Materials/effect";
  15728. import { Particle } from "babylonjs/Particles/particle";
  15729. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15730. /**
  15731. * Particle emitter emitting particles from the inside of a cone.
  15732. * It emits the particles alongside the cone volume from the base to the particle.
  15733. * The emission direction might be randomized.
  15734. */
  15735. export class ConeParticleEmitter implements IParticleEmitterType {
  15736. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15737. directionRandomizer: number;
  15738. private _radius;
  15739. private _angle;
  15740. private _height;
  15741. /**
  15742. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15743. */
  15744. radiusRange: number;
  15745. /**
  15746. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15747. */
  15748. heightRange: number;
  15749. /**
  15750. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15751. */
  15752. emitFromSpawnPointOnly: boolean;
  15753. /**
  15754. * Gets or sets the radius of the emission cone
  15755. */
  15756. radius: number;
  15757. /**
  15758. * Gets or sets the angle of the emission cone
  15759. */
  15760. angle: number;
  15761. private _buildHeight;
  15762. /**
  15763. * Creates a new instance ConeParticleEmitter
  15764. * @param radius the radius of the emission cone (1 by default)
  15765. * @param angle the cone base angle (PI by default)
  15766. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15767. */
  15768. constructor(radius?: number, angle?: number,
  15769. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15770. directionRandomizer?: number);
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. */
  15777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Called by the particle System when the position is computed for the created particle.
  15780. * @param worldMatrix is the world matrix of the particle system
  15781. * @param positionToUpdate is the position vector to update with the result
  15782. * @param particle is the particle we are computed the position for
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): ConeParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "ConeParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15818. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15819. import { Effect } from "babylonjs/Materials/effect";
  15820. import { Particle } from "babylonjs/Particles/particle";
  15821. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15822. /**
  15823. * Particle emitter emitting particles from the inside of a cylinder.
  15824. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15825. */
  15826. export class CylinderParticleEmitter implements IParticleEmitterType {
  15827. /**
  15828. * The radius of the emission cylinder.
  15829. */
  15830. radius: number;
  15831. /**
  15832. * The height of the emission cylinder.
  15833. */
  15834. height: number;
  15835. /**
  15836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15837. */
  15838. radiusRange: number;
  15839. /**
  15840. * How much to randomize the particle direction [0-1].
  15841. */
  15842. directionRandomizer: number;
  15843. /**
  15844. * Creates a new instance CylinderParticleEmitter
  15845. * @param radius the radius of the emission cylinder (1 by default)
  15846. * @param height the height of the emission cylinder (1 by default)
  15847. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15848. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15849. */
  15850. constructor(
  15851. /**
  15852. * The radius of the emission cylinder.
  15853. */
  15854. radius?: number,
  15855. /**
  15856. * The height of the emission cylinder.
  15857. */
  15858. height?: number,
  15859. /**
  15860. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15861. */
  15862. radiusRange?: number,
  15863. /**
  15864. * How much to randomize the particle direction [0-1].
  15865. */
  15866. directionRandomizer?: number);
  15867. /**
  15868. * Called by the particle System when the direction is computed for the created particle.
  15869. * @param worldMatrix is the world matrix of the particle system
  15870. * @param directionToUpdate is the direction vector to update with the result
  15871. * @param particle is the particle we are computed the direction for
  15872. */
  15873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15874. /**
  15875. * Called by the particle System when the position is computed for the created particle.
  15876. * @param worldMatrix is the world matrix of the particle system
  15877. * @param positionToUpdate is the position vector to update with the result
  15878. * @param particle is the particle we are computed the position for
  15879. */
  15880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15881. /**
  15882. * Clones the current emitter and returns a copy of it
  15883. * @returns the new emitter
  15884. */
  15885. clone(): CylinderParticleEmitter;
  15886. /**
  15887. * Called by the GPUParticleSystem to setup the update shader
  15888. * @param effect defines the update shader
  15889. */
  15890. applyToShader(effect: Effect): void;
  15891. /**
  15892. * Returns a string to use to update the GPU particles update shader
  15893. * @returns a string containng the defines string
  15894. */
  15895. getEffectDefines(): string;
  15896. /**
  15897. * Returns the string "CylinderParticleEmitter"
  15898. * @returns a string containing the class name
  15899. */
  15900. getClassName(): string;
  15901. /**
  15902. * Serializes the particle system to a JSON object.
  15903. * @returns the JSON object
  15904. */
  15905. serialize(): any;
  15906. /**
  15907. * Parse properties from a JSON object
  15908. * @param serializationObject defines the JSON object
  15909. */
  15910. parse(serializationObject: any): void;
  15911. }
  15912. /**
  15913. * Particle emitter emitting particles from the inside of a cylinder.
  15914. * It emits the particles randomly between two vectors.
  15915. */
  15916. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15917. /**
  15918. * The min limit of the emission direction.
  15919. */
  15920. direction1: Vector3;
  15921. /**
  15922. * The max limit of the emission direction.
  15923. */
  15924. direction2: Vector3;
  15925. /**
  15926. * Creates a new instance CylinderDirectedParticleEmitter
  15927. * @param radius the radius of the emission cylinder (1 by default)
  15928. * @param height the height of the emission cylinder (1 by default)
  15929. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15930. * @param direction1 the min limit of the emission direction (up vector by default)
  15931. * @param direction2 the max limit of the emission direction (up vector by default)
  15932. */
  15933. constructor(radius?: number, height?: number, radiusRange?: number,
  15934. /**
  15935. * The min limit of the emission direction.
  15936. */
  15937. direction1?: Vector3,
  15938. /**
  15939. * The max limit of the emission direction.
  15940. */
  15941. direction2?: Vector3);
  15942. /**
  15943. * Called by the particle System when the direction is computed for the created particle.
  15944. * @param worldMatrix is the world matrix of the particle system
  15945. * @param directionToUpdate is the direction vector to update with the result
  15946. * @param particle is the particle we are computed the direction for
  15947. */
  15948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15949. /**
  15950. * Clones the current emitter and returns a copy of it
  15951. * @returns the new emitter
  15952. */
  15953. clone(): CylinderDirectedParticleEmitter;
  15954. /**
  15955. * Called by the GPUParticleSystem to setup the update shader
  15956. * @param effect defines the update shader
  15957. */
  15958. applyToShader(effect: Effect): void;
  15959. /**
  15960. * Returns a string to use to update the GPU particles update shader
  15961. * @returns a string containng the defines string
  15962. */
  15963. getEffectDefines(): string;
  15964. /**
  15965. * Returns the string "CylinderDirectedParticleEmitter"
  15966. * @returns a string containing the class name
  15967. */
  15968. getClassName(): string;
  15969. /**
  15970. * Serializes the particle system to a JSON object.
  15971. * @returns the JSON object
  15972. */
  15973. serialize(): any;
  15974. /**
  15975. * Parse properties from a JSON object
  15976. * @param serializationObject defines the JSON object
  15977. */
  15978. parse(serializationObject: any): void;
  15979. }
  15980. }
  15981. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15982. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15983. import { Effect } from "babylonjs/Materials/effect";
  15984. import { Particle } from "babylonjs/Particles/particle";
  15985. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15986. /**
  15987. * Particle emitter emitting particles from the inside of a hemisphere.
  15988. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15989. */
  15990. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15991. /**
  15992. * The radius of the emission hemisphere.
  15993. */
  15994. radius: number;
  15995. /**
  15996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15997. */
  15998. radiusRange: number;
  15999. /**
  16000. * How much to randomize the particle direction [0-1].
  16001. */
  16002. directionRandomizer: number;
  16003. /**
  16004. * Creates a new instance HemisphericParticleEmitter
  16005. * @param radius the radius of the emission hemisphere (1 by default)
  16006. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16007. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16008. */
  16009. constructor(
  16010. /**
  16011. * The radius of the emission hemisphere.
  16012. */
  16013. radius?: number,
  16014. /**
  16015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16016. */
  16017. radiusRange?: number,
  16018. /**
  16019. * How much to randomize the particle direction [0-1].
  16020. */
  16021. directionRandomizer?: number);
  16022. /**
  16023. * Called by the particle System when the direction is computed for the created particle.
  16024. * @param worldMatrix is the world matrix of the particle system
  16025. * @param directionToUpdate is the direction vector to update with the result
  16026. * @param particle is the particle we are computed the direction for
  16027. */
  16028. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16029. /**
  16030. * Called by the particle System when the position is computed for the created particle.
  16031. * @param worldMatrix is the world matrix of the particle system
  16032. * @param positionToUpdate is the position vector to update with the result
  16033. * @param particle is the particle we are computed the position for
  16034. */
  16035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16036. /**
  16037. * Clones the current emitter and returns a copy of it
  16038. * @returns the new emitter
  16039. */
  16040. clone(): HemisphericParticleEmitter;
  16041. /**
  16042. * Called by the GPUParticleSystem to setup the update shader
  16043. * @param effect defines the update shader
  16044. */
  16045. applyToShader(effect: Effect): void;
  16046. /**
  16047. * Returns a string to use to update the GPU particles update shader
  16048. * @returns a string containng the defines string
  16049. */
  16050. getEffectDefines(): string;
  16051. /**
  16052. * Returns the string "HemisphericParticleEmitter"
  16053. * @returns a string containing the class name
  16054. */
  16055. getClassName(): string;
  16056. /**
  16057. * Serializes the particle system to a JSON object.
  16058. * @returns the JSON object
  16059. */
  16060. serialize(): any;
  16061. /**
  16062. * Parse properties from a JSON object
  16063. * @param serializationObject defines the JSON object
  16064. */
  16065. parse(serializationObject: any): void;
  16066. }
  16067. }
  16068. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16069. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16070. import { Effect } from "babylonjs/Materials/effect";
  16071. import { Particle } from "babylonjs/Particles/particle";
  16072. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16073. /**
  16074. * Particle emitter emitting particles from a point.
  16075. * It emits the particles randomly between 2 given directions.
  16076. */
  16077. export class PointParticleEmitter implements IParticleEmitterType {
  16078. /**
  16079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16080. */
  16081. direction1: Vector3;
  16082. /**
  16083. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16084. */
  16085. direction2: Vector3;
  16086. /**
  16087. * Creates a new instance PointParticleEmitter
  16088. */
  16089. constructor();
  16090. /**
  16091. * Called by the particle System when the direction is computed for the created particle.
  16092. * @param worldMatrix is the world matrix of the particle system
  16093. * @param directionToUpdate is the direction vector to update with the result
  16094. * @param particle is the particle we are computed the direction for
  16095. */
  16096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16097. /**
  16098. * Called by the particle System when the position is computed for the created particle.
  16099. * @param worldMatrix is the world matrix of the particle system
  16100. * @param positionToUpdate is the position vector to update with the result
  16101. * @param particle is the particle we are computed the position for
  16102. */
  16103. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16104. /**
  16105. * Clones the current emitter and returns a copy of it
  16106. * @returns the new emitter
  16107. */
  16108. clone(): PointParticleEmitter;
  16109. /**
  16110. * Called by the GPUParticleSystem to setup the update shader
  16111. * @param effect defines the update shader
  16112. */
  16113. applyToShader(effect: Effect): void;
  16114. /**
  16115. * Returns a string to use to update the GPU particles update shader
  16116. * @returns a string containng the defines string
  16117. */
  16118. getEffectDefines(): string;
  16119. /**
  16120. * Returns the string "PointParticleEmitter"
  16121. * @returns a string containing the class name
  16122. */
  16123. getClassName(): string;
  16124. /**
  16125. * Serializes the particle system to a JSON object.
  16126. * @returns the JSON object
  16127. */
  16128. serialize(): any;
  16129. /**
  16130. * Parse properties from a JSON object
  16131. * @param serializationObject defines the JSON object
  16132. */
  16133. parse(serializationObject: any): void;
  16134. }
  16135. }
  16136. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16137. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16138. import { Effect } from "babylonjs/Materials/effect";
  16139. import { Particle } from "babylonjs/Particles/particle";
  16140. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16141. /**
  16142. * Particle emitter emitting particles from the inside of a sphere.
  16143. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16144. */
  16145. export class SphereParticleEmitter implements IParticleEmitterType {
  16146. /**
  16147. * The radius of the emission sphere.
  16148. */
  16149. radius: number;
  16150. /**
  16151. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16152. */
  16153. radiusRange: number;
  16154. /**
  16155. * How much to randomize the particle direction [0-1].
  16156. */
  16157. directionRandomizer: number;
  16158. /**
  16159. * Creates a new instance SphereParticleEmitter
  16160. * @param radius the radius of the emission sphere (1 by default)
  16161. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16162. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16163. */
  16164. constructor(
  16165. /**
  16166. * The radius of the emission sphere.
  16167. */
  16168. radius?: number,
  16169. /**
  16170. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16171. */
  16172. radiusRange?: number,
  16173. /**
  16174. * How much to randomize the particle direction [0-1].
  16175. */
  16176. directionRandomizer?: number);
  16177. /**
  16178. * Called by the particle System when the direction is computed for the created particle.
  16179. * @param worldMatrix is the world matrix of the particle system
  16180. * @param directionToUpdate is the direction vector to update with the result
  16181. * @param particle is the particle we are computed the direction for
  16182. */
  16183. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16184. /**
  16185. * Called by the particle System when the position is computed for the created particle.
  16186. * @param worldMatrix is the world matrix of the particle system
  16187. * @param positionToUpdate is the position vector to update with the result
  16188. * @param particle is the particle we are computed the position for
  16189. */
  16190. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16191. /**
  16192. * Clones the current emitter and returns a copy of it
  16193. * @returns the new emitter
  16194. */
  16195. clone(): SphereParticleEmitter;
  16196. /**
  16197. * Called by the GPUParticleSystem to setup the update shader
  16198. * @param effect defines the update shader
  16199. */
  16200. applyToShader(effect: Effect): void;
  16201. /**
  16202. * Returns a string to use to update the GPU particles update shader
  16203. * @returns a string containng the defines string
  16204. */
  16205. getEffectDefines(): string;
  16206. /**
  16207. * Returns the string "SphereParticleEmitter"
  16208. * @returns a string containing the class name
  16209. */
  16210. getClassName(): string;
  16211. /**
  16212. * Serializes the particle system to a JSON object.
  16213. * @returns the JSON object
  16214. */
  16215. serialize(): any;
  16216. /**
  16217. * Parse properties from a JSON object
  16218. * @param serializationObject defines the JSON object
  16219. */
  16220. parse(serializationObject: any): void;
  16221. }
  16222. /**
  16223. * Particle emitter emitting particles from the inside of a sphere.
  16224. * It emits the particles randomly between two vectors.
  16225. */
  16226. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16227. /**
  16228. * The min limit of the emission direction.
  16229. */
  16230. direction1: Vector3;
  16231. /**
  16232. * The max limit of the emission direction.
  16233. */
  16234. direction2: Vector3;
  16235. /**
  16236. * Creates a new instance SphereDirectedParticleEmitter
  16237. * @param radius the radius of the emission sphere (1 by default)
  16238. * @param direction1 the min limit of the emission direction (up vector by default)
  16239. * @param direction2 the max limit of the emission direction (up vector by default)
  16240. */
  16241. constructor(radius?: number,
  16242. /**
  16243. * The min limit of the emission direction.
  16244. */
  16245. direction1?: Vector3,
  16246. /**
  16247. * The max limit of the emission direction.
  16248. */
  16249. direction2?: Vector3);
  16250. /**
  16251. * Called by the particle System when the direction is computed for the created particle.
  16252. * @param worldMatrix is the world matrix of the particle system
  16253. * @param directionToUpdate is the direction vector to update with the result
  16254. * @param particle is the particle we are computed the direction for
  16255. */
  16256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16257. /**
  16258. * Clones the current emitter and returns a copy of it
  16259. * @returns the new emitter
  16260. */
  16261. clone(): SphereDirectedParticleEmitter;
  16262. /**
  16263. * Called by the GPUParticleSystem to setup the update shader
  16264. * @param effect defines the update shader
  16265. */
  16266. applyToShader(effect: Effect): void;
  16267. /**
  16268. * Returns a string to use to update the GPU particles update shader
  16269. * @returns a string containng the defines string
  16270. */
  16271. getEffectDefines(): string;
  16272. /**
  16273. * Returns the string "SphereDirectedParticleEmitter"
  16274. * @returns a string containing the class name
  16275. */
  16276. getClassName(): string;
  16277. /**
  16278. * Serializes the particle system to a JSON object.
  16279. * @returns the JSON object
  16280. */
  16281. serialize(): any;
  16282. /**
  16283. * Parse properties from a JSON object
  16284. * @param serializationObject defines the JSON object
  16285. */
  16286. parse(serializationObject: any): void;
  16287. }
  16288. }
  16289. declare module "babylonjs/Particles/EmitterTypes/index" {
  16290. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16291. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16292. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16293. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16294. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16295. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16296. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16297. }
  16298. declare module "babylonjs/Particles/IParticleSystem" {
  16299. import { Nullable } from "babylonjs/types";
  16300. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16303. import { Texture } from "babylonjs/Materials/Textures/texture";
  16304. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16305. import { Scene } from "babylonjs/scene";
  16306. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16307. import { Animation } from "babylonjs/Animations/animation";
  16308. /**
  16309. * Interface representing a particle system in Babylon.js.
  16310. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16311. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16312. */
  16313. export interface IParticleSystem {
  16314. /**
  16315. * List of animations used by the particle system.
  16316. */
  16317. animations: Animation[];
  16318. /**
  16319. * The id of the Particle system.
  16320. */
  16321. id: string;
  16322. /**
  16323. * The name of the Particle system.
  16324. */
  16325. name: string;
  16326. /**
  16327. * The emitter represents the Mesh or position we are attaching the particle system to.
  16328. */
  16329. emitter: Nullable<AbstractMesh | Vector3>;
  16330. /**
  16331. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16332. */
  16333. isBillboardBased: boolean;
  16334. /**
  16335. * The rendering group used by the Particle system to chose when to render.
  16336. */
  16337. renderingGroupId: number;
  16338. /**
  16339. * The layer mask we are rendering the particles through.
  16340. */
  16341. layerMask: number;
  16342. /**
  16343. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16344. */
  16345. updateSpeed: number;
  16346. /**
  16347. * The amount of time the particle system is running (depends of the overall update speed).
  16348. */
  16349. targetStopDuration: number;
  16350. /**
  16351. * The texture used to render each particle. (this can be a spritesheet)
  16352. */
  16353. particleTexture: Nullable<Texture>;
  16354. /**
  16355. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16356. */
  16357. blendMode: number;
  16358. /**
  16359. * Minimum life time of emitting particles.
  16360. */
  16361. minLifeTime: number;
  16362. /**
  16363. * Maximum life time of emitting particles.
  16364. */
  16365. maxLifeTime: number;
  16366. /**
  16367. * Minimum Size of emitting particles.
  16368. */
  16369. minSize: number;
  16370. /**
  16371. * Maximum Size of emitting particles.
  16372. */
  16373. maxSize: number;
  16374. /**
  16375. * Minimum scale of emitting particles on X axis.
  16376. */
  16377. minScaleX: number;
  16378. /**
  16379. * Maximum scale of emitting particles on X axis.
  16380. */
  16381. maxScaleX: number;
  16382. /**
  16383. * Minimum scale of emitting particles on Y axis.
  16384. */
  16385. minScaleY: number;
  16386. /**
  16387. * Maximum scale of emitting particles on Y axis.
  16388. */
  16389. maxScaleY: number;
  16390. /**
  16391. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16392. */
  16393. color1: Color4;
  16394. /**
  16395. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16396. */
  16397. color2: Color4;
  16398. /**
  16399. * Color the particle will have at the end of its lifetime.
  16400. */
  16401. colorDead: Color4;
  16402. /**
  16403. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16404. */
  16405. emitRate: number;
  16406. /**
  16407. * You can use gravity if you want to give an orientation to your particles.
  16408. */
  16409. gravity: Vector3;
  16410. /**
  16411. * Minimum power of emitting particles.
  16412. */
  16413. minEmitPower: number;
  16414. /**
  16415. * Maximum power of emitting particles.
  16416. */
  16417. maxEmitPower: number;
  16418. /**
  16419. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16420. */
  16421. minAngularSpeed: number;
  16422. /**
  16423. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16424. */
  16425. maxAngularSpeed: number;
  16426. /**
  16427. * Gets or sets the minimal initial rotation in radians.
  16428. */
  16429. minInitialRotation: number;
  16430. /**
  16431. * Gets or sets the maximal initial rotation in radians.
  16432. */
  16433. maxInitialRotation: number;
  16434. /**
  16435. * The particle emitter type defines the emitter used by the particle system.
  16436. * It can be for example box, sphere, or cone...
  16437. */
  16438. particleEmitterType: Nullable<IParticleEmitterType>;
  16439. /**
  16440. * Defines the delay in milliseconds before starting the system (0 by default)
  16441. */
  16442. startDelay: number;
  16443. /**
  16444. * 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
  16445. */
  16446. preWarmCycles: number;
  16447. /**
  16448. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16449. */
  16450. preWarmStepOffset: number;
  16451. /**
  16452. * 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)
  16453. */
  16454. spriteCellChangeSpeed: number;
  16455. /**
  16456. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16457. */
  16458. startSpriteCellID: number;
  16459. /**
  16460. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16461. */
  16462. endSpriteCellID: number;
  16463. /**
  16464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16465. */
  16466. spriteCellWidth: number;
  16467. /**
  16468. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16469. */
  16470. spriteCellHeight: number;
  16471. /**
  16472. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16473. */
  16474. spriteRandomStartCell: boolean;
  16475. /**
  16476. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16477. */
  16478. isAnimationSheetEnabled: boolean;
  16479. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16480. translationPivot: Vector2;
  16481. /**
  16482. * Gets or sets a texture used to add random noise to particle positions
  16483. */
  16484. noiseTexture: Nullable<BaseTexture>;
  16485. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16486. noiseStrength: Vector3;
  16487. /**
  16488. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16489. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16490. */
  16491. billboardMode: number;
  16492. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16493. limitVelocityDamping: number;
  16494. /**
  16495. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16496. */
  16497. beginAnimationOnStart: boolean;
  16498. /**
  16499. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16500. */
  16501. beginAnimationFrom: number;
  16502. /**
  16503. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16504. */
  16505. beginAnimationTo: number;
  16506. /**
  16507. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16508. */
  16509. beginAnimationLoop: boolean;
  16510. /**
  16511. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16512. */
  16513. disposeOnStop: boolean;
  16514. /**
  16515. * Gets the maximum number of particles active at the same time.
  16516. * @returns The max number of active particles.
  16517. */
  16518. getCapacity(): number;
  16519. /**
  16520. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16521. * @returns True if it has been started, otherwise false.
  16522. */
  16523. isStarted(): boolean;
  16524. /**
  16525. * Animates the particle system for this frame.
  16526. */
  16527. animate(): void;
  16528. /**
  16529. * Renders the particle system in its current state.
  16530. * @returns the current number of particles
  16531. */
  16532. render(): number;
  16533. /**
  16534. * Dispose the particle system and frees its associated resources.
  16535. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16536. */
  16537. dispose(disposeTexture?: boolean): void;
  16538. /**
  16539. * Clones the particle system.
  16540. * @param name The name of the cloned object
  16541. * @param newEmitter The new emitter to use
  16542. * @returns the cloned particle system
  16543. */
  16544. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16545. /**
  16546. * Serializes the particle system to a JSON object.
  16547. * @returns the JSON object
  16548. */
  16549. serialize(): any;
  16550. /**
  16551. * Rebuild the particle system
  16552. */
  16553. rebuild(): void;
  16554. /**
  16555. * Starts the particle system and begins to emit
  16556. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16557. */
  16558. start(delay?: number): void;
  16559. /**
  16560. * Stops the particle system.
  16561. */
  16562. stop(): void;
  16563. /**
  16564. * Remove all active particles
  16565. */
  16566. reset(): void;
  16567. /**
  16568. * Is this system ready to be used/rendered
  16569. * @return true if the system is ready
  16570. */
  16571. isReady(): boolean;
  16572. /**
  16573. * Adds a new color gradient
  16574. * @param gradient defines the gradient to use (between 0 and 1)
  16575. * @param color1 defines the color to affect to the specified gradient
  16576. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16577. * @returns the current particle system
  16578. */
  16579. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16580. /**
  16581. * Remove a specific color gradient
  16582. * @param gradient defines the gradient to remove
  16583. * @returns the current particle system
  16584. */
  16585. removeColorGradient(gradient: number): IParticleSystem;
  16586. /**
  16587. * Adds a new size gradient
  16588. * @param gradient defines the gradient to use (between 0 and 1)
  16589. * @param factor defines the size factor to affect to the specified gradient
  16590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16591. * @returns the current particle system
  16592. */
  16593. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16594. /**
  16595. * Remove a specific size gradient
  16596. * @param gradient defines the gradient to remove
  16597. * @returns the current particle system
  16598. */
  16599. removeSizeGradient(gradient: number): IParticleSystem;
  16600. /**
  16601. * Gets the current list of color gradients.
  16602. * You must use addColorGradient and removeColorGradient to udpate this list
  16603. * @returns the list of color gradients
  16604. */
  16605. getColorGradients(): Nullable<Array<ColorGradient>>;
  16606. /**
  16607. * Gets the current list of size gradients.
  16608. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16609. * @returns the list of size gradients
  16610. */
  16611. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Gets the current list of angular speed gradients.
  16614. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16615. * @returns the list of angular speed gradients
  16616. */
  16617. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16618. /**
  16619. * Adds a new angular speed gradient
  16620. * @param gradient defines the gradient to use (between 0 and 1)
  16621. * @param factor defines the angular speed to affect to the specified gradient
  16622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16623. * @returns the current particle system
  16624. */
  16625. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16626. /**
  16627. * Remove a specific angular speed gradient
  16628. * @param gradient defines the gradient to remove
  16629. * @returns the current particle system
  16630. */
  16631. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16632. /**
  16633. * Gets the current list of velocity gradients.
  16634. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16635. * @returns the list of velocity gradients
  16636. */
  16637. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16638. /**
  16639. * Adds a new velocity gradient
  16640. * @param gradient defines the gradient to use (between 0 and 1)
  16641. * @param factor defines the velocity to affect to the specified gradient
  16642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16643. * @returns the current particle system
  16644. */
  16645. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16646. /**
  16647. * Remove a specific velocity gradient
  16648. * @param gradient defines the gradient to remove
  16649. * @returns the current particle system
  16650. */
  16651. removeVelocityGradient(gradient: number): IParticleSystem;
  16652. /**
  16653. * Gets the current list of limit velocity gradients.
  16654. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16655. * @returns the list of limit velocity gradients
  16656. */
  16657. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16658. /**
  16659. * Adds a new limit velocity gradient
  16660. * @param gradient defines the gradient to use (between 0 and 1)
  16661. * @param factor defines the limit velocity to affect to the specified gradient
  16662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16663. * @returns the current particle system
  16664. */
  16665. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16666. /**
  16667. * Remove a specific limit velocity gradient
  16668. * @param gradient defines the gradient to remove
  16669. * @returns the current particle system
  16670. */
  16671. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16672. /**
  16673. * Adds a new drag gradient
  16674. * @param gradient defines the gradient to use (between 0 and 1)
  16675. * @param factor defines the drag to affect to the specified gradient
  16676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16677. * @returns the current particle system
  16678. */
  16679. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16680. /**
  16681. * Remove a specific drag gradient
  16682. * @param gradient defines the gradient to remove
  16683. * @returns the current particle system
  16684. */
  16685. removeDragGradient(gradient: number): IParticleSystem;
  16686. /**
  16687. * Gets the current list of drag gradients.
  16688. * You must use addDragGradient and removeDragGradient to udpate this list
  16689. * @returns the list of drag gradients
  16690. */
  16691. getDragGradients(): Nullable<Array<FactorGradient>>;
  16692. /**
  16693. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16694. * @param gradient defines the gradient to use (between 0 and 1)
  16695. * @param factor defines the emit rate to affect to the specified gradient
  16696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16697. * @returns the current particle system
  16698. */
  16699. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16700. /**
  16701. * Remove a specific emit rate gradient
  16702. * @param gradient defines the gradient to remove
  16703. * @returns the current particle system
  16704. */
  16705. removeEmitRateGradient(gradient: number): IParticleSystem;
  16706. /**
  16707. * Gets the current list of emit rate gradients.
  16708. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16709. * @returns the list of emit rate gradients
  16710. */
  16711. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16712. /**
  16713. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16714. * @param gradient defines the gradient to use (between 0 and 1)
  16715. * @param factor defines the start size to affect to the specified gradient
  16716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16717. * @returns the current particle system
  16718. */
  16719. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16720. /**
  16721. * Remove a specific start size gradient
  16722. * @param gradient defines the gradient to remove
  16723. * @returns the current particle system
  16724. */
  16725. removeStartSizeGradient(gradient: number): IParticleSystem;
  16726. /**
  16727. * Gets the current list of start size gradients.
  16728. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16729. * @returns the list of start size gradients
  16730. */
  16731. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16732. /**
  16733. * Adds a new life time gradient
  16734. * @param gradient defines the gradient to use (between 0 and 1)
  16735. * @param factor defines the life time factor to affect to the specified gradient
  16736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16737. * @returns the current particle system
  16738. */
  16739. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16740. /**
  16741. * Remove a specific life time gradient
  16742. * @param gradient defines the gradient to remove
  16743. * @returns the current particle system
  16744. */
  16745. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16746. /**
  16747. * Gets the current list of life time gradients.
  16748. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16749. * @returns the list of life time gradients
  16750. */
  16751. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16752. /**
  16753. * Gets the current list of color gradients.
  16754. * You must use addColorGradient and removeColorGradient to udpate this list
  16755. * @returns the list of color gradients
  16756. */
  16757. getColorGradients(): Nullable<Array<ColorGradient>>;
  16758. /**
  16759. * Adds a new ramp gradient used to remap particle colors
  16760. * @param gradient defines the gradient to use (between 0 and 1)
  16761. * @param color defines the color to affect to the specified gradient
  16762. * @returns the current particle system
  16763. */
  16764. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16765. /**
  16766. * Gets the current list of ramp gradients.
  16767. * You must use addRampGradient and removeRampGradient to udpate this list
  16768. * @returns the list of ramp gradients
  16769. */
  16770. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16771. /** Gets or sets a boolean indicating that ramp gradients must be used
  16772. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16773. */
  16774. useRampGradients: boolean;
  16775. /**
  16776. * Adds a new color remap gradient
  16777. * @param gradient defines the gradient to use (between 0 and 1)
  16778. * @param min defines the color remap minimal range
  16779. * @param max defines the color remap maximal range
  16780. * @returns the current particle system
  16781. */
  16782. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16783. /**
  16784. * Gets the current list of color remap gradients.
  16785. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16786. * @returns the list of color remap gradients
  16787. */
  16788. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16789. /**
  16790. * Adds a new alpha remap gradient
  16791. * @param gradient defines the gradient to use (between 0 and 1)
  16792. * @param min defines the alpha remap minimal range
  16793. * @param max defines the alpha remap maximal range
  16794. * @returns the current particle system
  16795. */
  16796. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16797. /**
  16798. * Gets the current list of alpha remap gradients.
  16799. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16800. * @returns the list of alpha remap gradients
  16801. */
  16802. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16803. /**
  16804. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16807. * @returns the emitter
  16808. */
  16809. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16810. /**
  16811. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16812. * @param radius The radius of the hemisphere to emit from
  16813. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16814. * @returns the emitter
  16815. */
  16816. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16817. /**
  16818. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16819. * @param radius The radius of the sphere to emit from
  16820. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16821. * @returns the emitter
  16822. */
  16823. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16824. /**
  16825. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16826. * @param radius The radius of the sphere to emit from
  16827. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16828. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16829. * @returns the emitter
  16830. */
  16831. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16832. /**
  16833. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16834. * @param radius The radius of the emission cylinder
  16835. * @param height The height of the emission cylinder
  16836. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16837. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16838. * @returns the emitter
  16839. */
  16840. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16841. /**
  16842. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16843. * @param radius The radius of the cylinder to emit from
  16844. * @param height The height of the emission cylinder
  16845. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16846. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16847. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16848. * @returns the emitter
  16849. */
  16850. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16851. /**
  16852. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16853. * @param radius The radius of the cone to emit from
  16854. * @param angle The base angle of the cone
  16855. * @returns the emitter
  16856. */
  16857. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16858. /**
  16859. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16862. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16863. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16864. * @returns the emitter
  16865. */
  16866. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16867. /**
  16868. * Get hosting scene
  16869. * @returns the scene
  16870. */
  16871. getScene(): Scene;
  16872. }
  16873. }
  16874. declare module "babylonjs/Meshes/instancedMesh" {
  16875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16876. import { Vector3 } from "babylonjs/Maths/math";
  16877. import { Camera } from "babylonjs/Cameras/camera";
  16878. import { Node } from "babylonjs/node";
  16879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16880. import { Mesh } from "babylonjs/Meshes/mesh";
  16881. import { Material } from "babylonjs/Materials/material";
  16882. import { Skeleton } from "babylonjs/Bones/skeleton";
  16883. /**
  16884. * Creates an instance based on a source mesh.
  16885. */
  16886. export class InstancedMesh extends AbstractMesh {
  16887. private _sourceMesh;
  16888. private _currentLOD;
  16889. /** @hidden */
  16890. _indexInSourceMeshInstanceArray: number;
  16891. constructor(name: string, source: Mesh);
  16892. /**
  16893. * Returns the string "InstancedMesh".
  16894. */
  16895. getClassName(): string;
  16896. /**
  16897. * If the source mesh receives shadows
  16898. */
  16899. readonly receiveShadows: boolean;
  16900. /**
  16901. * The material of the source mesh
  16902. */
  16903. readonly material: Nullable<Material>;
  16904. /**
  16905. * Visibility of the source mesh
  16906. */
  16907. readonly visibility: number;
  16908. /**
  16909. * Skeleton of the source mesh
  16910. */
  16911. readonly skeleton: Nullable<Skeleton>;
  16912. /**
  16913. * Rendering ground id of the source mesh
  16914. */
  16915. renderingGroupId: number;
  16916. /**
  16917. * Returns the total number of vertices (integer).
  16918. */
  16919. getTotalVertices(): number;
  16920. /**
  16921. * Returns a positive integer : the total number of indices in this mesh geometry.
  16922. * @returns the numner of indices or zero if the mesh has no geometry.
  16923. */
  16924. getTotalIndices(): number;
  16925. /**
  16926. * The source mesh of the instance
  16927. */
  16928. readonly sourceMesh: Mesh;
  16929. /**
  16930. * Is this node ready to be used/rendered
  16931. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16932. * @return {boolean} is it ready
  16933. */
  16934. isReady(completeCheck?: boolean): boolean;
  16935. /**
  16936. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16937. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16938. * @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.
  16939. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16940. */
  16941. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16942. /**
  16943. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16944. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16945. * The `data` are either a numeric array either a Float32Array.
  16946. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16947. * 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).
  16948. * Note that a new underlying VertexBuffer object is created each call.
  16949. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16950. *
  16951. * Possible `kind` values :
  16952. * - VertexBuffer.PositionKind
  16953. * - VertexBuffer.UVKind
  16954. * - VertexBuffer.UV2Kind
  16955. * - VertexBuffer.UV3Kind
  16956. * - VertexBuffer.UV4Kind
  16957. * - VertexBuffer.UV5Kind
  16958. * - VertexBuffer.UV6Kind
  16959. * - VertexBuffer.ColorKind
  16960. * - VertexBuffer.MatricesIndicesKind
  16961. * - VertexBuffer.MatricesIndicesExtraKind
  16962. * - VertexBuffer.MatricesWeightsKind
  16963. * - VertexBuffer.MatricesWeightsExtraKind
  16964. *
  16965. * Returns the Mesh.
  16966. */
  16967. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16968. /**
  16969. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16970. * If the mesh has no geometry, it is simply returned as it is.
  16971. * The `data` are either a numeric array either a Float32Array.
  16972. * No new underlying VertexBuffer object is created.
  16973. * 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.
  16974. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16975. *
  16976. * Possible `kind` values :
  16977. * - VertexBuffer.PositionKind
  16978. * - VertexBuffer.UVKind
  16979. * - VertexBuffer.UV2Kind
  16980. * - VertexBuffer.UV3Kind
  16981. * - VertexBuffer.UV4Kind
  16982. * - VertexBuffer.UV5Kind
  16983. * - VertexBuffer.UV6Kind
  16984. * - VertexBuffer.ColorKind
  16985. * - VertexBuffer.MatricesIndicesKind
  16986. * - VertexBuffer.MatricesIndicesExtraKind
  16987. * - VertexBuffer.MatricesWeightsKind
  16988. * - VertexBuffer.MatricesWeightsExtraKind
  16989. *
  16990. * Returns the Mesh.
  16991. */
  16992. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16993. /**
  16994. * Sets the mesh indices.
  16995. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16996. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16997. * This method creates a new index buffer each call.
  16998. * Returns the Mesh.
  16999. */
  17000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17001. /**
  17002. * Boolean : True if the mesh owns the requested kind of data.
  17003. */
  17004. isVerticesDataPresent(kind: string): boolean;
  17005. /**
  17006. * Returns an array of indices (IndicesArray).
  17007. */
  17008. getIndices(): Nullable<IndicesArray>;
  17009. readonly _positions: Nullable<Vector3[]>;
  17010. /**
  17011. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17012. * This means the mesh underlying bounding box and sphere are recomputed.
  17013. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17014. * @returns the current mesh
  17015. */
  17016. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17017. /** @hidden */
  17018. _preActivate(): InstancedMesh;
  17019. /** @hidden */
  17020. _activate(renderId: number): InstancedMesh;
  17021. /**
  17022. * Returns the current associated LOD AbstractMesh.
  17023. */
  17024. getLOD(camera: Camera): AbstractMesh;
  17025. /** @hidden */
  17026. _syncSubMeshes(): InstancedMesh;
  17027. /** @hidden */
  17028. _generatePointsArray(): boolean;
  17029. /**
  17030. * Creates a new InstancedMesh from the current mesh.
  17031. * - name (string) : the cloned mesh name
  17032. * - newParent (optional Node) : the optional Node to parent the clone to.
  17033. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17034. *
  17035. * Returns the clone.
  17036. */
  17037. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17038. /**
  17039. * Disposes the InstancedMesh.
  17040. * Returns nothing.
  17041. */
  17042. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17043. }
  17044. }
  17045. declare module "babylonjs/Materials/shaderMaterial" {
  17046. import { Scene } from "babylonjs/scene";
  17047. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17049. import { Mesh } from "babylonjs/Meshes/mesh";
  17050. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17051. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17052. import { Texture } from "babylonjs/Materials/Textures/texture";
  17053. import { Material } from "babylonjs/Materials/material";
  17054. /**
  17055. * Defines the options associated with the creation of a shader material.
  17056. */
  17057. export interface IShaderMaterialOptions {
  17058. /**
  17059. * Does the material work in alpha blend mode
  17060. */
  17061. needAlphaBlending: boolean;
  17062. /**
  17063. * Does the material work in alpha test mode
  17064. */
  17065. needAlphaTesting: boolean;
  17066. /**
  17067. * The list of attribute names used in the shader
  17068. */
  17069. attributes: string[];
  17070. /**
  17071. * The list of unifrom names used in the shader
  17072. */
  17073. uniforms: string[];
  17074. /**
  17075. * The list of UBO names used in the shader
  17076. */
  17077. uniformBuffers: string[];
  17078. /**
  17079. * The list of sampler names used in the shader
  17080. */
  17081. samplers: string[];
  17082. /**
  17083. * The list of defines used in the shader
  17084. */
  17085. defines: string[];
  17086. }
  17087. /**
  17088. * 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.
  17089. *
  17090. * This returned material effects how the mesh will look based on the code in the shaders.
  17091. *
  17092. * @see http://doc.babylonjs.com/how_to/shader_material
  17093. */
  17094. export class ShaderMaterial extends Material {
  17095. private _shaderPath;
  17096. private _options;
  17097. private _textures;
  17098. private _textureArrays;
  17099. private _floats;
  17100. private _ints;
  17101. private _floatsArrays;
  17102. private _colors3;
  17103. private _colors3Arrays;
  17104. private _colors4;
  17105. private _vectors2;
  17106. private _vectors3;
  17107. private _vectors4;
  17108. private _matrices;
  17109. private _matrices3x3;
  17110. private _matrices2x2;
  17111. private _vectors2Arrays;
  17112. private _vectors3Arrays;
  17113. private _cachedWorldViewMatrix;
  17114. private _renderId;
  17115. /**
  17116. * Instantiate a new shader material.
  17117. * 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.
  17118. * This returned material effects how the mesh will look based on the code in the shaders.
  17119. * @see http://doc.babylonjs.com/how_to/shader_material
  17120. * @param name Define the name of the material in the scene
  17121. * @param scene Define the scene the material belongs to
  17122. * @param shaderPath Defines the route to the shader code in one of three ways:
  17123. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17124. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17125. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17126. * @param options Define the options used to create the shader
  17127. */
  17128. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17129. /**
  17130. * Gets the options used to compile the shader.
  17131. * They can be modified to trigger a new compilation
  17132. */
  17133. readonly options: IShaderMaterialOptions;
  17134. /**
  17135. * Gets the current class name of the material e.g. "ShaderMaterial"
  17136. * Mainly use in serialization.
  17137. * @returns the class name
  17138. */
  17139. getClassName(): string;
  17140. /**
  17141. * Specifies if the material will require alpha blending
  17142. * @returns a boolean specifying if alpha blending is needed
  17143. */
  17144. needAlphaBlending(): boolean;
  17145. /**
  17146. * Specifies if this material should be rendered in alpha test mode
  17147. * @returns a boolean specifying if an alpha test is needed.
  17148. */
  17149. needAlphaTesting(): boolean;
  17150. private _checkUniform;
  17151. /**
  17152. * Set a texture in the shader.
  17153. * @param name Define the name of the uniform samplers as defined in the shader
  17154. * @param texture Define the texture to bind to this sampler
  17155. * @return the material itself allowing "fluent" like uniform updates
  17156. */
  17157. setTexture(name: string, texture: Texture): ShaderMaterial;
  17158. /**
  17159. * Set a texture array in the shader.
  17160. * @param name Define the name of the uniform sampler array as defined in the shader
  17161. * @param textures Define the list of textures to bind to this sampler
  17162. * @return the material itself allowing "fluent" like uniform updates
  17163. */
  17164. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17165. /**
  17166. * Set a float in the shader.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the material itself allowing "fluent" like uniform updates
  17170. */
  17171. setFloat(name: string, value: number): ShaderMaterial;
  17172. /**
  17173. * Set a int in the shader.
  17174. * @param name Define the name of the uniform as defined in the shader
  17175. * @param value Define the value to give to the uniform
  17176. * @return the material itself allowing "fluent" like uniform updates
  17177. */
  17178. setInt(name: string, value: number): ShaderMaterial;
  17179. /**
  17180. * Set an array of floats in the shader.
  17181. * @param name Define the name of the uniform as defined in the shader
  17182. * @param value Define the value to give to the uniform
  17183. * @return the material itself allowing "fluent" like uniform updates
  17184. */
  17185. setFloats(name: string, value: number[]): ShaderMaterial;
  17186. /**
  17187. * Set a vec3 in the shader from a Color3.
  17188. * @param name Define the name of the uniform as defined in the shader
  17189. * @param value Define the value to give to the uniform
  17190. * @return the material itself allowing "fluent" like uniform updates
  17191. */
  17192. setColor3(name: string, value: Color3): ShaderMaterial;
  17193. /**
  17194. * Set a vec3 array in the shader from a Color3 array.
  17195. * @param name Define the name of the uniform as defined in the shader
  17196. * @param value Define the value to give to the uniform
  17197. * @return the material itself allowing "fluent" like uniform updates
  17198. */
  17199. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17200. /**
  17201. * Set a vec4 in the shader from a Color4.
  17202. * @param name Define the name of the uniform as defined in the shader
  17203. * @param value Define the value to give to the uniform
  17204. * @return the material itself allowing "fluent" like uniform updates
  17205. */
  17206. setColor4(name: string, value: Color4): ShaderMaterial;
  17207. /**
  17208. * Set a vec2 in the shader from a Vector2.
  17209. * @param name Define the name of the uniform as defined in the shader
  17210. * @param value Define the value to give to the uniform
  17211. * @return the material itself allowing "fluent" like uniform updates
  17212. */
  17213. setVector2(name: string, value: Vector2): ShaderMaterial;
  17214. /**
  17215. * Set a vec3 in the shader from a Vector3.
  17216. * @param name Define the name of the uniform as defined in the shader
  17217. * @param value Define the value to give to the uniform
  17218. * @return the material itself allowing "fluent" like uniform updates
  17219. */
  17220. setVector3(name: string, value: Vector3): ShaderMaterial;
  17221. /**
  17222. * Set a vec4 in the shader from a Vector4.
  17223. * @param name Define the name of the uniform as defined in the shader
  17224. * @param value Define the value to give to the uniform
  17225. * @return the material itself allowing "fluent" like uniform updates
  17226. */
  17227. setVector4(name: string, value: Vector4): ShaderMaterial;
  17228. /**
  17229. * Set a mat4 in the shader from a Matrix.
  17230. * @param name Define the name of the uniform as defined in the shader
  17231. * @param value Define the value to give to the uniform
  17232. * @return the material itself allowing "fluent" like uniform updates
  17233. */
  17234. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17235. /**
  17236. * Set a mat3 in the shader from a Float32Array.
  17237. * @param name Define the name of the uniform as defined in the shader
  17238. * @param value Define the value to give to the uniform
  17239. * @return the material itself allowing "fluent" like uniform updates
  17240. */
  17241. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17242. /**
  17243. * Set a mat2 in the shader from a Float32Array.
  17244. * @param name Define the name of the uniform as defined in the shader
  17245. * @param value Define the value to give to the uniform
  17246. * @return the material itself allowing "fluent" like uniform updates
  17247. */
  17248. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17249. /**
  17250. * Set a vec2 array in the shader from a number array.
  17251. * @param name Define the name of the uniform as defined in the shader
  17252. * @param value Define the value to give to the uniform
  17253. * @return the material itself allowing "fluent" like uniform updates
  17254. */
  17255. setArray2(name: string, value: number[]): ShaderMaterial;
  17256. /**
  17257. * Set a vec3 array in the shader from a number array.
  17258. * @param name Define the name of the uniform as defined in the shader
  17259. * @param value Define the value to give to the uniform
  17260. * @return the material itself allowing "fluent" like uniform updates
  17261. */
  17262. setArray3(name: string, value: number[]): ShaderMaterial;
  17263. private _checkCache;
  17264. /**
  17265. * Specifies that the submesh is ready to be used
  17266. * @param mesh defines the mesh to check
  17267. * @param subMesh defines which submesh to check
  17268. * @param useInstances specifies that instances should be used
  17269. * @returns a boolean indicating that the submesh is ready or not
  17270. */
  17271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17272. /**
  17273. * Checks if the material is ready to render the requested mesh
  17274. * @param mesh Define the mesh to render
  17275. * @param useInstances Define whether or not the material is used with instances
  17276. * @returns true if ready, otherwise false
  17277. */
  17278. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17279. /**
  17280. * Binds the world matrix to the material
  17281. * @param world defines the world transformation matrix
  17282. */
  17283. bindOnlyWorldMatrix(world: Matrix): void;
  17284. /**
  17285. * Binds the material to the mesh
  17286. * @param world defines the world transformation matrix
  17287. * @param mesh defines the mesh to bind the material to
  17288. */
  17289. bind(world: Matrix, mesh?: Mesh): void;
  17290. /**
  17291. * Gets the active textures from the material
  17292. * @returns an array of textures
  17293. */
  17294. getActiveTextures(): BaseTexture[];
  17295. /**
  17296. * Specifies if the material uses a texture
  17297. * @param texture defines the texture to check against the material
  17298. * @returns a boolean specifying if the material uses the texture
  17299. */
  17300. hasTexture(texture: BaseTexture): boolean;
  17301. /**
  17302. * Makes a duplicate of the material, and gives it a new name
  17303. * @param name defines the new name for the duplicated material
  17304. * @returns the cloned material
  17305. */
  17306. clone(name: string): ShaderMaterial;
  17307. /**
  17308. * Disposes the material
  17309. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17310. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17311. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17312. */
  17313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17314. /**
  17315. * Serializes this material in a JSON representation
  17316. * @returns the serialized material object
  17317. */
  17318. serialize(): any;
  17319. /**
  17320. * Creates a shader material from parsed shader material data
  17321. * @param source defines the JSON represnetation of the material
  17322. * @param scene defines the hosting scene
  17323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17324. * @returns a new material
  17325. */
  17326. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17327. }
  17328. }
  17329. declare module "babylonjs/Shaders/color.fragment" {
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17332. /** @hidden */
  17333. export var colorPixelShader: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Shaders/color.vertex" {
  17339. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17340. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17341. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17342. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17343. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17344. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17345. /** @hidden */
  17346. export var colorVertexShader: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module "babylonjs/Meshes/linesMesh" {
  17352. import { Nullable } from "babylonjs/types";
  17353. import { Scene } from "babylonjs/scene";
  17354. import { Color3 } from "babylonjs/Maths/math";
  17355. import { Node } from "babylonjs/node";
  17356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17357. import { Mesh } from "babylonjs/Meshes/mesh";
  17358. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17359. import { Effect } from "babylonjs/Materials/effect";
  17360. import { Material } from "babylonjs/Materials/material";
  17361. import "babylonjs/Shaders/color.fragment";
  17362. import "babylonjs/Shaders/color.vertex";
  17363. /**
  17364. * Line mesh
  17365. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17366. */
  17367. export class LinesMesh extends Mesh {
  17368. /**
  17369. * If vertex color should be applied to the mesh
  17370. */
  17371. useVertexColor?: boolean | undefined;
  17372. /**
  17373. * If vertex alpha should be applied to the mesh
  17374. */
  17375. useVertexAlpha?: boolean | undefined;
  17376. /**
  17377. * Color of the line (Default: White)
  17378. */
  17379. color: Color3;
  17380. /**
  17381. * Alpha of the line (Default: 1)
  17382. */
  17383. alpha: number;
  17384. /**
  17385. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17386. * This margin is expressed in world space coordinates, so its value may vary.
  17387. * Default value is 0.1
  17388. */
  17389. intersectionThreshold: number;
  17390. private _colorShader;
  17391. /**
  17392. * Creates a new LinesMesh
  17393. * @param name defines the name
  17394. * @param scene defines the hosting scene
  17395. * @param parent defines the parent mesh if any
  17396. * @param source defines the optional source LinesMesh used to clone data from
  17397. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17398. * When false, achieved by calling a clone(), also passing False.
  17399. * This will make creation of children, recursive.
  17400. * @param useVertexColor defines if this LinesMesh supports vertex color
  17401. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17402. */
  17403. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17404. /**
  17405. * If vertex color should be applied to the mesh
  17406. */
  17407. useVertexColor?: boolean | undefined,
  17408. /**
  17409. * If vertex alpha should be applied to the mesh
  17410. */
  17411. useVertexAlpha?: boolean | undefined);
  17412. private _addClipPlaneDefine;
  17413. private _removeClipPlaneDefine;
  17414. isReady(): boolean;
  17415. /**
  17416. * Returns the string "LineMesh"
  17417. */
  17418. getClassName(): string;
  17419. /**
  17420. * @hidden
  17421. */
  17422. /**
  17423. * @hidden
  17424. */
  17425. material: Material;
  17426. /**
  17427. * @hidden
  17428. */
  17429. readonly checkCollisions: boolean;
  17430. /** @hidden */
  17431. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17432. /** @hidden */
  17433. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17434. /**
  17435. * Disposes of the line mesh
  17436. * @param doNotRecurse If children should be disposed
  17437. */
  17438. dispose(doNotRecurse?: boolean): void;
  17439. /**
  17440. * Returns a new LineMesh object cloned from the current one.
  17441. */
  17442. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17443. /**
  17444. * Creates a new InstancedLinesMesh object from the mesh model.
  17445. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17446. * @param name defines the name of the new instance
  17447. * @returns a new InstancedLinesMesh
  17448. */
  17449. createInstance(name: string): InstancedLinesMesh;
  17450. }
  17451. /**
  17452. * Creates an instance based on a source LinesMesh
  17453. */
  17454. export class InstancedLinesMesh extends InstancedMesh {
  17455. /**
  17456. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17457. * This margin is expressed in world space coordinates, so its value may vary.
  17458. * Initilized with the intersectionThreshold value of the source LinesMesh
  17459. */
  17460. intersectionThreshold: number;
  17461. constructor(name: string, source: LinesMesh);
  17462. /**
  17463. * Returns the string "InstancedLinesMesh".
  17464. */
  17465. getClassName(): string;
  17466. }
  17467. }
  17468. declare module "babylonjs/Shaders/line.fragment" {
  17469. /** @hidden */
  17470. export var linePixelShader: {
  17471. name: string;
  17472. shader: string;
  17473. };
  17474. }
  17475. declare module "babylonjs/Shaders/line.vertex" {
  17476. /** @hidden */
  17477. export var lineVertexShader: {
  17478. name: string;
  17479. shader: string;
  17480. };
  17481. }
  17482. declare module "babylonjs/Rendering/edgesRenderer" {
  17483. import { Nullable } from "babylonjs/types";
  17484. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17486. import { Vector3 } from "babylonjs/Maths/math";
  17487. import { IDisposable } from "babylonjs/scene";
  17488. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17489. import "babylonjs/Shaders/line.fragment";
  17490. import "babylonjs/Shaders/line.vertex";
  17491. module "babylonjs/Meshes/abstractMesh" {
  17492. interface AbstractMesh {
  17493. /**
  17494. * Disables the mesh edge rendering mode
  17495. * @returns the currentAbstractMesh
  17496. */
  17497. disableEdgesRendering(): AbstractMesh;
  17498. /**
  17499. * Enables the edge rendering mode on the mesh.
  17500. * This mode makes the mesh edges visible
  17501. * @param epsilon defines the maximal distance between two angles to detect a face
  17502. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17503. * @returns the currentAbstractMesh
  17504. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17505. */
  17506. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17507. /**
  17508. * Gets the edgesRenderer associated with the mesh
  17509. */
  17510. edgesRenderer: Nullable<EdgesRenderer>;
  17511. }
  17512. }
  17513. module "babylonjs/Meshes/linesMesh" {
  17514. interface LinesMesh {
  17515. /**
  17516. * Enables the edge rendering mode on the mesh.
  17517. * This mode makes the mesh edges visible
  17518. * @param epsilon defines the maximal distance between two angles to detect a face
  17519. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17520. * @returns the currentAbstractMesh
  17521. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17522. */
  17523. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17524. }
  17525. }
  17526. module "babylonjs/Meshes/linesMesh" {
  17527. interface InstancedLinesMesh {
  17528. /**
  17529. * Enables the edge rendering mode on the mesh.
  17530. * This mode makes the mesh edges visible
  17531. * @param epsilon defines the maximal distance between two angles to detect a face
  17532. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17533. * @returns the current InstancedLinesMesh
  17534. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17535. */
  17536. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17537. }
  17538. }
  17539. /**
  17540. * Defines the minimum contract an Edges renderer should follow.
  17541. */
  17542. export interface IEdgesRenderer extends IDisposable {
  17543. /**
  17544. * Gets or sets a boolean indicating if the edgesRenderer is active
  17545. */
  17546. isEnabled: boolean;
  17547. /**
  17548. * Renders the edges of the attached mesh,
  17549. */
  17550. render(): void;
  17551. /**
  17552. * Checks wether or not the edges renderer is ready to render.
  17553. * @return true if ready, otherwise false.
  17554. */
  17555. isReady(): boolean;
  17556. }
  17557. /**
  17558. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17559. */
  17560. export class EdgesRenderer implements IEdgesRenderer {
  17561. /**
  17562. * Define the size of the edges with an orthographic camera
  17563. */
  17564. edgesWidthScalerForOrthographic: number;
  17565. /**
  17566. * Define the size of the edges with a perspective camera
  17567. */
  17568. edgesWidthScalerForPerspective: number;
  17569. protected _source: AbstractMesh;
  17570. protected _linesPositions: number[];
  17571. protected _linesNormals: number[];
  17572. protected _linesIndices: number[];
  17573. protected _epsilon: number;
  17574. protected _indicesCount: number;
  17575. protected _lineShader: ShaderMaterial;
  17576. protected _ib: WebGLBuffer;
  17577. protected _buffers: {
  17578. [key: string]: Nullable<VertexBuffer>;
  17579. };
  17580. protected _checkVerticesInsteadOfIndices: boolean;
  17581. private _meshRebuildObserver;
  17582. private _meshDisposeObserver;
  17583. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17584. isEnabled: boolean;
  17585. /**
  17586. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17587. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17588. * @param source Mesh used to create edges
  17589. * @param epsilon sum of angles in adjacency to check for edge
  17590. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17591. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17592. */
  17593. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17594. protected _prepareRessources(): void;
  17595. /** @hidden */
  17596. _rebuild(): void;
  17597. /**
  17598. * Releases the required resources for the edges renderer
  17599. */
  17600. dispose(): void;
  17601. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17602. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17603. /**
  17604. * Checks if the pair of p0 and p1 is en edge
  17605. * @param faceIndex
  17606. * @param edge
  17607. * @param faceNormals
  17608. * @param p0
  17609. * @param p1
  17610. * @private
  17611. */
  17612. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17613. /**
  17614. * push line into the position, normal and index buffer
  17615. * @protected
  17616. */
  17617. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17618. /**
  17619. * Generates lines edges from adjacencjes
  17620. * @private
  17621. */
  17622. _generateEdgesLines(): void;
  17623. /**
  17624. * Checks wether or not the edges renderer is ready to render.
  17625. * @return true if ready, otherwise false.
  17626. */
  17627. isReady(): boolean;
  17628. /**
  17629. * Renders the edges of the attached mesh,
  17630. */
  17631. render(): void;
  17632. }
  17633. /**
  17634. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17635. */
  17636. export class LineEdgesRenderer extends EdgesRenderer {
  17637. /**
  17638. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17639. * @param source LineMesh used to generate edges
  17640. * @param epsilon not important (specified angle for edge detection)
  17641. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17642. */
  17643. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17644. /**
  17645. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17646. */
  17647. _generateEdgesLines(): void;
  17648. }
  17649. }
  17650. declare module "babylonjs/Rendering/renderingGroup" {
  17651. import { SmartArray } from "babylonjs/Misc/smartArray";
  17652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17654. import { Nullable } from "babylonjs/types";
  17655. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17656. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17657. import { Material } from "babylonjs/Materials/material";
  17658. import { Scene } from "babylonjs/scene";
  17659. /**
  17660. * This represents the object necessary to create a rendering group.
  17661. * This is exclusively used and created by the rendering manager.
  17662. * To modify the behavior, you use the available helpers in your scene or meshes.
  17663. * @hidden
  17664. */
  17665. export class RenderingGroup {
  17666. index: number;
  17667. private _scene;
  17668. private _opaqueSubMeshes;
  17669. private _transparentSubMeshes;
  17670. private _alphaTestSubMeshes;
  17671. private _depthOnlySubMeshes;
  17672. private _particleSystems;
  17673. private _spriteManagers;
  17674. private _opaqueSortCompareFn;
  17675. private _alphaTestSortCompareFn;
  17676. private _transparentSortCompareFn;
  17677. private _renderOpaque;
  17678. private _renderAlphaTest;
  17679. private _renderTransparent;
  17680. private _edgesRenderers;
  17681. onBeforeTransparentRendering: () => void;
  17682. /**
  17683. * Set the opaque sort comparison function.
  17684. * If null the sub meshes will be render in the order they were created
  17685. */
  17686. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17687. /**
  17688. * Set the alpha test sort comparison function.
  17689. * If null the sub meshes will be render in the order they were created
  17690. */
  17691. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17692. /**
  17693. * Set the transparent sort comparison function.
  17694. * If null the sub meshes will be render in the order they were created
  17695. */
  17696. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17697. /**
  17698. * Creates a new rendering group.
  17699. * @param index The rendering group index
  17700. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17701. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17702. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17703. */
  17704. 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>);
  17705. /**
  17706. * Render all the sub meshes contained in the group.
  17707. * @param customRenderFunction Used to override the default render behaviour of the group.
  17708. * @returns true if rendered some submeshes.
  17709. */
  17710. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17711. /**
  17712. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17713. * @param subMeshes The submeshes to render
  17714. */
  17715. private renderOpaqueSorted;
  17716. /**
  17717. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17718. * @param subMeshes The submeshes to render
  17719. */
  17720. private renderAlphaTestSorted;
  17721. /**
  17722. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17723. * @param subMeshes The submeshes to render
  17724. */
  17725. private renderTransparentSorted;
  17726. /**
  17727. * Renders the submeshes in a specified order.
  17728. * @param subMeshes The submeshes to sort before render
  17729. * @param sortCompareFn The comparison function use to sort
  17730. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17731. * @param transparent Specifies to activate blending if true
  17732. */
  17733. private static renderSorted;
  17734. /**
  17735. * Renders the submeshes in the order they were dispatched (no sort applied).
  17736. * @param subMeshes The submeshes to render
  17737. */
  17738. private static renderUnsorted;
  17739. /**
  17740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17741. * are rendered back to front if in the same alpha index.
  17742. *
  17743. * @param a The first submesh
  17744. * @param b The second submesh
  17745. * @returns The result of the comparison
  17746. */
  17747. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17748. /**
  17749. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17750. * are rendered back to front.
  17751. *
  17752. * @param a The first submesh
  17753. * @param b The second submesh
  17754. * @returns The result of the comparison
  17755. */
  17756. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17757. /**
  17758. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17759. * are rendered front to back (prevent overdraw).
  17760. *
  17761. * @param a The first submesh
  17762. * @param b The second submesh
  17763. * @returns The result of the comparison
  17764. */
  17765. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17766. /**
  17767. * Resets the different lists of submeshes to prepare a new frame.
  17768. */
  17769. prepare(): void;
  17770. dispose(): void;
  17771. /**
  17772. * Inserts the submesh in its correct queue depending on its material.
  17773. * @param subMesh The submesh to dispatch
  17774. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17775. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17776. */
  17777. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17778. dispatchSprites(spriteManager: ISpriteManager): void;
  17779. dispatchParticles(particleSystem: IParticleSystem): void;
  17780. private _renderParticles;
  17781. private _renderSprites;
  17782. }
  17783. }
  17784. declare module "babylonjs/Rendering/renderingManager" {
  17785. import { Nullable } from "babylonjs/types";
  17786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17787. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17788. import { SmartArray } from "babylonjs/Misc/smartArray";
  17789. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17790. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17791. import { Material } from "babylonjs/Materials/material";
  17792. import { Scene } from "babylonjs/scene";
  17793. import { Camera } from "babylonjs/Cameras/camera";
  17794. /**
  17795. * Interface describing the different options available in the rendering manager
  17796. * regarding Auto Clear between groups.
  17797. */
  17798. export interface IRenderingManagerAutoClearSetup {
  17799. /**
  17800. * Defines whether or not autoclear is enable.
  17801. */
  17802. autoClear: boolean;
  17803. /**
  17804. * Defines whether or not to autoclear the depth buffer.
  17805. */
  17806. depth: boolean;
  17807. /**
  17808. * Defines whether or not to autoclear the stencil buffer.
  17809. */
  17810. stencil: boolean;
  17811. }
  17812. /**
  17813. * This class is used by the onRenderingGroupObservable
  17814. */
  17815. export class RenderingGroupInfo {
  17816. /**
  17817. * The Scene that being rendered
  17818. */
  17819. scene: Scene;
  17820. /**
  17821. * The camera currently used for the rendering pass
  17822. */
  17823. camera: Nullable<Camera>;
  17824. /**
  17825. * The ID of the renderingGroup being processed
  17826. */
  17827. renderingGroupId: number;
  17828. }
  17829. /**
  17830. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17831. * It is enable to manage the different groups as well as the different necessary sort functions.
  17832. * This should not be used directly aside of the few static configurations
  17833. */
  17834. export class RenderingManager {
  17835. /**
  17836. * The max id used for rendering groups (not included)
  17837. */
  17838. static MAX_RENDERINGGROUPS: number;
  17839. /**
  17840. * The min id used for rendering groups (included)
  17841. */
  17842. static MIN_RENDERINGGROUPS: number;
  17843. /**
  17844. * Used to globally prevent autoclearing scenes.
  17845. */
  17846. static AUTOCLEAR: boolean;
  17847. /**
  17848. * @hidden
  17849. */
  17850. _useSceneAutoClearSetup: boolean;
  17851. private _scene;
  17852. private _renderingGroups;
  17853. private _depthStencilBufferAlreadyCleaned;
  17854. private _autoClearDepthStencil;
  17855. private _customOpaqueSortCompareFn;
  17856. private _customAlphaTestSortCompareFn;
  17857. private _customTransparentSortCompareFn;
  17858. private _renderingGroupInfo;
  17859. /**
  17860. * Instantiates a new rendering group for a particular scene
  17861. * @param scene Defines the scene the groups belongs to
  17862. */
  17863. constructor(scene: Scene);
  17864. private _clearDepthStencilBuffer;
  17865. /**
  17866. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17867. * @hidden
  17868. */
  17869. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17870. /**
  17871. * Resets the different information of the group to prepare a new frame
  17872. * @hidden
  17873. */
  17874. reset(): void;
  17875. /**
  17876. * Dispose and release the group and its associated resources.
  17877. * @hidden
  17878. */
  17879. dispose(): void;
  17880. /**
  17881. * Clear the info related to rendering groups preventing retention points during dispose.
  17882. */
  17883. freeRenderingGroups(): void;
  17884. private _prepareRenderingGroup;
  17885. /**
  17886. * Add a sprite manager to the rendering manager in order to render it this frame.
  17887. * @param spriteManager Define the sprite manager to render
  17888. */
  17889. dispatchSprites(spriteManager: ISpriteManager): void;
  17890. /**
  17891. * Add a particle system to the rendering manager in order to render it this frame.
  17892. * @param particleSystem Define the particle system to render
  17893. */
  17894. dispatchParticles(particleSystem: IParticleSystem): void;
  17895. /**
  17896. * Add a submesh to the manager in order to render it this frame
  17897. * @param subMesh The submesh to dispatch
  17898. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17899. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17900. */
  17901. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17902. /**
  17903. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17904. * This allowed control for front to back rendering or reversly depending of the special needs.
  17905. *
  17906. * @param renderingGroupId The rendering group id corresponding to its index
  17907. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17908. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17909. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17910. */
  17911. 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;
  17912. /**
  17913. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17914. *
  17915. * @param renderingGroupId The rendering group id corresponding to its index
  17916. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17917. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17918. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17919. */
  17920. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17921. /**
  17922. * Gets the current auto clear configuration for one rendering group of the rendering
  17923. * manager.
  17924. * @param index the rendering group index to get the information for
  17925. * @returns The auto clear setup for the requested rendering group
  17926. */
  17927. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17928. }
  17929. }
  17930. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17931. import { Observable } from "babylonjs/Misc/observable";
  17932. import { SmartArray } from "babylonjs/Misc/smartArray";
  17933. import { Nullable } from "babylonjs/types";
  17934. import { Camera } from "babylonjs/Cameras/camera";
  17935. import { Scene } from "babylonjs/scene";
  17936. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17937. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17940. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17941. import { Texture } from "babylonjs/Materials/Textures/texture";
  17942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17943. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17944. import { Engine } from "babylonjs/Engines/engine";
  17945. /**
  17946. * This Helps creating a texture that will be created from a camera in your scene.
  17947. * It is basically a dynamic texture that could be used to create special effects for instance.
  17948. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17949. */
  17950. export class RenderTargetTexture extends Texture {
  17951. isCube: boolean;
  17952. /**
  17953. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17954. */
  17955. static readonly REFRESHRATE_RENDER_ONCE: number;
  17956. /**
  17957. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17958. */
  17959. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17960. /**
  17961. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17962. * the central point of your effect and can save a lot of performances.
  17963. */
  17964. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17965. /**
  17966. * Use this predicate to dynamically define the list of mesh you want to render.
  17967. * If set, the renderList property will be overwritten.
  17968. */
  17969. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17970. private _renderList;
  17971. /**
  17972. * Use this list to define the list of mesh you want to render.
  17973. */
  17974. renderList: Nullable<Array<AbstractMesh>>;
  17975. private _hookArray;
  17976. /**
  17977. * Define if particles should be rendered in your texture.
  17978. */
  17979. renderParticles: boolean;
  17980. /**
  17981. * Define if sprites should be rendered in your texture.
  17982. */
  17983. renderSprites: boolean;
  17984. /**
  17985. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17986. */
  17987. coordinatesMode: number;
  17988. /**
  17989. * Define the camera used to render the texture.
  17990. */
  17991. activeCamera: Nullable<Camera>;
  17992. /**
  17993. * Override the render function of the texture with your own one.
  17994. */
  17995. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17996. /**
  17997. * Define if camera post processes should be use while rendering the texture.
  17998. */
  17999. useCameraPostProcesses: boolean;
  18000. /**
  18001. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18002. */
  18003. ignoreCameraViewport: boolean;
  18004. private _postProcessManager;
  18005. private _postProcesses;
  18006. private _resizeObserver;
  18007. /**
  18008. * An event triggered when the texture is unbind.
  18009. */
  18010. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18011. /**
  18012. * An event triggered when the texture is unbind.
  18013. */
  18014. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18015. private _onAfterUnbindObserver;
  18016. /**
  18017. * Set a after unbind callback in the texture.
  18018. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18019. */
  18020. onAfterUnbind: () => void;
  18021. /**
  18022. * An event triggered before rendering the texture
  18023. */
  18024. onBeforeRenderObservable: Observable<number>;
  18025. private _onBeforeRenderObserver;
  18026. /**
  18027. * Set a before render callback in the texture.
  18028. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18029. */
  18030. onBeforeRender: (faceIndex: number) => void;
  18031. /**
  18032. * An event triggered after rendering the texture
  18033. */
  18034. onAfterRenderObservable: Observable<number>;
  18035. private _onAfterRenderObserver;
  18036. /**
  18037. * Set a after render callback in the texture.
  18038. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18039. */
  18040. onAfterRender: (faceIndex: number) => void;
  18041. /**
  18042. * An event triggered after the texture clear
  18043. */
  18044. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18045. private _onClearObserver;
  18046. /**
  18047. * Set a clear callback in the texture.
  18048. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18049. */
  18050. onClear: (Engine: Engine) => void;
  18051. /**
  18052. * Define the clear color of the Render Target if it should be different from the scene.
  18053. */
  18054. clearColor: Color4;
  18055. protected _size: number | {
  18056. width: number;
  18057. height: number;
  18058. };
  18059. protected _initialSizeParameter: number | {
  18060. width: number;
  18061. height: number;
  18062. } | {
  18063. ratio: number;
  18064. };
  18065. protected _sizeRatio: Nullable<number>;
  18066. /** @hidden */
  18067. _generateMipMaps: boolean;
  18068. protected _renderingManager: RenderingManager;
  18069. /** @hidden */
  18070. _waitingRenderList: string[];
  18071. protected _doNotChangeAspectRatio: boolean;
  18072. protected _currentRefreshId: number;
  18073. protected _refreshRate: number;
  18074. protected _textureMatrix: Matrix;
  18075. protected _samples: number;
  18076. protected _renderTargetOptions: RenderTargetCreationOptions;
  18077. /**
  18078. * Gets render target creation options that were used.
  18079. */
  18080. readonly renderTargetOptions: RenderTargetCreationOptions;
  18081. protected _engine: Engine;
  18082. protected _onRatioRescale(): void;
  18083. /**
  18084. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18085. * It must define where the camera used to render the texture is set
  18086. */
  18087. boundingBoxPosition: Vector3;
  18088. private _boundingBoxSize;
  18089. /**
  18090. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18091. * When defined, the cubemap will switch to local mode
  18092. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18093. * @example https://www.babylonjs-playground.com/#RNASML
  18094. */
  18095. boundingBoxSize: Vector3;
  18096. /**
  18097. * In case the RTT has been created with a depth texture, get the associated
  18098. * depth texture.
  18099. * Otherwise, return null.
  18100. */
  18101. depthStencilTexture: Nullable<InternalTexture>;
  18102. /**
  18103. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18104. * or used a shadow, depth texture...
  18105. * @param name The friendly name of the texture
  18106. * @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)
  18107. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18108. * @param generateMipMaps True if mip maps need to be generated after render.
  18109. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18110. * @param type The type of the buffer in the RTT (int, half float, float...)
  18111. * @param isCube True if a cube texture needs to be created
  18112. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18113. * @param generateDepthBuffer True to generate a depth buffer
  18114. * @param generateStencilBuffer True to generate a stencil buffer
  18115. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18116. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18117. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18118. */
  18119. constructor(name: string, size: number | {
  18120. width: number;
  18121. height: number;
  18122. } | {
  18123. ratio: number;
  18124. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18125. /**
  18126. * Creates a depth stencil texture.
  18127. * This is only available in WebGL 2 or with the depth texture extension available.
  18128. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18129. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18130. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18131. */
  18132. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18133. private _processSizeParameter;
  18134. /**
  18135. * Define the number of samples to use in case of MSAA.
  18136. * It defaults to one meaning no MSAA has been enabled.
  18137. */
  18138. samples: number;
  18139. /**
  18140. * Resets the refresh counter of the texture and start bak from scratch.
  18141. * Could be useful to regenerate the texture if it is setup to render only once.
  18142. */
  18143. resetRefreshCounter(): void;
  18144. /**
  18145. * Define the refresh rate of the texture or the rendering frequency.
  18146. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18147. */
  18148. refreshRate: number;
  18149. /**
  18150. * Adds a post process to the render target rendering passes.
  18151. * @param postProcess define the post process to add
  18152. */
  18153. addPostProcess(postProcess: PostProcess): void;
  18154. /**
  18155. * Clear all the post processes attached to the render target
  18156. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18157. */
  18158. clearPostProcesses(dispose?: boolean): void;
  18159. /**
  18160. * Remove one of the post process from the list of attached post processes to the texture
  18161. * @param postProcess define the post process to remove from the list
  18162. */
  18163. removePostProcess(postProcess: PostProcess): void;
  18164. /** @hidden */
  18165. _shouldRender(): boolean;
  18166. /**
  18167. * Gets the actual render size of the texture.
  18168. * @returns the width of the render size
  18169. */
  18170. getRenderSize(): number;
  18171. /**
  18172. * Gets the actual render width of the texture.
  18173. * @returns the width of the render size
  18174. */
  18175. getRenderWidth(): number;
  18176. /**
  18177. * Gets the actual render height of the texture.
  18178. * @returns the height of the render size
  18179. */
  18180. getRenderHeight(): number;
  18181. /**
  18182. * Get if the texture can be rescaled or not.
  18183. */
  18184. readonly canRescale: boolean;
  18185. /**
  18186. * Resize the texture using a ratio.
  18187. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18188. */
  18189. scale(ratio: number): void;
  18190. /**
  18191. * Get the texture reflection matrix used to rotate/transform the reflection.
  18192. * @returns the reflection matrix
  18193. */
  18194. getReflectionTextureMatrix(): Matrix;
  18195. /**
  18196. * Resize the texture to a new desired size.
  18197. * Be carrefull as it will recreate all the data in the new texture.
  18198. * @param size Define the new size. It can be:
  18199. * - a number for squared texture,
  18200. * - an object containing { width: number, height: number }
  18201. * - or an object containing a ratio { ratio: number }
  18202. */
  18203. resize(size: number | {
  18204. width: number;
  18205. height: number;
  18206. } | {
  18207. ratio: number;
  18208. }): void;
  18209. /**
  18210. * Renders all the objects from the render list into the texture.
  18211. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18212. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18213. */
  18214. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18215. private _bestReflectionRenderTargetDimension;
  18216. /**
  18217. * @hidden
  18218. * @param faceIndex face index to bind to if this is a cubetexture
  18219. */
  18220. _bindFrameBuffer(faceIndex?: number): void;
  18221. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18222. private renderToTarget;
  18223. /**
  18224. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18225. * This allowed control for front to back rendering or reversly depending of the special needs.
  18226. *
  18227. * @param renderingGroupId The rendering group id corresponding to its index
  18228. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18229. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18230. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18231. */
  18232. 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;
  18233. /**
  18234. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18235. *
  18236. * @param renderingGroupId The rendering group id corresponding to its index
  18237. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18238. */
  18239. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18240. /**
  18241. * Clones the texture.
  18242. * @returns the cloned texture
  18243. */
  18244. clone(): RenderTargetTexture;
  18245. /**
  18246. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18247. * @returns The JSON representation of the texture
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18252. */
  18253. disposeFramebufferObjects(): void;
  18254. /**
  18255. * Dispose the texture and release its associated resources.
  18256. */
  18257. dispose(): void;
  18258. /** @hidden */
  18259. _rebuild(): void;
  18260. /**
  18261. * Clear the info related to rendering groups preventing retention point in material dispose.
  18262. */
  18263. freeRenderingGroups(): void;
  18264. /**
  18265. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18266. * @returns the view count
  18267. */
  18268. getViewCount(): number;
  18269. }
  18270. }
  18271. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18272. import { Scene } from "babylonjs/scene";
  18273. import { Plane } from "babylonjs/Maths/math";
  18274. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18275. /**
  18276. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18277. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18278. * You can then easily use it as a reflectionTexture on a flat surface.
  18279. * In case the surface is not a plane, please consider relying on reflection probes.
  18280. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18281. */
  18282. export class MirrorTexture extends RenderTargetTexture {
  18283. private scene;
  18284. /**
  18285. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18286. * 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.
  18287. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18288. */
  18289. mirrorPlane: Plane;
  18290. /**
  18291. * Define the blur ratio used to blur the reflection if needed.
  18292. */
  18293. blurRatio: number;
  18294. /**
  18295. * Define the adaptive blur kernel used to blur the reflection if needed.
  18296. * This will autocompute the closest best match for the `blurKernel`
  18297. */
  18298. adaptiveBlurKernel: number;
  18299. /**
  18300. * Define the blur kernel used to blur the reflection if needed.
  18301. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18302. */
  18303. blurKernel: number;
  18304. /**
  18305. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18306. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18307. */
  18308. blurKernelX: number;
  18309. /**
  18310. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18311. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18312. */
  18313. blurKernelY: number;
  18314. private _autoComputeBlurKernel;
  18315. protected _onRatioRescale(): void;
  18316. private _updateGammaSpace;
  18317. private _imageProcessingConfigChangeObserver;
  18318. private _transformMatrix;
  18319. private _mirrorMatrix;
  18320. private _savedViewMatrix;
  18321. private _blurX;
  18322. private _blurY;
  18323. private _adaptiveBlurKernel;
  18324. private _blurKernelX;
  18325. private _blurKernelY;
  18326. private _blurRatio;
  18327. /**
  18328. * Instantiates a Mirror Texture.
  18329. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18330. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18331. * You can then easily use it as a reflectionTexture on a flat surface.
  18332. * In case the surface is not a plane, please consider relying on reflection probes.
  18333. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18334. * @param name
  18335. * @param size
  18336. * @param scene
  18337. * @param generateMipMaps
  18338. * @param type
  18339. * @param samplingMode
  18340. * @param generateDepthBuffer
  18341. */
  18342. constructor(name: string, size: number | {
  18343. width: number;
  18344. height: number;
  18345. } | {
  18346. ratio: number;
  18347. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18348. private _preparePostProcesses;
  18349. /**
  18350. * Clone the mirror texture.
  18351. * @returns the cloned texture
  18352. */
  18353. clone(): MirrorTexture;
  18354. /**
  18355. * Serialize the texture to a JSON representation you could use in Parse later on
  18356. * @returns the serialized JSON representation
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Dispose the texture and release its associated resources.
  18361. */
  18362. dispose(): void;
  18363. }
  18364. }
  18365. declare module "babylonjs/Materials/Textures/texture" {
  18366. import { Observable } from "babylonjs/Misc/observable";
  18367. import { Nullable } from "babylonjs/types";
  18368. import { Scene } from "babylonjs/scene";
  18369. import { Matrix } from "babylonjs/Maths/math";
  18370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18371. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18372. /**
  18373. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18374. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18375. */
  18376. export class Texture extends BaseTexture {
  18377. /** @hidden */
  18378. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18379. /** @hidden */
  18380. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18381. /** @hidden */
  18382. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18383. /** nearest is mag = nearest and min = nearest and mip = linear */
  18384. static readonly NEAREST_SAMPLINGMODE: number;
  18385. /** nearest is mag = nearest and min = nearest and mip = linear */
  18386. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18388. static readonly BILINEAR_SAMPLINGMODE: number;
  18389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18390. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18391. /** Trilinear is mag = linear and min = linear and mip = linear */
  18392. static readonly TRILINEAR_SAMPLINGMODE: number;
  18393. /** Trilinear is mag = linear and min = linear and mip = linear */
  18394. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18395. /** mag = nearest and min = nearest and mip = nearest */
  18396. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18397. /** mag = nearest and min = linear and mip = nearest */
  18398. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18399. /** mag = nearest and min = linear and mip = linear */
  18400. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18401. /** mag = nearest and min = linear and mip = none */
  18402. static readonly NEAREST_LINEAR: number;
  18403. /** mag = nearest and min = nearest and mip = none */
  18404. static readonly NEAREST_NEAREST: number;
  18405. /** mag = linear and min = nearest and mip = nearest */
  18406. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18407. /** mag = linear and min = nearest and mip = linear */
  18408. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18409. /** mag = linear and min = linear and mip = none */
  18410. static readonly LINEAR_LINEAR: number;
  18411. /** mag = linear and min = nearest and mip = none */
  18412. static readonly LINEAR_NEAREST: number;
  18413. /** Explicit coordinates mode */
  18414. static readonly EXPLICIT_MODE: number;
  18415. /** Spherical coordinates mode */
  18416. static readonly SPHERICAL_MODE: number;
  18417. /** Planar coordinates mode */
  18418. static readonly PLANAR_MODE: number;
  18419. /** Cubic coordinates mode */
  18420. static readonly CUBIC_MODE: number;
  18421. /** Projection coordinates mode */
  18422. static readonly PROJECTION_MODE: number;
  18423. /** Inverse Cubic coordinates mode */
  18424. static readonly SKYBOX_MODE: number;
  18425. /** Inverse Cubic coordinates mode */
  18426. static readonly INVCUBIC_MODE: number;
  18427. /** Equirectangular coordinates mode */
  18428. static readonly EQUIRECTANGULAR_MODE: number;
  18429. /** Equirectangular Fixed coordinates mode */
  18430. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18431. /** Equirectangular Fixed Mirrored coordinates mode */
  18432. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18433. /** Texture is not repeating outside of 0..1 UVs */
  18434. static readonly CLAMP_ADDRESSMODE: number;
  18435. /** Texture is repeating outside of 0..1 UVs */
  18436. static readonly WRAP_ADDRESSMODE: number;
  18437. /** Texture is repeating and mirrored */
  18438. static readonly MIRROR_ADDRESSMODE: number;
  18439. /**
  18440. * 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
  18441. */
  18442. static UseSerializedUrlIfAny: boolean;
  18443. /**
  18444. * Define the url of the texture.
  18445. */
  18446. url: Nullable<string>;
  18447. /**
  18448. * Define an offset on the texture to offset the u coordinates of the UVs
  18449. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18450. */
  18451. uOffset: number;
  18452. /**
  18453. * Define an offset on the texture to offset the v coordinates of the UVs
  18454. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18455. */
  18456. vOffset: number;
  18457. /**
  18458. * Define an offset on the texture to scale the u coordinates of the UVs
  18459. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18460. */
  18461. uScale: number;
  18462. /**
  18463. * Define an offset on the texture to scale the v coordinates of the UVs
  18464. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18465. */
  18466. vScale: number;
  18467. /**
  18468. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18469. * @see http://doc.babylonjs.com/how_to/more_materials
  18470. */
  18471. uAng: number;
  18472. /**
  18473. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18474. * @see http://doc.babylonjs.com/how_to/more_materials
  18475. */
  18476. vAng: number;
  18477. /**
  18478. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18479. * @see http://doc.babylonjs.com/how_to/more_materials
  18480. */
  18481. wAng: number;
  18482. /**
  18483. * Defines the center of rotation (U)
  18484. */
  18485. uRotationCenter: number;
  18486. /**
  18487. * Defines the center of rotation (V)
  18488. */
  18489. vRotationCenter: number;
  18490. /**
  18491. * Defines the center of rotation (W)
  18492. */
  18493. wRotationCenter: number;
  18494. /**
  18495. * Are mip maps generated for this texture or not.
  18496. */
  18497. readonly noMipmap: boolean;
  18498. /**
  18499. * List of inspectable custom properties (used by the Inspector)
  18500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18501. */
  18502. inspectableCustomProperties: IInspectable[];
  18503. private _noMipmap;
  18504. /** @hidden */
  18505. _invertY: boolean;
  18506. private _rowGenerationMatrix;
  18507. private _cachedTextureMatrix;
  18508. private _projectionModeMatrix;
  18509. private _t0;
  18510. private _t1;
  18511. private _t2;
  18512. private _cachedUOffset;
  18513. private _cachedVOffset;
  18514. private _cachedUScale;
  18515. private _cachedVScale;
  18516. private _cachedUAng;
  18517. private _cachedVAng;
  18518. private _cachedWAng;
  18519. private _cachedProjectionMatrixId;
  18520. private _cachedCoordinatesMode;
  18521. /** @hidden */
  18522. protected _initialSamplingMode: number;
  18523. /** @hidden */
  18524. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18525. private _deleteBuffer;
  18526. protected _format: Nullable<number>;
  18527. private _delayedOnLoad;
  18528. private _delayedOnError;
  18529. /**
  18530. * Observable triggered once the texture has been loaded.
  18531. */
  18532. onLoadObservable: Observable<Texture>;
  18533. protected _isBlocking: boolean;
  18534. /**
  18535. * Is the texture preventing material to render while loading.
  18536. * If false, a default texture will be used instead of the loading one during the preparation step.
  18537. */
  18538. isBlocking: boolean;
  18539. /**
  18540. * Get the current sampling mode associated with the texture.
  18541. */
  18542. readonly samplingMode: number;
  18543. /**
  18544. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18545. */
  18546. readonly invertY: boolean;
  18547. /**
  18548. * Instantiates a new texture.
  18549. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18550. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18551. * @param url define the url of the picture to load as a texture
  18552. * @param scene define the scene the texture will belong to
  18553. * @param noMipmap define if the texture will require mip maps or not
  18554. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18555. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18556. * @param onLoad define a callback triggered when the texture has been loaded
  18557. * @param onError define a callback triggered when an error occurred during the loading session
  18558. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18559. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18560. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18561. */
  18562. 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);
  18563. /**
  18564. * Update the url (and optional buffer) of this texture if url was null during construction.
  18565. * @param url the url of the texture
  18566. * @param buffer the buffer of the texture (defaults to null)
  18567. * @param onLoad callback called when the texture is loaded (defaults to null)
  18568. */
  18569. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18570. /**
  18571. * Finish the loading sequence of a texture flagged as delayed load.
  18572. * @hidden
  18573. */
  18574. delayLoad(): void;
  18575. private _prepareRowForTextureGeneration;
  18576. /**
  18577. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18578. * @returns the transform matrix of the texture.
  18579. */
  18580. getTextureMatrix(): Matrix;
  18581. /**
  18582. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18583. * @returns The reflection texture transform
  18584. */
  18585. getReflectionTextureMatrix(): Matrix;
  18586. /**
  18587. * Clones the texture.
  18588. * @returns the cloned texture
  18589. */
  18590. clone(): Texture;
  18591. /**
  18592. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18593. * @returns The JSON representation of the texture
  18594. */
  18595. serialize(): any;
  18596. /**
  18597. * Get the current class name of the texture useful for serialization or dynamic coding.
  18598. * @returns "Texture"
  18599. */
  18600. getClassName(): string;
  18601. /**
  18602. * Dispose the texture and release its associated resources.
  18603. */
  18604. dispose(): void;
  18605. /**
  18606. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18607. * @param parsedTexture Define the JSON representation of the texture
  18608. * @param scene Define the scene the parsed texture should be instantiated in
  18609. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18610. * @returns The parsed texture if successful
  18611. */
  18612. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18613. /**
  18614. * Creates a texture from its base 64 representation.
  18615. * @param data Define the base64 payload without the data: prefix
  18616. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18617. * @param scene Define the scene the texture should belong to
  18618. * @param noMipmap Forces the texture to not create mip map information if true
  18619. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18620. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18621. * @param onLoad define a callback triggered when the texture has been loaded
  18622. * @param onError define a callback triggered when an error occurred during the loading session
  18623. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18624. * @returns the created texture
  18625. */
  18626. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18627. /**
  18628. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18629. * @param data Define the base64 payload without the data: prefix
  18630. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18631. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18632. * @param scene Define the scene the texture should belong to
  18633. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18634. * @param noMipmap Forces the texture to not create mip map information if true
  18635. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18636. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18637. * @param onLoad define a callback triggered when the texture has been loaded
  18638. * @param onError define a callback triggered when an error occurred during the loading session
  18639. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18640. * @returns the created texture
  18641. */
  18642. 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;
  18643. }
  18644. }
  18645. declare module "babylonjs/Materials/Textures/rawTexture" {
  18646. import { Scene } from "babylonjs/scene";
  18647. import { Texture } from "babylonjs/Materials/Textures/texture";
  18648. /**
  18649. * Raw texture can help creating a texture directly from an array of data.
  18650. * This can be super useful if you either get the data from an uncompressed source or
  18651. * if you wish to create your texture pixel by pixel.
  18652. */
  18653. export class RawTexture extends Texture {
  18654. /**
  18655. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18656. */
  18657. format: number;
  18658. private _engine;
  18659. /**
  18660. * Instantiates a new RawTexture.
  18661. * Raw texture can help creating a texture directly from an array of data.
  18662. * This can be super useful if you either get the data from an uncompressed source or
  18663. * if you wish to create your texture pixel by pixel.
  18664. * @param data define the array of data to use to create the texture
  18665. * @param width define the width of the texture
  18666. * @param height define the height of the texture
  18667. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18668. * @param scene define the scene the texture belongs to
  18669. * @param generateMipMaps define whether mip maps should be generated or not
  18670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18672. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18673. */
  18674. constructor(data: ArrayBufferView, width: number, height: number,
  18675. /**
  18676. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18677. */
  18678. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18679. /**
  18680. * Updates the texture underlying data.
  18681. * @param data Define the new data of the texture
  18682. */
  18683. update(data: ArrayBufferView): void;
  18684. /**
  18685. * Creates a luminance texture from some data.
  18686. * @param data Define the texture data
  18687. * @param width Define the width of the texture
  18688. * @param height Define the height of the texture
  18689. * @param scene Define the scene the texture belongs to
  18690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18693. * @returns the luminance texture
  18694. */
  18695. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18696. /**
  18697. * Creates a luminance alpha texture from some data.
  18698. * @param data Define the texture data
  18699. * @param width Define the width of the texture
  18700. * @param height Define the height of the texture
  18701. * @param scene Define the scene the texture belongs to
  18702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18705. * @returns the luminance alpha texture
  18706. */
  18707. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18708. /**
  18709. * Creates an alpha texture from some data.
  18710. * @param data Define the texture data
  18711. * @param width Define the width of the texture
  18712. * @param height Define the height of the texture
  18713. * @param scene Define the scene the texture belongs to
  18714. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18715. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18716. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18717. * @returns the alpha texture
  18718. */
  18719. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18720. /**
  18721. * Creates a RGB texture from some data.
  18722. * @param data Define the texture data
  18723. * @param width Define the width of the texture
  18724. * @param height Define the height of the texture
  18725. * @param scene Define the scene the texture belongs to
  18726. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18730. * @returns the RGB alpha texture
  18731. */
  18732. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18733. /**
  18734. * Creates a RGBA texture from some data.
  18735. * @param data Define the texture data
  18736. * @param width Define the width of the texture
  18737. * @param height Define the height of the texture
  18738. * @param scene Define the scene the texture belongs to
  18739. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18740. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18741. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18742. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18743. * @returns the RGBA texture
  18744. */
  18745. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18746. /**
  18747. * Creates a R texture from some data.
  18748. * @param data Define the texture data
  18749. * @param width Define the width of the texture
  18750. * @param height Define the height of the texture
  18751. * @param scene Define the scene the texture belongs to
  18752. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18755. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18756. * @returns the R texture
  18757. */
  18758. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18759. }
  18760. }
  18761. declare module "babylonjs/Animations/runtimeAnimation" {
  18762. import { Animation } from "babylonjs/Animations/animation";
  18763. import { Animatable } from "babylonjs/Animations/animatable";
  18764. import { Scene } from "babylonjs/scene";
  18765. /**
  18766. * Defines a runtime animation
  18767. */
  18768. export class RuntimeAnimation {
  18769. private _events;
  18770. /**
  18771. * The current frame of the runtime animation
  18772. */
  18773. private _currentFrame;
  18774. /**
  18775. * The animation used by the runtime animation
  18776. */
  18777. private _animation;
  18778. /**
  18779. * The target of the runtime animation
  18780. */
  18781. private _target;
  18782. /**
  18783. * The initiating animatable
  18784. */
  18785. private _host;
  18786. /**
  18787. * The original value of the runtime animation
  18788. */
  18789. private _originalValue;
  18790. /**
  18791. * The original blend value of the runtime animation
  18792. */
  18793. private _originalBlendValue;
  18794. /**
  18795. * The offsets cache of the runtime animation
  18796. */
  18797. private _offsetsCache;
  18798. /**
  18799. * The high limits cache of the runtime animation
  18800. */
  18801. private _highLimitsCache;
  18802. /**
  18803. * Specifies if the runtime animation has been stopped
  18804. */
  18805. private _stopped;
  18806. /**
  18807. * The blending factor of the runtime animation
  18808. */
  18809. private _blendingFactor;
  18810. /**
  18811. * The BabylonJS scene
  18812. */
  18813. private _scene;
  18814. /**
  18815. * The current value of the runtime animation
  18816. */
  18817. private _currentValue;
  18818. /** @hidden */
  18819. _workValue: any;
  18820. /**
  18821. * The active target of the runtime animation
  18822. */
  18823. private _activeTarget;
  18824. /**
  18825. * The target path of the runtime animation
  18826. */
  18827. private _targetPath;
  18828. /**
  18829. * The weight of the runtime animation
  18830. */
  18831. private _weight;
  18832. /**
  18833. * The ratio offset of the runtime animation
  18834. */
  18835. private _ratioOffset;
  18836. /**
  18837. * The previous delay of the runtime animation
  18838. */
  18839. private _previousDelay;
  18840. /**
  18841. * The previous ratio of the runtime animation
  18842. */
  18843. private _previousRatio;
  18844. /**
  18845. * Gets the current frame of the runtime animation
  18846. */
  18847. readonly currentFrame: number;
  18848. /**
  18849. * Gets the weight of the runtime animation
  18850. */
  18851. readonly weight: number;
  18852. /**
  18853. * Gets the current value of the runtime animation
  18854. */
  18855. readonly currentValue: any;
  18856. /**
  18857. * Gets the target path of the runtime animation
  18858. */
  18859. readonly targetPath: string;
  18860. /**
  18861. * Gets the actual target of the runtime animation
  18862. */
  18863. readonly target: any;
  18864. /**
  18865. * Create a new RuntimeAnimation object
  18866. * @param target defines the target of the animation
  18867. * @param animation defines the source animation object
  18868. * @param scene defines the hosting scene
  18869. * @param host defines the initiating Animatable
  18870. */
  18871. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18872. /**
  18873. * Gets the animation from the runtime animation
  18874. */
  18875. readonly animation: Animation;
  18876. /**
  18877. * Resets the runtime animation to the beginning
  18878. * @param restoreOriginal defines whether to restore the target property to the original value
  18879. */
  18880. reset(restoreOriginal?: boolean): void;
  18881. /**
  18882. * Specifies if the runtime animation is stopped
  18883. * @returns Boolean specifying if the runtime animation is stopped
  18884. */
  18885. isStopped(): boolean;
  18886. /**
  18887. * Disposes of the runtime animation
  18888. */
  18889. dispose(): void;
  18890. /**
  18891. * Interpolates the animation from the current frame
  18892. * @param currentFrame The frame to interpolate the animation to
  18893. * @param repeatCount The number of times that the animation should loop
  18894. * @param loopMode The type of looping mode to use
  18895. * @param offsetValue Animation offset value
  18896. * @param highLimitValue The high limit value
  18897. * @returns The interpolated value
  18898. */
  18899. private _interpolate;
  18900. /**
  18901. * Apply the interpolated value to the target
  18902. * @param currentValue defines the value computed by the animation
  18903. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18904. */
  18905. setValue(currentValue: any, weight?: number): void;
  18906. private _setValue;
  18907. /**
  18908. * Gets the loop pmode of the runtime animation
  18909. * @returns Loop Mode
  18910. */
  18911. private _getCorrectLoopMode;
  18912. /**
  18913. * Move the current animation to a given frame
  18914. * @param frame defines the frame to move to
  18915. */
  18916. goToFrame(frame: number): void;
  18917. /**
  18918. * @hidden Internal use only
  18919. */
  18920. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18921. /**
  18922. * Execute the current animation
  18923. * @param delay defines the delay to add to the current frame
  18924. * @param from defines the lower bound of the animation range
  18925. * @param to defines the upper bound of the animation range
  18926. * @param loop defines if the current animation must loop
  18927. * @param speedRatio defines the current speed ratio
  18928. * @param weight defines the weight of the animation (default is -1 so no weight)
  18929. * @param onLoop optional callback called when animation loops
  18930. * @returns a boolean indicating if the animation is running
  18931. */
  18932. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18933. }
  18934. }
  18935. declare module "babylonjs/Animations/animatable" {
  18936. import { Animation } from "babylonjs/Animations/animation";
  18937. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18938. import { Nullable } from "babylonjs/types";
  18939. import { Observable } from "babylonjs/Misc/observable";
  18940. import { Scene } from "babylonjs/scene";
  18941. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18942. import { Node } from "babylonjs/node";
  18943. /**
  18944. * Class used to store an actual running animation
  18945. */
  18946. export class Animatable {
  18947. /** defines the target object */
  18948. target: any;
  18949. /** defines the starting frame number (default is 0) */
  18950. fromFrame: number;
  18951. /** defines the ending frame number (default is 100) */
  18952. toFrame: number;
  18953. /** defines if the animation must loop (default is false) */
  18954. loopAnimation: boolean;
  18955. /** defines a callback to call when animation ends if it is not looping */
  18956. onAnimationEnd?: (() => void) | null | undefined;
  18957. /** defines a callback to call when animation loops */
  18958. onAnimationLoop?: (() => void) | null | undefined;
  18959. private _localDelayOffset;
  18960. private _pausedDelay;
  18961. private _runtimeAnimations;
  18962. private _paused;
  18963. private _scene;
  18964. private _speedRatio;
  18965. private _weight;
  18966. private _syncRoot;
  18967. /**
  18968. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18969. * This will only apply for non looping animation (default is true)
  18970. */
  18971. disposeOnEnd: boolean;
  18972. /**
  18973. * Gets a boolean indicating if the animation has started
  18974. */
  18975. animationStarted: boolean;
  18976. /**
  18977. * Observer raised when the animation ends
  18978. */
  18979. onAnimationEndObservable: Observable<Animatable>;
  18980. /**
  18981. * Observer raised when the animation loops
  18982. */
  18983. onAnimationLoopObservable: Observable<Animatable>;
  18984. /**
  18985. * Gets the root Animatable used to synchronize and normalize animations
  18986. */
  18987. readonly syncRoot: Animatable;
  18988. /**
  18989. * Gets the current frame of the first RuntimeAnimation
  18990. * Used to synchronize Animatables
  18991. */
  18992. readonly masterFrame: number;
  18993. /**
  18994. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18995. */
  18996. weight: number;
  18997. /**
  18998. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18999. */
  19000. speedRatio: number;
  19001. /**
  19002. * Creates a new Animatable
  19003. * @param scene defines the hosting scene
  19004. * @param target defines the target object
  19005. * @param fromFrame defines the starting frame number (default is 0)
  19006. * @param toFrame defines the ending frame number (default is 100)
  19007. * @param loopAnimation defines if the animation must loop (default is false)
  19008. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19009. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19010. * @param animations defines a group of animation to add to the new Animatable
  19011. * @param onAnimationLoop defines a callback to call when animation loops
  19012. */
  19013. constructor(scene: Scene,
  19014. /** defines the target object */
  19015. target: any,
  19016. /** defines the starting frame number (default is 0) */
  19017. fromFrame?: number,
  19018. /** defines the ending frame number (default is 100) */
  19019. toFrame?: number,
  19020. /** defines if the animation must loop (default is false) */
  19021. loopAnimation?: boolean, speedRatio?: number,
  19022. /** defines a callback to call when animation ends if it is not looping */
  19023. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19024. /** defines a callback to call when animation loops */
  19025. onAnimationLoop?: (() => void) | null | undefined);
  19026. /**
  19027. * Synchronize and normalize current Animatable with a source Animatable
  19028. * This is useful when using animation weights and when animations are not of the same length
  19029. * @param root defines the root Animatable to synchronize with
  19030. * @returns the current Animatable
  19031. */
  19032. syncWith(root: Animatable): Animatable;
  19033. /**
  19034. * Gets the list of runtime animations
  19035. * @returns an array of RuntimeAnimation
  19036. */
  19037. getAnimations(): RuntimeAnimation[];
  19038. /**
  19039. * Adds more animations to the current animatable
  19040. * @param target defines the target of the animations
  19041. * @param animations defines the new animations to add
  19042. */
  19043. appendAnimations(target: any, animations: Animation[]): void;
  19044. /**
  19045. * Gets the source animation for a specific property
  19046. * @param property defines the propertyu to look for
  19047. * @returns null or the source animation for the given property
  19048. */
  19049. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19050. /**
  19051. * Gets the runtime animation for a specific property
  19052. * @param property defines the propertyu to look for
  19053. * @returns null or the runtime animation for the given property
  19054. */
  19055. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19056. /**
  19057. * Resets the animatable to its original state
  19058. */
  19059. reset(): void;
  19060. /**
  19061. * Allows the animatable to blend with current running animations
  19062. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19063. * @param blendingSpeed defines the blending speed to use
  19064. */
  19065. enableBlending(blendingSpeed: number): void;
  19066. /**
  19067. * Disable animation blending
  19068. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19069. */
  19070. disableBlending(): void;
  19071. /**
  19072. * Jump directly to a given frame
  19073. * @param frame defines the frame to jump to
  19074. */
  19075. goToFrame(frame: number): void;
  19076. /**
  19077. * Pause the animation
  19078. */
  19079. pause(): void;
  19080. /**
  19081. * Restart the animation
  19082. */
  19083. restart(): void;
  19084. private _raiseOnAnimationEnd;
  19085. /**
  19086. * Stop and delete the current animation
  19087. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19088. * @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)
  19089. */
  19090. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19091. /**
  19092. * Wait asynchronously for the animation to end
  19093. * @returns a promise which will be fullfilled when the animation ends
  19094. */
  19095. waitAsync(): Promise<Animatable>;
  19096. /** @hidden */
  19097. _animate(delay: number): boolean;
  19098. }
  19099. module "babylonjs/scene" {
  19100. interface Scene {
  19101. /** @hidden */
  19102. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19103. /** @hidden */
  19104. _processLateAnimationBindingsForMatrices(holder: {
  19105. totalWeight: number;
  19106. animations: RuntimeAnimation[];
  19107. originalValue: Matrix;
  19108. }): any;
  19109. /** @hidden */
  19110. _processLateAnimationBindingsForQuaternions(holder: {
  19111. totalWeight: number;
  19112. animations: RuntimeAnimation[];
  19113. originalValue: Quaternion;
  19114. }, refQuaternion: Quaternion): Quaternion;
  19115. /** @hidden */
  19116. _processLateAnimationBindings(): void;
  19117. /**
  19118. * Will start the animation sequence of a given target
  19119. * @param target defines the target
  19120. * @param from defines from which frame should animation start
  19121. * @param to defines until which frame should animation run.
  19122. * @param weight defines the weight to apply to the animation (1.0 by default)
  19123. * @param loop defines if the animation loops
  19124. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19125. * @param onAnimationEnd defines the function to be executed when the animation ends
  19126. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19127. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19128. * @param onAnimationLoop defines the callback to call when an animation loops
  19129. * @returns the animatable object created for this animation
  19130. */
  19131. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19132. /**
  19133. * Will start the animation sequence of a given target
  19134. * @param target defines the target
  19135. * @param from defines from which frame should animation start
  19136. * @param to defines until which frame should animation run.
  19137. * @param loop defines if the animation loops
  19138. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19139. * @param onAnimationEnd defines the function to be executed when the animation ends
  19140. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19141. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19142. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19143. * @param onAnimationLoop defines the callback to call when an animation loops
  19144. * @returns the animatable object created for this animation
  19145. */
  19146. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19147. /**
  19148. * Will start the animation sequence of a given target and its hierarchy
  19149. * @param target defines the target
  19150. * @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.
  19151. * @param from defines from which frame should animation start
  19152. * @param to defines until which frame should animation run.
  19153. * @param loop defines if the animation loops
  19154. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19155. * @param onAnimationEnd defines the function to be executed when the animation ends
  19156. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19157. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19158. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19159. * @param onAnimationLoop defines the callback to call when an animation loops
  19160. * @returns the list of created animatables
  19161. */
  19162. 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[];
  19163. /**
  19164. * Begin a new animation on a given node
  19165. * @param target defines the target where the animation will take place
  19166. * @param animations defines the list of animations to start
  19167. * @param from defines the initial value
  19168. * @param to defines the final value
  19169. * @param loop defines if you want animation to loop (off by default)
  19170. * @param speedRatio defines the speed ratio to apply to all animations
  19171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19172. * @param onAnimationLoop defines the callback to call when an animation loops
  19173. * @returns the list of created animatables
  19174. */
  19175. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19176. /**
  19177. * Begin a new animation on a given node and its hierarchy
  19178. * @param target defines the root node where the animation will take place
  19179. * @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.
  19180. * @param animations defines the list of animations to start
  19181. * @param from defines the initial value
  19182. * @param to defines the final value
  19183. * @param loop defines if you want animation to loop (off by default)
  19184. * @param speedRatio defines the speed ratio to apply to all animations
  19185. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19186. * @param onAnimationLoop defines the callback to call when an animation loops
  19187. * @returns the list of animatables created for all nodes
  19188. */
  19189. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19190. /**
  19191. * Gets the animatable associated with a specific target
  19192. * @param target defines the target of the animatable
  19193. * @returns the required animatable if found
  19194. */
  19195. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19196. /**
  19197. * Gets all animatables associated with a given target
  19198. * @param target defines the target to look animatables for
  19199. * @returns an array of Animatables
  19200. */
  19201. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19202. /**
  19203. * Will stop the animation of the given target
  19204. * @param target - the target
  19205. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19206. * @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)
  19207. */
  19208. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19209. /**
  19210. * Stops and removes all animations that have been applied to the scene
  19211. */
  19212. stopAllAnimations(): void;
  19213. }
  19214. }
  19215. module "babylonjs/Bones/bone" {
  19216. interface Bone {
  19217. /**
  19218. * Copy an animation range from another bone
  19219. * @param source defines the source bone
  19220. * @param rangeName defines the range name to copy
  19221. * @param frameOffset defines the frame offset
  19222. * @param rescaleAsRequired defines if rescaling must be applied if required
  19223. * @param skelDimensionsRatio defines the scaling ratio
  19224. * @returns true if operation was successful
  19225. */
  19226. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19227. }
  19228. }
  19229. }
  19230. declare module "babylonjs/Bones/skeleton" {
  19231. import { Bone } from "babylonjs/Bones/bone";
  19232. import { IAnimatable } from "babylonjs/Misc/tools";
  19233. import { Observable } from "babylonjs/Misc/observable";
  19234. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19235. import { Scene } from "babylonjs/scene";
  19236. import { Nullable } from "babylonjs/types";
  19237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19238. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19239. import { Animatable } from "babylonjs/Animations/animatable";
  19240. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19241. import { Animation } from "babylonjs/Animations/animation";
  19242. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19243. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19244. /**
  19245. * Class used to handle skinning animations
  19246. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19247. */
  19248. export class Skeleton implements IAnimatable {
  19249. /** defines the skeleton name */
  19250. name: string;
  19251. /** defines the skeleton Id */
  19252. id: string;
  19253. /**
  19254. * Defines the list of child bones
  19255. */
  19256. bones: Bone[];
  19257. /**
  19258. * Defines an estimate of the dimension of the skeleton at rest
  19259. */
  19260. dimensionsAtRest: Vector3;
  19261. /**
  19262. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19263. */
  19264. needInitialSkinMatrix: boolean;
  19265. /**
  19266. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19267. */
  19268. overrideMesh: Nullable<AbstractMesh>;
  19269. /**
  19270. * Gets the list of animations attached to this skeleton
  19271. */
  19272. animations: Array<Animation>;
  19273. private _scene;
  19274. private _isDirty;
  19275. private _transformMatrices;
  19276. private _transformMatrixTexture;
  19277. private _meshesWithPoseMatrix;
  19278. private _animatables;
  19279. private _identity;
  19280. private _synchronizedWithMesh;
  19281. private _ranges;
  19282. private _lastAbsoluteTransformsUpdateId;
  19283. private _canUseTextureForBones;
  19284. private _uniqueId;
  19285. /** @hidden */
  19286. _numBonesWithLinkedTransformNode: number;
  19287. /**
  19288. * Specifies if the skeleton should be serialized
  19289. */
  19290. doNotSerialize: boolean;
  19291. private _useTextureToStoreBoneMatrices;
  19292. /**
  19293. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19294. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19295. */
  19296. useTextureToStoreBoneMatrices: boolean;
  19297. private _animationPropertiesOverride;
  19298. /**
  19299. * Gets or sets the animation properties override
  19300. */
  19301. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19302. /**
  19303. * List of inspectable custom properties (used by the Inspector)
  19304. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19305. */
  19306. inspectableCustomProperties: IInspectable[];
  19307. /**
  19308. * An observable triggered before computing the skeleton's matrices
  19309. */
  19310. onBeforeComputeObservable: Observable<Skeleton>;
  19311. /**
  19312. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19313. */
  19314. readonly isUsingTextureForMatrices: boolean;
  19315. /**
  19316. * Gets the unique ID of this skeleton
  19317. */
  19318. readonly uniqueId: number;
  19319. /**
  19320. * Creates a new skeleton
  19321. * @param name defines the skeleton name
  19322. * @param id defines the skeleton Id
  19323. * @param scene defines the hosting scene
  19324. */
  19325. constructor(
  19326. /** defines the skeleton name */
  19327. name: string,
  19328. /** defines the skeleton Id */
  19329. id: string, scene: Scene);
  19330. /**
  19331. * Gets the current object class name.
  19332. * @return the class name
  19333. */
  19334. getClassName(): string;
  19335. /**
  19336. * Returns an array containing the root bones
  19337. * @returns an array containing the root bones
  19338. */
  19339. getChildren(): Array<Bone>;
  19340. /**
  19341. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19342. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19343. * @returns a Float32Array containing matrices data
  19344. */
  19345. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19346. /**
  19347. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19348. * @returns a raw texture containing the data
  19349. */
  19350. getTransformMatrixTexture(): Nullable<RawTexture>;
  19351. /**
  19352. * Gets the current hosting scene
  19353. * @returns a scene object
  19354. */
  19355. getScene(): Scene;
  19356. /**
  19357. * Gets a string representing the current skeleton data
  19358. * @param fullDetails defines a boolean indicating if we want a verbose version
  19359. * @returns a string representing the current skeleton data
  19360. */
  19361. toString(fullDetails?: boolean): string;
  19362. /**
  19363. * Get bone's index searching by name
  19364. * @param name defines bone's name to search for
  19365. * @return the indice of the bone. Returns -1 if not found
  19366. */
  19367. getBoneIndexByName(name: string): number;
  19368. /**
  19369. * Creater a new animation range
  19370. * @param name defines the name of the range
  19371. * @param from defines the start key
  19372. * @param to defines the end key
  19373. */
  19374. createAnimationRange(name: string, from: number, to: number): void;
  19375. /**
  19376. * Delete a specific animation range
  19377. * @param name defines the name of the range
  19378. * @param deleteFrames defines if frames must be removed as well
  19379. */
  19380. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19381. /**
  19382. * Gets a specific animation range
  19383. * @param name defines the name of the range to look for
  19384. * @returns the requested animation range or null if not found
  19385. */
  19386. getAnimationRange(name: string): Nullable<AnimationRange>;
  19387. /**
  19388. * Gets the list of all animation ranges defined on this skeleton
  19389. * @returns an array
  19390. */
  19391. getAnimationRanges(): Nullable<AnimationRange>[];
  19392. /**
  19393. * Copy animation range from a source skeleton.
  19394. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19395. * @param source defines the source skeleton
  19396. * @param name defines the name of the range to copy
  19397. * @param rescaleAsRequired defines if rescaling must be applied if required
  19398. * @returns true if operation was successful
  19399. */
  19400. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19401. /**
  19402. * Forces the skeleton to go to rest pose
  19403. */
  19404. returnToRest(): void;
  19405. private _getHighestAnimationFrame;
  19406. /**
  19407. * Begin a specific animation range
  19408. * @param name defines the name of the range to start
  19409. * @param loop defines if looping must be turned on (false by default)
  19410. * @param speedRatio defines the speed ratio to apply (1 by default)
  19411. * @param onAnimationEnd defines a callback which will be called when animation will end
  19412. * @returns a new animatable
  19413. */
  19414. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19415. /** @hidden */
  19416. _markAsDirty(): void;
  19417. /** @hidden */
  19418. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19419. /** @hidden */
  19420. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19421. private _computeTransformMatrices;
  19422. /**
  19423. * Build all resources required to render a skeleton
  19424. */
  19425. prepare(): void;
  19426. /**
  19427. * Gets the list of animatables currently running for this skeleton
  19428. * @returns an array of animatables
  19429. */
  19430. getAnimatables(): IAnimatable[];
  19431. /**
  19432. * Clone the current skeleton
  19433. * @param name defines the name of the new skeleton
  19434. * @param id defines the id of the enw skeleton
  19435. * @returns the new skeleton
  19436. */
  19437. clone(name: string, id: string): Skeleton;
  19438. /**
  19439. * Enable animation blending for this skeleton
  19440. * @param blendingSpeed defines the blending speed to apply
  19441. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19442. */
  19443. enableBlending(blendingSpeed?: number): void;
  19444. /**
  19445. * Releases all resources associated with the current skeleton
  19446. */
  19447. dispose(): void;
  19448. /**
  19449. * Serialize the skeleton in a JSON object
  19450. * @returns a JSON object
  19451. */
  19452. serialize(): any;
  19453. /**
  19454. * Creates a new skeleton from serialized data
  19455. * @param parsedSkeleton defines the serialized data
  19456. * @param scene defines the hosting scene
  19457. * @returns a new skeleton
  19458. */
  19459. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19460. /**
  19461. * Compute all node absolute transforms
  19462. * @param forceUpdate defines if computation must be done even if cache is up to date
  19463. */
  19464. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19465. /**
  19466. * Gets the root pose matrix
  19467. * @returns a matrix
  19468. */
  19469. getPoseMatrix(): Nullable<Matrix>;
  19470. /**
  19471. * Sorts bones per internal index
  19472. */
  19473. sortBones(): void;
  19474. private _sortBones;
  19475. }
  19476. }
  19477. declare module "babylonjs/Morph/morphTarget" {
  19478. import { IAnimatable } from "babylonjs/Misc/tools";
  19479. import { Observable } from "babylonjs/Misc/observable";
  19480. import { Nullable, FloatArray } from "babylonjs/types";
  19481. import { Scene } from "babylonjs/scene";
  19482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19483. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19484. /**
  19485. * Defines a target to use with MorphTargetManager
  19486. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19487. */
  19488. export class MorphTarget implements IAnimatable {
  19489. /** defines the name of the target */
  19490. name: string;
  19491. /**
  19492. * Gets or sets the list of animations
  19493. */
  19494. animations: import("babylonjs/Animations/animation").Animation[];
  19495. private _scene;
  19496. private _positions;
  19497. private _normals;
  19498. private _tangents;
  19499. private _influence;
  19500. /**
  19501. * Observable raised when the influence changes
  19502. */
  19503. onInfluenceChanged: Observable<boolean>;
  19504. /** @hidden */
  19505. _onDataLayoutChanged: Observable<void>;
  19506. /**
  19507. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19508. */
  19509. influence: number;
  19510. /**
  19511. * Gets or sets the id of the morph Target
  19512. */
  19513. id: string;
  19514. private _animationPropertiesOverride;
  19515. /**
  19516. * Gets or sets the animation properties override
  19517. */
  19518. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19519. /**
  19520. * Creates a new MorphTarget
  19521. * @param name defines the name of the target
  19522. * @param influence defines the influence to use
  19523. * @param scene defines the scene the morphtarget belongs to
  19524. */
  19525. constructor(
  19526. /** defines the name of the target */
  19527. name: string, influence?: number, scene?: Nullable<Scene>);
  19528. /**
  19529. * Gets a boolean defining if the target contains position data
  19530. */
  19531. readonly hasPositions: boolean;
  19532. /**
  19533. * Gets a boolean defining if the target contains normal data
  19534. */
  19535. readonly hasNormals: boolean;
  19536. /**
  19537. * Gets a boolean defining if the target contains tangent data
  19538. */
  19539. readonly hasTangents: boolean;
  19540. /**
  19541. * Affects position data to this target
  19542. * @param data defines the position data to use
  19543. */
  19544. setPositions(data: Nullable<FloatArray>): void;
  19545. /**
  19546. * Gets the position data stored in this target
  19547. * @returns a FloatArray containing the position data (or null if not present)
  19548. */
  19549. getPositions(): Nullable<FloatArray>;
  19550. /**
  19551. * Affects normal data to this target
  19552. * @param data defines the normal data to use
  19553. */
  19554. setNormals(data: Nullable<FloatArray>): void;
  19555. /**
  19556. * Gets the normal data stored in this target
  19557. * @returns a FloatArray containing the normal data (or null if not present)
  19558. */
  19559. getNormals(): Nullable<FloatArray>;
  19560. /**
  19561. * Affects tangent data to this target
  19562. * @param data defines the tangent data to use
  19563. */
  19564. setTangents(data: Nullable<FloatArray>): void;
  19565. /**
  19566. * Gets the tangent data stored in this target
  19567. * @returns a FloatArray containing the tangent data (or null if not present)
  19568. */
  19569. getTangents(): Nullable<FloatArray>;
  19570. /**
  19571. * Serializes the current target into a Serialization object
  19572. * @returns the serialized object
  19573. */
  19574. serialize(): any;
  19575. /**
  19576. * Returns the string "MorphTarget"
  19577. * @returns "MorphTarget"
  19578. */
  19579. getClassName(): string;
  19580. /**
  19581. * Creates a new target from serialized data
  19582. * @param serializationObject defines the serialized data to use
  19583. * @returns a new MorphTarget
  19584. */
  19585. static Parse(serializationObject: any): MorphTarget;
  19586. /**
  19587. * Creates a MorphTarget from mesh data
  19588. * @param mesh defines the source mesh
  19589. * @param name defines the name to use for the new target
  19590. * @param influence defines the influence to attach to the target
  19591. * @returns a new MorphTarget
  19592. */
  19593. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19594. }
  19595. }
  19596. declare module "babylonjs/Morph/morphTargetManager" {
  19597. import { Nullable } from "babylonjs/types";
  19598. import { Scene } from "babylonjs/scene";
  19599. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19600. /**
  19601. * This class is used to deform meshes using morphing between different targets
  19602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19603. */
  19604. export class MorphTargetManager {
  19605. private _targets;
  19606. private _targetInfluenceChangedObservers;
  19607. private _targetDataLayoutChangedObservers;
  19608. private _activeTargets;
  19609. private _scene;
  19610. private _influences;
  19611. private _supportsNormals;
  19612. private _supportsTangents;
  19613. private _vertexCount;
  19614. private _uniqueId;
  19615. private _tempInfluences;
  19616. /**
  19617. * Creates a new MorphTargetManager
  19618. * @param scene defines the current scene
  19619. */
  19620. constructor(scene?: Nullable<Scene>);
  19621. /**
  19622. * Gets the unique ID of this manager
  19623. */
  19624. readonly uniqueId: number;
  19625. /**
  19626. * Gets the number of vertices handled by this manager
  19627. */
  19628. readonly vertexCount: number;
  19629. /**
  19630. * Gets a boolean indicating if this manager supports morphing of normals
  19631. */
  19632. readonly supportsNormals: boolean;
  19633. /**
  19634. * Gets a boolean indicating if this manager supports morphing of tangents
  19635. */
  19636. readonly supportsTangents: boolean;
  19637. /**
  19638. * Gets the number of targets stored in this manager
  19639. */
  19640. readonly numTargets: number;
  19641. /**
  19642. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19643. */
  19644. readonly numInfluencers: number;
  19645. /**
  19646. * Gets the list of influences (one per target)
  19647. */
  19648. readonly influences: Float32Array;
  19649. /**
  19650. * Gets the active target at specified index. An active target is a target with an influence > 0
  19651. * @param index defines the index to check
  19652. * @returns the requested target
  19653. */
  19654. getActiveTarget(index: number): MorphTarget;
  19655. /**
  19656. * Gets the target at specified index
  19657. * @param index defines the index to check
  19658. * @returns the requested target
  19659. */
  19660. getTarget(index: number): MorphTarget;
  19661. /**
  19662. * Add a new target to this manager
  19663. * @param target defines the target to add
  19664. */
  19665. addTarget(target: MorphTarget): void;
  19666. /**
  19667. * Removes a target from the manager
  19668. * @param target defines the target to remove
  19669. */
  19670. removeTarget(target: MorphTarget): void;
  19671. /**
  19672. * Serializes the current manager into a Serialization object
  19673. * @returns the serialized object
  19674. */
  19675. serialize(): any;
  19676. private _syncActiveTargets;
  19677. /**
  19678. * Syncrhonize the targets with all the meshes using this morph target manager
  19679. */
  19680. synchronize(): void;
  19681. /**
  19682. * Creates a new MorphTargetManager from serialized data
  19683. * @param serializationObject defines the serialized data
  19684. * @param scene defines the hosting scene
  19685. * @returns the new MorphTargetManager
  19686. */
  19687. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19688. }
  19689. }
  19690. declare module "babylonjs/Meshes/groundMesh" {
  19691. import { Scene } from "babylonjs/scene";
  19692. import { Vector3 } from "babylonjs/Maths/math";
  19693. import { Mesh } from "babylonjs/Meshes/mesh";
  19694. /**
  19695. * Mesh representing the gorund
  19696. */
  19697. export class GroundMesh extends Mesh {
  19698. /** If octree should be generated */
  19699. generateOctree: boolean;
  19700. private _heightQuads;
  19701. /** @hidden */
  19702. _subdivisionsX: number;
  19703. /** @hidden */
  19704. _subdivisionsY: number;
  19705. /** @hidden */
  19706. _width: number;
  19707. /** @hidden */
  19708. _height: number;
  19709. /** @hidden */
  19710. _minX: number;
  19711. /** @hidden */
  19712. _maxX: number;
  19713. /** @hidden */
  19714. _minZ: number;
  19715. /** @hidden */
  19716. _maxZ: number;
  19717. constructor(name: string, scene: Scene);
  19718. /**
  19719. * "GroundMesh"
  19720. * @returns "GroundMesh"
  19721. */
  19722. getClassName(): string;
  19723. /**
  19724. * The minimum of x and y subdivisions
  19725. */
  19726. readonly subdivisions: number;
  19727. /**
  19728. * X subdivisions
  19729. */
  19730. readonly subdivisionsX: number;
  19731. /**
  19732. * Y subdivisions
  19733. */
  19734. readonly subdivisionsY: number;
  19735. /**
  19736. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19737. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19738. * @param chunksCount the number of subdivisions for x and y
  19739. * @param octreeBlocksSize (Default: 32)
  19740. */
  19741. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19742. /**
  19743. * Returns a height (y) value in the Worl system :
  19744. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19745. * @param x x coordinate
  19746. * @param z z coordinate
  19747. * @returns the ground y position if (x, z) are outside the ground surface.
  19748. */
  19749. getHeightAtCoordinates(x: number, z: number): number;
  19750. /**
  19751. * Returns a normalized vector (Vector3) orthogonal to the ground
  19752. * at the ground coordinates (x, z) expressed in the World system.
  19753. * @param x x coordinate
  19754. * @param z z coordinate
  19755. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19756. */
  19757. getNormalAtCoordinates(x: number, z: number): Vector3;
  19758. /**
  19759. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19760. * at the ground coordinates (x, z) expressed in the World system.
  19761. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19762. * @param x x coordinate
  19763. * @param z z coordinate
  19764. * @param ref vector to store the result
  19765. * @returns the GroundMesh.
  19766. */
  19767. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19768. /**
  19769. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19770. * if the ground has been updated.
  19771. * This can be used in the render loop.
  19772. * @returns the GroundMesh.
  19773. */
  19774. updateCoordinateHeights(): GroundMesh;
  19775. private _getFacetAt;
  19776. private _initHeightQuads;
  19777. private _computeHeightQuads;
  19778. /**
  19779. * Serializes this ground mesh
  19780. * @param serializationObject object to write serialization to
  19781. */
  19782. serialize(serializationObject: any): void;
  19783. /**
  19784. * Parses a serialized ground mesh
  19785. * @param parsedMesh the serialized mesh
  19786. * @param scene the scene to create the ground mesh in
  19787. * @returns the created ground mesh
  19788. */
  19789. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19790. }
  19791. }
  19792. declare module "babylonjs/Physics/physicsJoint" {
  19793. import { Vector3 } from "babylonjs/Maths/math";
  19794. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19795. /**
  19796. * Interface for Physics-Joint data
  19797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19798. */
  19799. export interface PhysicsJointData {
  19800. /**
  19801. * The main pivot of the joint
  19802. */
  19803. mainPivot?: Vector3;
  19804. /**
  19805. * The connected pivot of the joint
  19806. */
  19807. connectedPivot?: Vector3;
  19808. /**
  19809. * The main axis of the joint
  19810. */
  19811. mainAxis?: Vector3;
  19812. /**
  19813. * The connected axis of the joint
  19814. */
  19815. connectedAxis?: Vector3;
  19816. /**
  19817. * The collision of the joint
  19818. */
  19819. collision?: boolean;
  19820. /**
  19821. * Native Oimo/Cannon/Energy data
  19822. */
  19823. nativeParams?: any;
  19824. }
  19825. /**
  19826. * This is a holder class for the physics joint created by the physics plugin
  19827. * It holds a set of functions to control the underlying joint
  19828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19829. */
  19830. export class PhysicsJoint {
  19831. /**
  19832. * The type of the physics joint
  19833. */
  19834. type: number;
  19835. /**
  19836. * The data for the physics joint
  19837. */
  19838. jointData: PhysicsJointData;
  19839. private _physicsJoint;
  19840. protected _physicsPlugin: IPhysicsEnginePlugin;
  19841. /**
  19842. * Initializes the physics joint
  19843. * @param type The type of the physics joint
  19844. * @param jointData The data for the physics joint
  19845. */
  19846. constructor(
  19847. /**
  19848. * The type of the physics joint
  19849. */
  19850. type: number,
  19851. /**
  19852. * The data for the physics joint
  19853. */
  19854. jointData: PhysicsJointData);
  19855. /**
  19856. * Gets the physics joint
  19857. */
  19858. /**
  19859. * Sets the physics joint
  19860. */
  19861. physicsJoint: any;
  19862. /**
  19863. * Sets the physics plugin
  19864. */
  19865. physicsPlugin: IPhysicsEnginePlugin;
  19866. /**
  19867. * Execute a function that is physics-plugin specific.
  19868. * @param {Function} func the function that will be executed.
  19869. * It accepts two parameters: the physics world and the physics joint
  19870. */
  19871. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19872. /**
  19873. * Distance-Joint type
  19874. */
  19875. static DistanceJoint: number;
  19876. /**
  19877. * Hinge-Joint type
  19878. */
  19879. static HingeJoint: number;
  19880. /**
  19881. * Ball-and-Socket joint type
  19882. */
  19883. static BallAndSocketJoint: number;
  19884. /**
  19885. * Wheel-Joint type
  19886. */
  19887. static WheelJoint: number;
  19888. /**
  19889. * Slider-Joint type
  19890. */
  19891. static SliderJoint: number;
  19892. /**
  19893. * Prismatic-Joint type
  19894. */
  19895. static PrismaticJoint: number;
  19896. /**
  19897. * Universal-Joint type
  19898. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19899. */
  19900. static UniversalJoint: number;
  19901. /**
  19902. * Hinge-Joint 2 type
  19903. */
  19904. static Hinge2Joint: number;
  19905. /**
  19906. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19907. */
  19908. static PointToPointJoint: number;
  19909. /**
  19910. * Spring-Joint type
  19911. */
  19912. static SpringJoint: number;
  19913. /**
  19914. * Lock-Joint type
  19915. */
  19916. static LockJoint: number;
  19917. }
  19918. /**
  19919. * A class representing a physics distance joint
  19920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19921. */
  19922. export class DistanceJoint extends PhysicsJoint {
  19923. /**
  19924. *
  19925. * @param jointData The data for the Distance-Joint
  19926. */
  19927. constructor(jointData: DistanceJointData);
  19928. /**
  19929. * Update the predefined distance.
  19930. * @param maxDistance The maximum preferred distance
  19931. * @param minDistance The minimum preferred distance
  19932. */
  19933. updateDistance(maxDistance: number, minDistance?: number): void;
  19934. }
  19935. /**
  19936. * Represents a Motor-Enabled Joint
  19937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19938. */
  19939. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19940. /**
  19941. * Initializes the Motor-Enabled Joint
  19942. * @param type The type of the joint
  19943. * @param jointData The physica joint data for the joint
  19944. */
  19945. constructor(type: number, jointData: PhysicsJointData);
  19946. /**
  19947. * Set the motor values.
  19948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19949. * @param force the force to apply
  19950. * @param maxForce max force for this motor.
  19951. */
  19952. setMotor(force?: number, maxForce?: number): void;
  19953. /**
  19954. * Set the motor's limits.
  19955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19956. * @param upperLimit The upper limit of the motor
  19957. * @param lowerLimit The lower limit of the motor
  19958. */
  19959. setLimit(upperLimit: number, lowerLimit?: number): void;
  19960. }
  19961. /**
  19962. * This class represents a single physics Hinge-Joint
  19963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19964. */
  19965. export class HingeJoint extends MotorEnabledJoint {
  19966. /**
  19967. * Initializes the Hinge-Joint
  19968. * @param jointData The joint data for the Hinge-Joint
  19969. */
  19970. constructor(jointData: PhysicsJointData);
  19971. /**
  19972. * Set the motor values.
  19973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19974. * @param {number} force the force to apply
  19975. * @param {number} maxForce max force for this motor.
  19976. */
  19977. setMotor(force?: number, maxForce?: number): void;
  19978. /**
  19979. * Set the motor's limits.
  19980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19981. * @param upperLimit The upper limit of the motor
  19982. * @param lowerLimit The lower limit of the motor
  19983. */
  19984. setLimit(upperLimit: number, lowerLimit?: number): void;
  19985. }
  19986. /**
  19987. * This class represents a dual hinge physics joint (same as wheel joint)
  19988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19989. */
  19990. export class Hinge2Joint extends MotorEnabledJoint {
  19991. /**
  19992. * Initializes the Hinge2-Joint
  19993. * @param jointData The joint data for the Hinge2-Joint
  19994. */
  19995. constructor(jointData: PhysicsJointData);
  19996. /**
  19997. * Set the motor values.
  19998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19999. * @param {number} targetSpeed the speed the motor is to reach
  20000. * @param {number} maxForce max force for this motor.
  20001. * @param {motorIndex} the motor's index, 0 or 1.
  20002. */
  20003. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20004. /**
  20005. * Set the motor limits.
  20006. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20007. * @param {number} upperLimit the upper limit
  20008. * @param {number} lowerLimit lower limit
  20009. * @param {motorIndex} the motor's index, 0 or 1.
  20010. */
  20011. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20012. }
  20013. /**
  20014. * Interface for a motor enabled joint
  20015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20016. */
  20017. export interface IMotorEnabledJoint {
  20018. /**
  20019. * Physics joint
  20020. */
  20021. physicsJoint: any;
  20022. /**
  20023. * Sets the motor of the motor-enabled joint
  20024. * @param force The force of the motor
  20025. * @param maxForce The maximum force of the motor
  20026. * @param motorIndex The index of the motor
  20027. */
  20028. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20029. /**
  20030. * Sets the limit of the motor
  20031. * @param upperLimit The upper limit of the motor
  20032. * @param lowerLimit The lower limit of the motor
  20033. * @param motorIndex The index of the motor
  20034. */
  20035. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20036. }
  20037. /**
  20038. * Joint data for a Distance-Joint
  20039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20040. */
  20041. export interface DistanceJointData extends PhysicsJointData {
  20042. /**
  20043. * Max distance the 2 joint objects can be apart
  20044. */
  20045. maxDistance: number;
  20046. }
  20047. /**
  20048. * Joint data from a spring joint
  20049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20050. */
  20051. export interface SpringJointData extends PhysicsJointData {
  20052. /**
  20053. * Length of the spring
  20054. */
  20055. length: number;
  20056. /**
  20057. * Stiffness of the spring
  20058. */
  20059. stiffness: number;
  20060. /**
  20061. * Damping of the spring
  20062. */
  20063. damping: number;
  20064. /** this callback will be called when applying the force to the impostors. */
  20065. forceApplicationCallback: () => void;
  20066. }
  20067. }
  20068. declare module "babylonjs/Physics/physicsRaycastResult" {
  20069. import { Vector3 } from "babylonjs/Maths/math";
  20070. /**
  20071. * Holds the data for the raycast result
  20072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20073. */
  20074. export class PhysicsRaycastResult {
  20075. private _hasHit;
  20076. private _hitDistance;
  20077. private _hitNormalWorld;
  20078. private _hitPointWorld;
  20079. private _rayFromWorld;
  20080. private _rayToWorld;
  20081. /**
  20082. * Gets if there was a hit
  20083. */
  20084. readonly hasHit: boolean;
  20085. /**
  20086. * Gets the distance from the hit
  20087. */
  20088. readonly hitDistance: number;
  20089. /**
  20090. * Gets the hit normal/direction in the world
  20091. */
  20092. readonly hitNormalWorld: Vector3;
  20093. /**
  20094. * Gets the hit point in the world
  20095. */
  20096. readonly hitPointWorld: Vector3;
  20097. /**
  20098. * Gets the ray "start point" of the ray in the world
  20099. */
  20100. readonly rayFromWorld: Vector3;
  20101. /**
  20102. * Gets the ray "end point" of the ray in the world
  20103. */
  20104. readonly rayToWorld: Vector3;
  20105. /**
  20106. * Sets the hit data (normal & point in world space)
  20107. * @param hitNormalWorld defines the normal in world space
  20108. * @param hitPointWorld defines the point in world space
  20109. */
  20110. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20111. /**
  20112. * Sets the distance from the start point to the hit point
  20113. * @param distance
  20114. */
  20115. setHitDistance(distance: number): void;
  20116. /**
  20117. * Calculates the distance manually
  20118. */
  20119. calculateHitDistance(): void;
  20120. /**
  20121. * Resets all the values to default
  20122. * @param from The from point on world space
  20123. * @param to The to point on world space
  20124. */
  20125. reset(from?: Vector3, to?: Vector3): void;
  20126. }
  20127. /**
  20128. * Interface for the size containing width and height
  20129. */
  20130. interface IXYZ {
  20131. /**
  20132. * X
  20133. */
  20134. x: number;
  20135. /**
  20136. * Y
  20137. */
  20138. y: number;
  20139. /**
  20140. * Z
  20141. */
  20142. z: number;
  20143. }
  20144. }
  20145. declare module "babylonjs/Physics/IPhysicsEngine" {
  20146. import { Nullable } from "babylonjs/types";
  20147. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20149. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20150. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20151. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20152. /**
  20153. * Interface used to describe a physics joint
  20154. */
  20155. export interface PhysicsImpostorJoint {
  20156. /** Defines the main impostor to which the joint is linked */
  20157. mainImpostor: PhysicsImpostor;
  20158. /** Defines the impostor that is connected to the main impostor using this joint */
  20159. connectedImpostor: PhysicsImpostor;
  20160. /** Defines the joint itself */
  20161. joint: PhysicsJoint;
  20162. }
  20163. /** @hidden */
  20164. export interface IPhysicsEnginePlugin {
  20165. world: any;
  20166. name: string;
  20167. setGravity(gravity: Vector3): void;
  20168. setTimeStep(timeStep: number): void;
  20169. getTimeStep(): number;
  20170. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20171. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20174. removePhysicsBody(impostor: PhysicsImpostor): void;
  20175. generateJoint(joint: PhysicsImpostorJoint): void;
  20176. removeJoint(joint: PhysicsImpostorJoint): void;
  20177. isSupported(): boolean;
  20178. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20179. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20180. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20181. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20182. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20183. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20184. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20185. getBodyMass(impostor: PhysicsImpostor): number;
  20186. getBodyFriction(impostor: PhysicsImpostor): number;
  20187. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20188. getBodyRestitution(impostor: PhysicsImpostor): number;
  20189. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20190. getBodyPressure?(impostor: PhysicsImpostor): number;
  20191. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20192. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20193. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20194. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20195. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20196. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20197. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20198. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20199. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20200. sleepBody(impostor: PhysicsImpostor): void;
  20201. wakeUpBody(impostor: PhysicsImpostor): void;
  20202. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20203. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20204. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20205. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20206. getRadius(impostor: PhysicsImpostor): number;
  20207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20208. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20209. dispose(): void;
  20210. }
  20211. /**
  20212. * Interface used to define a physics engine
  20213. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20214. */
  20215. export interface IPhysicsEngine {
  20216. /**
  20217. * Gets the gravity vector used by the simulation
  20218. */
  20219. gravity: Vector3;
  20220. /**
  20221. * Sets the gravity vector used by the simulation
  20222. * @param gravity defines the gravity vector to use
  20223. */
  20224. setGravity(gravity: Vector3): void;
  20225. /**
  20226. * Set the time step of the physics engine.
  20227. * Default is 1/60.
  20228. * To slow it down, enter 1/600 for example.
  20229. * To speed it up, 1/30
  20230. * @param newTimeStep the new timestep to apply to this world.
  20231. */
  20232. setTimeStep(newTimeStep: number): void;
  20233. /**
  20234. * Get the time step of the physics engine.
  20235. * @returns the current time step
  20236. */
  20237. getTimeStep(): number;
  20238. /**
  20239. * Release all resources
  20240. */
  20241. dispose(): void;
  20242. /**
  20243. * Gets the name of the current physics plugin
  20244. * @returns the name of the plugin
  20245. */
  20246. getPhysicsPluginName(): string;
  20247. /**
  20248. * Adding a new impostor for the impostor tracking.
  20249. * This will be done by the impostor itself.
  20250. * @param impostor the impostor to add
  20251. */
  20252. addImpostor(impostor: PhysicsImpostor): void;
  20253. /**
  20254. * Remove an impostor from the engine.
  20255. * This impostor and its mesh will not longer be updated by the physics engine.
  20256. * @param impostor the impostor to remove
  20257. */
  20258. removeImpostor(impostor: PhysicsImpostor): void;
  20259. /**
  20260. * Add a joint to the physics engine
  20261. * @param mainImpostor defines the main impostor to which the joint is added.
  20262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20263. * @param joint defines the joint that will connect both impostors.
  20264. */
  20265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20266. /**
  20267. * Removes a joint from the simulation
  20268. * @param mainImpostor defines the impostor used with the joint
  20269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20270. * @param joint defines the joint to remove
  20271. */
  20272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20273. /**
  20274. * Gets the current plugin used to run the simulation
  20275. * @returns current plugin
  20276. */
  20277. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20278. /**
  20279. * Gets the list of physic impostors
  20280. * @returns an array of PhysicsImpostor
  20281. */
  20282. getImpostors(): Array<PhysicsImpostor>;
  20283. /**
  20284. * Gets the impostor for a physics enabled object
  20285. * @param object defines the object impersonated by the impostor
  20286. * @returns the PhysicsImpostor or null if not found
  20287. */
  20288. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20289. /**
  20290. * Gets the impostor for a physics body object
  20291. * @param body defines physics body used by the impostor
  20292. * @returns the PhysicsImpostor or null if not found
  20293. */
  20294. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20295. /**
  20296. * Does a raycast in the physics world
  20297. * @param from when should the ray start?
  20298. * @param to when should the ray end?
  20299. * @returns PhysicsRaycastResult
  20300. */
  20301. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20302. /**
  20303. * Called by the scene. No need to call it.
  20304. * @param delta defines the timespam between frames
  20305. */
  20306. _step(delta: number): void;
  20307. }
  20308. }
  20309. declare module "babylonjs/Physics/physicsImpostor" {
  20310. import { Nullable, IndicesArray } from "babylonjs/types";
  20311. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20312. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20314. import { Scene } from "babylonjs/scene";
  20315. import { Bone } from "babylonjs/Bones/bone";
  20316. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20317. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20318. /**
  20319. * The interface for the physics imposter parameters
  20320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20321. */
  20322. export interface PhysicsImpostorParameters {
  20323. /**
  20324. * The mass of the physics imposter
  20325. */
  20326. mass: number;
  20327. /**
  20328. * The friction of the physics imposter
  20329. */
  20330. friction?: number;
  20331. /**
  20332. * The coefficient of restitution of the physics imposter
  20333. */
  20334. restitution?: number;
  20335. /**
  20336. * The native options of the physics imposter
  20337. */
  20338. nativeOptions?: any;
  20339. /**
  20340. * Specifies if the parent should be ignored
  20341. */
  20342. ignoreParent?: boolean;
  20343. /**
  20344. * Specifies if bi-directional transformations should be disabled
  20345. */
  20346. disableBidirectionalTransformation?: boolean;
  20347. /**
  20348. * The pressure inside the physics imposter, soft object only
  20349. */
  20350. pressure?: number;
  20351. /**
  20352. * The stiffness the physics imposter, soft object only
  20353. */
  20354. stiffness?: number;
  20355. /**
  20356. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20357. */
  20358. velocityIterations?: number;
  20359. /**
  20360. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20361. */
  20362. positionIterations?: number;
  20363. /**
  20364. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20365. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20366. * Add to fix multiple points
  20367. */
  20368. fixedPoints?: number;
  20369. /**
  20370. * The collision margin around a soft object
  20371. */
  20372. margin?: number;
  20373. /**
  20374. * The collision margin around a soft object
  20375. */
  20376. damping?: number;
  20377. /**
  20378. * The path for a rope based on an extrusion
  20379. */
  20380. path?: any;
  20381. /**
  20382. * The shape of an extrusion used for a rope based on an extrusion
  20383. */
  20384. shape?: any;
  20385. }
  20386. /**
  20387. * Interface for a physics-enabled object
  20388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20389. */
  20390. export interface IPhysicsEnabledObject {
  20391. /**
  20392. * The position of the physics-enabled object
  20393. */
  20394. position: Vector3;
  20395. /**
  20396. * The rotation of the physics-enabled object
  20397. */
  20398. rotationQuaternion: Nullable<Quaternion>;
  20399. /**
  20400. * The scale of the physics-enabled object
  20401. */
  20402. scaling: Vector3;
  20403. /**
  20404. * The rotation of the physics-enabled object
  20405. */
  20406. rotation?: Vector3;
  20407. /**
  20408. * The parent of the physics-enabled object
  20409. */
  20410. parent?: any;
  20411. /**
  20412. * The bounding info of the physics-enabled object
  20413. * @returns The bounding info of the physics-enabled object
  20414. */
  20415. getBoundingInfo(): BoundingInfo;
  20416. /**
  20417. * Computes the world matrix
  20418. * @param force Specifies if the world matrix should be computed by force
  20419. * @returns A world matrix
  20420. */
  20421. computeWorldMatrix(force: boolean): Matrix;
  20422. /**
  20423. * Gets the world matrix
  20424. * @returns A world matrix
  20425. */
  20426. getWorldMatrix?(): Matrix;
  20427. /**
  20428. * Gets the child meshes
  20429. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20430. * @returns An array of abstract meshes
  20431. */
  20432. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20433. /**
  20434. * Gets the vertex data
  20435. * @param kind The type of vertex data
  20436. * @returns A nullable array of numbers, or a float32 array
  20437. */
  20438. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20439. /**
  20440. * Gets the indices from the mesh
  20441. * @returns A nullable array of index arrays
  20442. */
  20443. getIndices?(): Nullable<IndicesArray>;
  20444. /**
  20445. * Gets the scene from the mesh
  20446. * @returns the indices array or null
  20447. */
  20448. getScene?(): Scene;
  20449. /**
  20450. * Gets the absolute position from the mesh
  20451. * @returns the absolute position
  20452. */
  20453. getAbsolutePosition(): Vector3;
  20454. /**
  20455. * Gets the absolute pivot point from the mesh
  20456. * @returns the absolute pivot point
  20457. */
  20458. getAbsolutePivotPoint(): Vector3;
  20459. /**
  20460. * Rotates the mesh
  20461. * @param axis The axis of rotation
  20462. * @param amount The amount of rotation
  20463. * @param space The space of the rotation
  20464. * @returns The rotation transform node
  20465. */
  20466. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20467. /**
  20468. * Translates the mesh
  20469. * @param axis The axis of translation
  20470. * @param distance The distance of translation
  20471. * @param space The space of the translation
  20472. * @returns The transform node
  20473. */
  20474. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20475. /**
  20476. * Sets the absolute position of the mesh
  20477. * @param absolutePosition The absolute position of the mesh
  20478. * @returns The transform node
  20479. */
  20480. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20481. /**
  20482. * Gets the class name of the mesh
  20483. * @returns The class name
  20484. */
  20485. getClassName(): string;
  20486. }
  20487. /**
  20488. * Represents a physics imposter
  20489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20490. */
  20491. export class PhysicsImpostor {
  20492. /**
  20493. * The physics-enabled object used as the physics imposter
  20494. */
  20495. object: IPhysicsEnabledObject;
  20496. /**
  20497. * The type of the physics imposter
  20498. */
  20499. type: number;
  20500. private _options;
  20501. private _scene?;
  20502. /**
  20503. * The default object size of the imposter
  20504. */
  20505. static DEFAULT_OBJECT_SIZE: Vector3;
  20506. /**
  20507. * The identity quaternion of the imposter
  20508. */
  20509. static IDENTITY_QUATERNION: Quaternion;
  20510. /** @hidden */
  20511. _pluginData: any;
  20512. private _physicsEngine;
  20513. private _physicsBody;
  20514. private _bodyUpdateRequired;
  20515. private _onBeforePhysicsStepCallbacks;
  20516. private _onAfterPhysicsStepCallbacks;
  20517. /** @hidden */
  20518. _onPhysicsCollideCallbacks: Array<{
  20519. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20520. otherImpostors: Array<PhysicsImpostor>;
  20521. }>;
  20522. private _deltaPosition;
  20523. private _deltaRotation;
  20524. private _deltaRotationConjugated;
  20525. /** hidden */
  20526. _isFromLine: boolean;
  20527. private _parent;
  20528. private _isDisposed;
  20529. private static _tmpVecs;
  20530. private static _tmpQuat;
  20531. /**
  20532. * Specifies if the physics imposter is disposed
  20533. */
  20534. readonly isDisposed: boolean;
  20535. /**
  20536. * Gets the mass of the physics imposter
  20537. */
  20538. mass: number;
  20539. /**
  20540. * Gets the coefficient of friction
  20541. */
  20542. /**
  20543. * Sets the coefficient of friction
  20544. */
  20545. friction: number;
  20546. /**
  20547. * Gets the coefficient of restitution
  20548. */
  20549. /**
  20550. * Sets the coefficient of restitution
  20551. */
  20552. restitution: number;
  20553. /**
  20554. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20555. */
  20556. /**
  20557. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20558. */
  20559. pressure: number;
  20560. /**
  20561. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20562. */
  20563. /**
  20564. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20565. */
  20566. stiffness: number;
  20567. /**
  20568. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20569. */
  20570. /**
  20571. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20572. */
  20573. velocityIterations: number;
  20574. /**
  20575. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20576. */
  20577. /**
  20578. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20579. */
  20580. positionIterations: number;
  20581. /**
  20582. * The unique id of the physics imposter
  20583. * set by the physics engine when adding this impostor to the array
  20584. */
  20585. uniqueId: number;
  20586. /**
  20587. * @hidden
  20588. */
  20589. soft: boolean;
  20590. /**
  20591. * @hidden
  20592. */
  20593. segments: number;
  20594. private _joints;
  20595. /**
  20596. * Initializes the physics imposter
  20597. * @param object The physics-enabled object used as the physics imposter
  20598. * @param type The type of the physics imposter
  20599. * @param _options The options for the physics imposter
  20600. * @param _scene The Babylon scene
  20601. */
  20602. constructor(
  20603. /**
  20604. * The physics-enabled object used as the physics imposter
  20605. */
  20606. object: IPhysicsEnabledObject,
  20607. /**
  20608. * The type of the physics imposter
  20609. */
  20610. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20611. /**
  20612. * This function will completly initialize this impostor.
  20613. * It will create a new body - but only if this mesh has no parent.
  20614. * If it has, this impostor will not be used other than to define the impostor
  20615. * of the child mesh.
  20616. * @hidden
  20617. */
  20618. _init(): void;
  20619. private _getPhysicsParent;
  20620. /**
  20621. * Should a new body be generated.
  20622. * @returns boolean specifying if body initialization is required
  20623. */
  20624. isBodyInitRequired(): boolean;
  20625. /**
  20626. * Sets the updated scaling
  20627. * @param updated Specifies if the scaling is updated
  20628. */
  20629. setScalingUpdated(): void;
  20630. /**
  20631. * Force a regeneration of this or the parent's impostor's body.
  20632. * Use under cautious - This will remove all joints already implemented.
  20633. */
  20634. forceUpdate(): void;
  20635. /**
  20636. * Gets the body that holds this impostor. Either its own, or its parent.
  20637. */
  20638. /**
  20639. * Set the physics body. Used mainly by the physics engine/plugin
  20640. */
  20641. physicsBody: any;
  20642. /**
  20643. * Get the parent of the physics imposter
  20644. * @returns Physics imposter or null
  20645. */
  20646. /**
  20647. * Sets the parent of the physics imposter
  20648. */
  20649. parent: Nullable<PhysicsImpostor>;
  20650. /**
  20651. * Resets the update flags
  20652. */
  20653. resetUpdateFlags(): void;
  20654. /**
  20655. * Gets the object extend size
  20656. * @returns the object extend size
  20657. */
  20658. getObjectExtendSize(): Vector3;
  20659. /**
  20660. * Gets the object center
  20661. * @returns The object center
  20662. */
  20663. getObjectCenter(): Vector3;
  20664. /**
  20665. * Get a specific parametes from the options parameter
  20666. * @param paramName The object parameter name
  20667. * @returns The object parameter
  20668. */
  20669. getParam(paramName: string): any;
  20670. /**
  20671. * Sets a specific parameter in the options given to the physics plugin
  20672. * @param paramName The parameter name
  20673. * @param value The value of the parameter
  20674. */
  20675. setParam(paramName: string, value: number): void;
  20676. /**
  20677. * Specifically change the body's mass option. Won't recreate the physics body object
  20678. * @param mass The mass of the physics imposter
  20679. */
  20680. setMass(mass: number): void;
  20681. /**
  20682. * Gets the linear velocity
  20683. * @returns linear velocity or null
  20684. */
  20685. getLinearVelocity(): Nullable<Vector3>;
  20686. /**
  20687. * Sets the linear velocity
  20688. * @param velocity linear velocity or null
  20689. */
  20690. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20691. /**
  20692. * Gets the angular velocity
  20693. * @returns angular velocity or null
  20694. */
  20695. getAngularVelocity(): Nullable<Vector3>;
  20696. /**
  20697. * Sets the angular velocity
  20698. * @param velocity The velocity or null
  20699. */
  20700. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20701. /**
  20702. * Execute a function with the physics plugin native code
  20703. * Provide a function the will have two variables - the world object and the physics body object
  20704. * @param func The function to execute with the physics plugin native code
  20705. */
  20706. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20707. /**
  20708. * Register a function that will be executed before the physics world is stepping forward
  20709. * @param func The function to execute before the physics world is stepped forward
  20710. */
  20711. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20712. /**
  20713. * Unregister a function that will be executed before the physics world is stepping forward
  20714. * @param func The function to execute before the physics world is stepped forward
  20715. */
  20716. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20717. /**
  20718. * Register a function that will be executed after the physics step
  20719. * @param func The function to execute after physics step
  20720. */
  20721. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20722. /**
  20723. * Unregisters a function that will be executed after the physics step
  20724. * @param func The function to execute after physics step
  20725. */
  20726. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20727. /**
  20728. * register a function that will be executed when this impostor collides against a different body
  20729. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20730. * @param func Callback that is executed on collision
  20731. */
  20732. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20733. /**
  20734. * Unregisters the physics imposter on contact
  20735. * @param collideAgainst The physics object to collide against
  20736. * @param func Callback to execute on collision
  20737. */
  20738. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20739. private _tmpQuat;
  20740. private _tmpQuat2;
  20741. /**
  20742. * Get the parent rotation
  20743. * @returns The parent rotation
  20744. */
  20745. getParentsRotation(): Quaternion;
  20746. /**
  20747. * this function is executed by the physics engine.
  20748. */
  20749. beforeStep: () => void;
  20750. /**
  20751. * this function is executed by the physics engine
  20752. */
  20753. afterStep: () => void;
  20754. /**
  20755. * Legacy collision detection event support
  20756. */
  20757. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20758. /**
  20759. * event and body object due to cannon's event-based architecture.
  20760. */
  20761. onCollide: (e: {
  20762. body: any;
  20763. }) => void;
  20764. /**
  20765. * Apply a force
  20766. * @param force The force to apply
  20767. * @param contactPoint The contact point for the force
  20768. * @returns The physics imposter
  20769. */
  20770. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20771. /**
  20772. * Apply an impulse
  20773. * @param force The impulse force
  20774. * @param contactPoint The contact point for the impulse force
  20775. * @returns The physics imposter
  20776. */
  20777. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20778. /**
  20779. * A help function to create a joint
  20780. * @param otherImpostor A physics imposter used to create a joint
  20781. * @param jointType The type of joint
  20782. * @param jointData The data for the joint
  20783. * @returns The physics imposter
  20784. */
  20785. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20786. /**
  20787. * Add a joint to this impostor with a different impostor
  20788. * @param otherImpostor A physics imposter used to add a joint
  20789. * @param joint The joint to add
  20790. * @returns The physics imposter
  20791. */
  20792. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20793. /**
  20794. * Add an anchor to a cloth impostor
  20795. * @param otherImpostor rigid impostor to anchor to
  20796. * @param width ratio across width from 0 to 1
  20797. * @param height ratio up height from 0 to 1
  20798. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20799. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20800. * @returns impostor the soft imposter
  20801. */
  20802. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20803. /**
  20804. * Add a hook to a rope impostor
  20805. * @param otherImpostor rigid impostor to anchor to
  20806. * @param length ratio across rope from 0 to 1
  20807. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20808. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20809. * @returns impostor the rope imposter
  20810. */
  20811. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20812. /**
  20813. * Will keep this body still, in a sleep mode.
  20814. * @returns the physics imposter
  20815. */
  20816. sleep(): PhysicsImpostor;
  20817. /**
  20818. * Wake the body up.
  20819. * @returns The physics imposter
  20820. */
  20821. wakeUp(): PhysicsImpostor;
  20822. /**
  20823. * Clones the physics imposter
  20824. * @param newObject The physics imposter clones to this physics-enabled object
  20825. * @returns A nullable physics imposter
  20826. */
  20827. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20828. /**
  20829. * Disposes the physics imposter
  20830. */
  20831. dispose(): void;
  20832. /**
  20833. * Sets the delta position
  20834. * @param position The delta position amount
  20835. */
  20836. setDeltaPosition(position: Vector3): void;
  20837. /**
  20838. * Sets the delta rotation
  20839. * @param rotation The delta rotation amount
  20840. */
  20841. setDeltaRotation(rotation: Quaternion): void;
  20842. /**
  20843. * Gets the box size of the physics imposter and stores the result in the input parameter
  20844. * @param result Stores the box size
  20845. * @returns The physics imposter
  20846. */
  20847. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20848. /**
  20849. * Gets the radius of the physics imposter
  20850. * @returns Radius of the physics imposter
  20851. */
  20852. getRadius(): number;
  20853. /**
  20854. * Sync a bone with this impostor
  20855. * @param bone The bone to sync to the impostor.
  20856. * @param boneMesh The mesh that the bone is influencing.
  20857. * @param jointPivot The pivot of the joint / bone in local space.
  20858. * @param distToJoint Optional distance from the impostor to the joint.
  20859. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20860. */
  20861. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20862. /**
  20863. * Sync impostor to a bone
  20864. * @param bone The bone that the impostor will be synced to.
  20865. * @param boneMesh The mesh that the bone is influencing.
  20866. * @param jointPivot The pivot of the joint / bone in local space.
  20867. * @param distToJoint Optional distance from the impostor to the joint.
  20868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20869. * @param boneAxis Optional vector3 axis the bone is aligned with
  20870. */
  20871. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20872. /**
  20873. * No-Imposter type
  20874. */
  20875. static NoImpostor: number;
  20876. /**
  20877. * Sphere-Imposter type
  20878. */
  20879. static SphereImpostor: number;
  20880. /**
  20881. * Box-Imposter type
  20882. */
  20883. static BoxImpostor: number;
  20884. /**
  20885. * Plane-Imposter type
  20886. */
  20887. static PlaneImpostor: number;
  20888. /**
  20889. * Mesh-imposter type
  20890. */
  20891. static MeshImpostor: number;
  20892. /**
  20893. * Cylinder-Imposter type
  20894. */
  20895. static CylinderImpostor: number;
  20896. /**
  20897. * Particle-Imposter type
  20898. */
  20899. static ParticleImpostor: number;
  20900. /**
  20901. * Heightmap-Imposter type
  20902. */
  20903. static HeightmapImpostor: number;
  20904. /**
  20905. * ConvexHull-Impostor type (Ammo.js plugin only)
  20906. */
  20907. static ConvexHullImpostor: number;
  20908. /**
  20909. * Rope-Imposter type
  20910. */
  20911. static RopeImpostor: number;
  20912. /**
  20913. * Cloth-Imposter type
  20914. */
  20915. static ClothImpostor: number;
  20916. /**
  20917. * Softbody-Imposter type
  20918. */
  20919. static SoftbodyImpostor: number;
  20920. }
  20921. }
  20922. declare module "babylonjs/Meshes/mesh" {
  20923. import { Observable } from "babylonjs/Misc/observable";
  20924. import { IAnimatable } from "babylonjs/Misc/tools";
  20925. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20926. import { Camera } from "babylonjs/Cameras/camera";
  20927. import { Scene } from "babylonjs/scene";
  20928. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20929. import { Engine } from "babylonjs/Engines/engine";
  20930. import { Node } from "babylonjs/node";
  20931. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20932. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20933. import { Buffer } from "babylonjs/Meshes/buffer";
  20934. import { Geometry } from "babylonjs/Meshes/geometry";
  20935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20937. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20938. import { Effect } from "babylonjs/Materials/effect";
  20939. import { Material } from "babylonjs/Materials/material";
  20940. import { Skeleton } from "babylonjs/Bones/skeleton";
  20941. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20942. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20943. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20944. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20945. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20946. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20947. /**
  20948. * Class used to represent a specific level of detail of a mesh
  20949. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20950. */
  20951. export class MeshLODLevel {
  20952. /** Defines the distance where this level should star being displayed */
  20953. distance: number;
  20954. /** Defines the mesh to use to render this level */
  20955. mesh: Nullable<Mesh>;
  20956. /**
  20957. * Creates a new LOD level
  20958. * @param distance defines the distance where this level should star being displayed
  20959. * @param mesh defines the mesh to use to render this level
  20960. */
  20961. constructor(
  20962. /** Defines the distance where this level should star being displayed */
  20963. distance: number,
  20964. /** Defines the mesh to use to render this level */
  20965. mesh: Nullable<Mesh>);
  20966. }
  20967. /**
  20968. * @hidden
  20969. **/
  20970. export class _CreationDataStorage {
  20971. closePath?: boolean;
  20972. closeArray?: boolean;
  20973. idx: number[];
  20974. dashSize: number;
  20975. gapSize: number;
  20976. path3D: Path3D;
  20977. pathArray: Vector3[][];
  20978. arc: number;
  20979. radius: number;
  20980. cap: number;
  20981. tessellation: number;
  20982. }
  20983. /**
  20984. * @hidden
  20985. **/
  20986. class _InstanceDataStorage {
  20987. visibleInstances: any;
  20988. renderIdForInstances: number[];
  20989. batchCache: _InstancesBatch;
  20990. instancesBufferSize: number;
  20991. instancesBuffer: Nullable<Buffer>;
  20992. instancesData: Float32Array;
  20993. overridenInstanceCount: number;
  20994. }
  20995. /**
  20996. * @hidden
  20997. **/
  20998. export class _InstancesBatch {
  20999. mustReturn: boolean;
  21000. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21001. renderSelf: boolean[];
  21002. }
  21003. /**
  21004. * Class used to represent renderable models
  21005. */
  21006. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21007. /**
  21008. * Mesh side orientation : usually the external or front surface
  21009. */
  21010. static readonly FRONTSIDE: number;
  21011. /**
  21012. * Mesh side orientation : usually the internal or back surface
  21013. */
  21014. static readonly BACKSIDE: number;
  21015. /**
  21016. * Mesh side orientation : both internal and external or front and back surfaces
  21017. */
  21018. static readonly DOUBLESIDE: number;
  21019. /**
  21020. * Mesh side orientation : by default, `FRONTSIDE`
  21021. */
  21022. static readonly DEFAULTSIDE: number;
  21023. /**
  21024. * Mesh cap setting : no cap
  21025. */
  21026. static readonly NO_CAP: number;
  21027. /**
  21028. * Mesh cap setting : one cap at the beginning of the mesh
  21029. */
  21030. static readonly CAP_START: number;
  21031. /**
  21032. * Mesh cap setting : one cap at the end of the mesh
  21033. */
  21034. static readonly CAP_END: number;
  21035. /**
  21036. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21037. */
  21038. static readonly CAP_ALL: number;
  21039. /**
  21040. * Gets the default side orientation.
  21041. * @param orientation the orientation to value to attempt to get
  21042. * @returns the default orientation
  21043. * @hidden
  21044. */
  21045. static _GetDefaultSideOrientation(orientation?: number): number;
  21046. private _onBeforeRenderObservable;
  21047. private _onBeforeBindObservable;
  21048. private _onAfterRenderObservable;
  21049. private _onBeforeDrawObservable;
  21050. /**
  21051. * An event triggered before rendering the mesh
  21052. */
  21053. readonly onBeforeRenderObservable: Observable<Mesh>;
  21054. /**
  21055. * An event triggered before binding the mesh
  21056. */
  21057. readonly onBeforeBindObservable: Observable<Mesh>;
  21058. /**
  21059. * An event triggered after rendering the mesh
  21060. */
  21061. readonly onAfterRenderObservable: Observable<Mesh>;
  21062. /**
  21063. * An event triggered before drawing the mesh
  21064. */
  21065. readonly onBeforeDrawObservable: Observable<Mesh>;
  21066. private _onBeforeDrawObserver;
  21067. /**
  21068. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21069. */
  21070. onBeforeDraw: () => void;
  21071. /**
  21072. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21073. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21074. */
  21075. delayLoadState: number;
  21076. /**
  21077. * Gets the list of instances created from this mesh
  21078. * it is not supposed to be modified manually.
  21079. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21080. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21081. */
  21082. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21083. /**
  21084. * Gets the file containing delay loading data for this mesh
  21085. */
  21086. delayLoadingFile: string;
  21087. /** @hidden */
  21088. _binaryInfo: any;
  21089. private _LODLevels;
  21090. /**
  21091. * User defined function used to change how LOD level selection is done
  21092. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21093. */
  21094. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21095. private _morphTargetManager;
  21096. /**
  21097. * Gets or sets the morph target manager
  21098. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21099. */
  21100. morphTargetManager: Nullable<MorphTargetManager>;
  21101. /** @hidden */
  21102. _creationDataStorage: Nullable<_CreationDataStorage>;
  21103. /** @hidden */
  21104. _geometry: Nullable<Geometry>;
  21105. /** @hidden */
  21106. _delayInfo: Array<string>;
  21107. /** @hidden */
  21108. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21109. /** @hidden */
  21110. _instanceDataStorage: _InstanceDataStorage;
  21111. private _effectiveMaterial;
  21112. /** @hidden */
  21113. _shouldGenerateFlatShading: boolean;
  21114. private _preActivateId;
  21115. /** @hidden */
  21116. _originalBuilderSideOrientation: number;
  21117. /**
  21118. * Use this property to change the original side orientation defined at construction time
  21119. */
  21120. overrideMaterialSideOrientation: Nullable<number>;
  21121. private _areNormalsFrozen;
  21122. private _sourcePositions;
  21123. private _sourceNormals;
  21124. private _source;
  21125. private meshMap;
  21126. /**
  21127. * Gets the source mesh (the one used to clone this one from)
  21128. */
  21129. readonly source: Nullable<Mesh>;
  21130. /**
  21131. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21132. */
  21133. isUnIndexed: boolean;
  21134. /**
  21135. * @constructor
  21136. * @param name The value used by scene.getMeshByName() to do a lookup.
  21137. * @param scene The scene to add this mesh to.
  21138. * @param parent The parent of this mesh, if it has one
  21139. * @param source An optional Mesh from which geometry is shared, cloned.
  21140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21141. * When false, achieved by calling a clone(), also passing False.
  21142. * This will make creation of children, recursive.
  21143. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21144. */
  21145. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21146. /**
  21147. * Gets the class name
  21148. * @returns the string "Mesh".
  21149. */
  21150. getClassName(): string;
  21151. /** @hidden */
  21152. readonly _isMesh: boolean;
  21153. /**
  21154. * Returns a description of this mesh
  21155. * @param fullDetails define if full details about this mesh must be used
  21156. * @returns a descriptive string representing this mesh
  21157. */
  21158. toString(fullDetails?: boolean): string;
  21159. /** @hidden */
  21160. _unBindEffect(): void;
  21161. /**
  21162. * Gets a boolean indicating if this mesh has LOD
  21163. */
  21164. readonly hasLODLevels: boolean;
  21165. /**
  21166. * Gets the list of MeshLODLevel associated with the current mesh
  21167. * @returns an array of MeshLODLevel
  21168. */
  21169. getLODLevels(): MeshLODLevel[];
  21170. private _sortLODLevels;
  21171. /**
  21172. * Add a mesh as LOD level triggered at the given distance.
  21173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21174. * @param distance The distance from the center of the object to show this level
  21175. * @param mesh The mesh to be added as LOD level (can be null)
  21176. * @return This mesh (for chaining)
  21177. */
  21178. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21179. /**
  21180. * Returns the LOD level mesh at the passed distance or null if not found.
  21181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21182. * @param distance The distance from the center of the object to show this level
  21183. * @returns a Mesh or `null`
  21184. */
  21185. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21186. /**
  21187. * Remove a mesh from the LOD array
  21188. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21189. * @param mesh defines the mesh to be removed
  21190. * @return This mesh (for chaining)
  21191. */
  21192. removeLODLevel(mesh: Mesh): Mesh;
  21193. /**
  21194. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21195. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21196. * @param camera defines the camera to use to compute distance
  21197. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21198. * @return This mesh (for chaining)
  21199. */
  21200. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21201. /**
  21202. * Gets the mesh internal Geometry object
  21203. */
  21204. readonly geometry: Nullable<Geometry>;
  21205. /**
  21206. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21207. * @returns the total number of vertices
  21208. */
  21209. getTotalVertices(): number;
  21210. /**
  21211. * Returns the content of an associated vertex buffer
  21212. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21213. * - VertexBuffer.PositionKind
  21214. * - VertexBuffer.UVKind
  21215. * - VertexBuffer.UV2Kind
  21216. * - VertexBuffer.UV3Kind
  21217. * - VertexBuffer.UV4Kind
  21218. * - VertexBuffer.UV5Kind
  21219. * - VertexBuffer.UV6Kind
  21220. * - VertexBuffer.ColorKind
  21221. * - VertexBuffer.MatricesIndicesKind
  21222. * - VertexBuffer.MatricesIndicesExtraKind
  21223. * - VertexBuffer.MatricesWeightsKind
  21224. * - VertexBuffer.MatricesWeightsExtraKind
  21225. * @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
  21226. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21227. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21228. */
  21229. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21230. /**
  21231. * Returns the mesh VertexBuffer object from the requested `kind`
  21232. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21233. * - VertexBuffer.PositionKind
  21234. * - VertexBuffer.UVKind
  21235. * - VertexBuffer.UV2Kind
  21236. * - VertexBuffer.UV3Kind
  21237. * - VertexBuffer.UV4Kind
  21238. * - VertexBuffer.UV5Kind
  21239. * - VertexBuffer.UV6Kind
  21240. * - VertexBuffer.ColorKind
  21241. * - VertexBuffer.MatricesIndicesKind
  21242. * - VertexBuffer.MatricesIndicesExtraKind
  21243. * - VertexBuffer.MatricesWeightsKind
  21244. * - VertexBuffer.MatricesWeightsExtraKind
  21245. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21246. */
  21247. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21248. /**
  21249. * Tests if a specific vertex buffer is associated with this mesh
  21250. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21251. * - VertexBuffer.PositionKind
  21252. * - VertexBuffer.UVKind
  21253. * - VertexBuffer.UV2Kind
  21254. * - VertexBuffer.UV3Kind
  21255. * - VertexBuffer.UV4Kind
  21256. * - VertexBuffer.UV5Kind
  21257. * - VertexBuffer.UV6Kind
  21258. * - VertexBuffer.ColorKind
  21259. * - VertexBuffer.MatricesIndicesKind
  21260. * - VertexBuffer.MatricesIndicesExtraKind
  21261. * - VertexBuffer.MatricesWeightsKind
  21262. * - VertexBuffer.MatricesWeightsExtraKind
  21263. * @returns a boolean
  21264. */
  21265. isVerticesDataPresent(kind: string): boolean;
  21266. /**
  21267. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21268. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21269. * - VertexBuffer.PositionKind
  21270. * - VertexBuffer.UVKind
  21271. * - VertexBuffer.UV2Kind
  21272. * - VertexBuffer.UV3Kind
  21273. * - VertexBuffer.UV4Kind
  21274. * - VertexBuffer.UV5Kind
  21275. * - VertexBuffer.UV6Kind
  21276. * - VertexBuffer.ColorKind
  21277. * - VertexBuffer.MatricesIndicesKind
  21278. * - VertexBuffer.MatricesIndicesExtraKind
  21279. * - VertexBuffer.MatricesWeightsKind
  21280. * - VertexBuffer.MatricesWeightsExtraKind
  21281. * @returns a boolean
  21282. */
  21283. isVertexBufferUpdatable(kind: string): boolean;
  21284. /**
  21285. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21286. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21287. * - VertexBuffer.PositionKind
  21288. * - VertexBuffer.UVKind
  21289. * - VertexBuffer.UV2Kind
  21290. * - VertexBuffer.UV3Kind
  21291. * - VertexBuffer.UV4Kind
  21292. * - VertexBuffer.UV5Kind
  21293. * - VertexBuffer.UV6Kind
  21294. * - VertexBuffer.ColorKind
  21295. * - VertexBuffer.MatricesIndicesKind
  21296. * - VertexBuffer.MatricesIndicesExtraKind
  21297. * - VertexBuffer.MatricesWeightsKind
  21298. * - VertexBuffer.MatricesWeightsExtraKind
  21299. * @returns an array of strings
  21300. */
  21301. getVerticesDataKinds(): string[];
  21302. /**
  21303. * Returns a positive integer : the total number of indices in this mesh geometry.
  21304. * @returns the numner of indices or zero if the mesh has no geometry.
  21305. */
  21306. getTotalIndices(): number;
  21307. /**
  21308. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21309. * @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.
  21310. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21311. * @returns the indices array or an empty array if the mesh has no geometry
  21312. */
  21313. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21314. readonly isBlocked: boolean;
  21315. /**
  21316. * Determine if the current mesh is ready to be rendered
  21317. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21318. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21319. * @returns true if all associated assets are ready (material, textures, shaders)
  21320. */
  21321. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21322. /**
  21323. * 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.
  21324. */
  21325. readonly areNormalsFrozen: boolean;
  21326. /**
  21327. * 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.
  21328. * @returns the current mesh
  21329. */
  21330. freezeNormals(): Mesh;
  21331. /**
  21332. * 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
  21333. * @returns the current mesh
  21334. */
  21335. unfreezeNormals(): Mesh;
  21336. /**
  21337. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21338. */
  21339. overridenInstanceCount: number;
  21340. /** @hidden */
  21341. _preActivate(): Mesh;
  21342. /** @hidden */
  21343. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21344. /** @hidden */
  21345. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21346. /**
  21347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21348. * This means the mesh underlying bounding box and sphere are recomputed.
  21349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21350. * @returns the current mesh
  21351. */
  21352. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21353. /** @hidden */
  21354. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21355. /**
  21356. * This function will subdivide the mesh into multiple submeshes
  21357. * @param count defines the expected number of submeshes
  21358. */
  21359. subdivide(count: number): void;
  21360. /**
  21361. * Copy a FloatArray into a specific associated vertex buffer
  21362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21363. * - VertexBuffer.PositionKind
  21364. * - VertexBuffer.UVKind
  21365. * - VertexBuffer.UV2Kind
  21366. * - VertexBuffer.UV3Kind
  21367. * - VertexBuffer.UV4Kind
  21368. * - VertexBuffer.UV5Kind
  21369. * - VertexBuffer.UV6Kind
  21370. * - VertexBuffer.ColorKind
  21371. * - VertexBuffer.MatricesIndicesKind
  21372. * - VertexBuffer.MatricesIndicesExtraKind
  21373. * - VertexBuffer.MatricesWeightsKind
  21374. * - VertexBuffer.MatricesWeightsExtraKind
  21375. * @param data defines the data source
  21376. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21377. * @param stride defines the data stride size (can be null)
  21378. * @returns the current mesh
  21379. */
  21380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21381. /**
  21382. * Flags an associated vertex buffer as updatable
  21383. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21384. * - VertexBuffer.PositionKind
  21385. * - VertexBuffer.UVKind
  21386. * - VertexBuffer.UV2Kind
  21387. * - VertexBuffer.UV3Kind
  21388. * - VertexBuffer.UV4Kind
  21389. * - VertexBuffer.UV5Kind
  21390. * - VertexBuffer.UV6Kind
  21391. * - VertexBuffer.ColorKind
  21392. * - VertexBuffer.MatricesIndicesKind
  21393. * - VertexBuffer.MatricesIndicesExtraKind
  21394. * - VertexBuffer.MatricesWeightsKind
  21395. * - VertexBuffer.MatricesWeightsExtraKind
  21396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21397. */
  21398. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21399. /**
  21400. * Sets the mesh global Vertex Buffer
  21401. * @param buffer defines the buffer to use
  21402. * @returns the current mesh
  21403. */
  21404. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21405. /**
  21406. * Update a specific associated vertex buffer
  21407. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21408. * - VertexBuffer.PositionKind
  21409. * - VertexBuffer.UVKind
  21410. * - VertexBuffer.UV2Kind
  21411. * - VertexBuffer.UV3Kind
  21412. * - VertexBuffer.UV4Kind
  21413. * - VertexBuffer.UV5Kind
  21414. * - VertexBuffer.UV6Kind
  21415. * - VertexBuffer.ColorKind
  21416. * - VertexBuffer.MatricesIndicesKind
  21417. * - VertexBuffer.MatricesIndicesExtraKind
  21418. * - VertexBuffer.MatricesWeightsKind
  21419. * - VertexBuffer.MatricesWeightsExtraKind
  21420. * @param data defines the data source
  21421. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21422. * @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)
  21423. * @returns the current mesh
  21424. */
  21425. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21426. /**
  21427. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21428. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21429. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21430. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21431. * @returns the current mesh
  21432. */
  21433. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21434. /**
  21435. * Creates a un-shared specific occurence of the geometry for the mesh.
  21436. * @returns the current mesh
  21437. */
  21438. makeGeometryUnique(): Mesh;
  21439. /**
  21440. * Set the index buffer of this mesh
  21441. * @param indices defines the source data
  21442. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21443. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21444. * @returns the current mesh
  21445. */
  21446. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21447. /**
  21448. * Update the current index buffer
  21449. * @param indices defines the source data
  21450. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21451. * @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)
  21452. * @returns the current mesh
  21453. */
  21454. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21455. /**
  21456. * Invert the geometry to move from a right handed system to a left handed one.
  21457. * @returns the current mesh
  21458. */
  21459. toLeftHanded(): Mesh;
  21460. /** @hidden */
  21461. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21462. /** @hidden */
  21463. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21464. /**
  21465. * Registers for this mesh a javascript function called just before the rendering process
  21466. * @param func defines the function to call before rendering this mesh
  21467. * @returns the current mesh
  21468. */
  21469. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21470. /**
  21471. * Disposes a previously registered javascript function called before the rendering
  21472. * @param func defines the function to remove
  21473. * @returns the current mesh
  21474. */
  21475. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21476. /**
  21477. * Registers for this mesh a javascript function called just after the rendering is complete
  21478. * @param func defines the function to call after rendering this mesh
  21479. * @returns the current mesh
  21480. */
  21481. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21482. /**
  21483. * Disposes a previously registered javascript function called after the rendering.
  21484. * @param func defines the function to remove
  21485. * @returns the current mesh
  21486. */
  21487. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21488. /** @hidden */
  21489. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21490. /** @hidden */
  21491. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21492. /** @hidden */
  21493. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21494. /**
  21495. * 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
  21496. * @param subMesh defines the subMesh to render
  21497. * @param enableAlphaMode defines if alpha mode can be changed
  21498. * @returns the current mesh
  21499. */
  21500. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21501. private _onBeforeDraw;
  21502. /**
  21503. * Renormalize the mesh and patch it up if there are no weights
  21504. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21505. * However in the case of zero weights then we set just a single influence to 1.
  21506. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21507. */
  21508. cleanMatrixWeights(): void;
  21509. private normalizeSkinFourWeights;
  21510. private normalizeSkinWeightsAndExtra;
  21511. /**
  21512. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21513. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21514. * the user know there was an issue with importing the mesh
  21515. * @returns a validation object with skinned, valid and report string
  21516. */
  21517. validateSkinning(): {
  21518. skinned: boolean;
  21519. valid: boolean;
  21520. report: string;
  21521. };
  21522. /** @hidden */
  21523. _checkDelayState(): Mesh;
  21524. private _queueLoad;
  21525. /**
  21526. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21527. * A mesh is in the frustum if its bounding box intersects the frustum
  21528. * @param frustumPlanes defines the frustum to test
  21529. * @returns true if the mesh is in the frustum planes
  21530. */
  21531. isInFrustum(frustumPlanes: Plane[]): boolean;
  21532. /**
  21533. * Sets the mesh material by the material or multiMaterial `id` property
  21534. * @param id is a string identifying the material or the multiMaterial
  21535. * @returns the current mesh
  21536. */
  21537. setMaterialByID(id: string): Mesh;
  21538. /**
  21539. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21540. * @returns an array of IAnimatable
  21541. */
  21542. getAnimatables(): IAnimatable[];
  21543. /**
  21544. * Modifies the mesh geometry according to the passed transformation matrix.
  21545. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21546. * The mesh normals are modified using the same transformation.
  21547. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21548. * @param transform defines the transform matrix to use
  21549. * @see http://doc.babylonjs.com/resources/baking_transformations
  21550. * @returns the current mesh
  21551. */
  21552. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21553. /**
  21554. * Modifies the mesh geometry according to its own current World Matrix.
  21555. * The mesh World Matrix is then reset.
  21556. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21557. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21558. * @see http://doc.babylonjs.com/resources/baking_transformations
  21559. * @returns the current mesh
  21560. */
  21561. bakeCurrentTransformIntoVertices(): Mesh;
  21562. /** @hidden */
  21563. readonly _positions: Nullable<Vector3[]>;
  21564. /** @hidden */
  21565. _resetPointsArrayCache(): Mesh;
  21566. /** @hidden */
  21567. _generatePointsArray(): boolean;
  21568. /**
  21569. * Returns a new Mesh object generated from the current mesh properties.
  21570. * This method must not get confused with createInstance()
  21571. * @param name is a string, the name given to the new mesh
  21572. * @param newParent can be any Node object (default `null`)
  21573. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21574. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21575. * @returns a new mesh
  21576. */
  21577. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21578. /**
  21579. * Releases resources associated with this mesh.
  21580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21582. */
  21583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21584. /**
  21585. * Modifies the mesh geometry according to a displacement map.
  21586. * 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.
  21587. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21588. * @param url is a string, the URL from the image file is to be downloaded.
  21589. * @param minHeight is the lower limit of the displacement.
  21590. * @param maxHeight is the upper limit of the displacement.
  21591. * @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.
  21592. * @param uvOffset is an optional vector2 used to offset UV.
  21593. * @param uvScale is an optional vector2 used to scale UV.
  21594. * @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.
  21595. * @returns the Mesh.
  21596. */
  21597. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21598. /**
  21599. * Modifies the mesh geometry according to a displacementMap buffer.
  21600. * 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.
  21601. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21602. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21603. * @param heightMapWidth is the width of the buffer image.
  21604. * @param heightMapHeight is the height of the buffer image.
  21605. * @param minHeight is the lower limit of the displacement.
  21606. * @param maxHeight is the upper limit of the displacement.
  21607. * @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.
  21608. * @param uvOffset is an optional vector2 used to offset UV.
  21609. * @param uvScale is an optional vector2 used to scale UV.
  21610. * @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.
  21611. * @returns the Mesh.
  21612. */
  21613. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21614. /**
  21615. * Modify the mesh to get a flat shading rendering.
  21616. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21617. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21618. * @returns current mesh
  21619. */
  21620. convertToFlatShadedMesh(): Mesh;
  21621. /**
  21622. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21623. * In other words, more vertices, no more indices and a single bigger VBO.
  21624. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21625. * @returns current mesh
  21626. */
  21627. convertToUnIndexedMesh(): Mesh;
  21628. /**
  21629. * Inverses facet orientations.
  21630. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21631. * @param flipNormals will also inverts the normals
  21632. * @returns current mesh
  21633. */
  21634. flipFaces(flipNormals?: boolean): Mesh;
  21635. /**
  21636. * Increase the number of facets and hence vertices in a mesh
  21637. * Vertex normals are interpolated from existing vertex normals
  21638. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21639. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21640. */
  21641. increaseVertices(numberPerEdge: number): void;
  21642. /**
  21643. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21644. * This will undo any application of covertToFlatShadedMesh
  21645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21646. */
  21647. forceSharedVertices(): void;
  21648. /** @hidden */
  21649. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21650. /** @hidden */
  21651. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21652. /**
  21653. * Creates a new InstancedMesh object from the mesh model.
  21654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21655. * @param name defines the name of the new instance
  21656. * @returns a new InstancedMesh
  21657. */
  21658. createInstance(name: string): InstancedMesh;
  21659. /**
  21660. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21661. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21662. * @returns the current mesh
  21663. */
  21664. synchronizeInstances(): Mesh;
  21665. /**
  21666. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21667. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21668. * This should be used together with the simplification to avoid disappearing triangles.
  21669. * @param successCallback an optional success callback to be called after the optimization finished.
  21670. * @returns the current mesh
  21671. */
  21672. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21673. /**
  21674. * Serialize current mesh
  21675. * @param serializationObject defines the object which will receive the serialization data
  21676. */
  21677. serialize(serializationObject: any): void;
  21678. /** @hidden */
  21679. _syncGeometryWithMorphTargetManager(): void;
  21680. /** @hidden */
  21681. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21682. /**
  21683. * Returns a new Mesh object parsed from the source provided.
  21684. * @param parsedMesh is the source
  21685. * @param scene defines the hosting scene
  21686. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21687. * @returns a new Mesh
  21688. */
  21689. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21690. /**
  21691. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21692. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21693. * @param name defines the name of the mesh to create
  21694. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21695. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21696. * @param closePath creates a seam between the first and the last points of each path of the path array
  21697. * @param offset is taken in account only if the `pathArray` is containing a single path
  21698. * @param scene defines the hosting scene
  21699. * @param updatable defines if the mesh must be flagged as updatable
  21700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21701. * @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)
  21702. * @returns a new Mesh
  21703. */
  21704. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21705. /**
  21706. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21707. * @param name defines the name of the mesh to create
  21708. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21709. * @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
  21710. * @param scene defines the hosting scene
  21711. * @param updatable defines if the mesh must be flagged as updatable
  21712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21713. * @returns a new Mesh
  21714. */
  21715. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21716. /**
  21717. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21718. * @param name defines the name of the mesh to create
  21719. * @param size sets the size (float) of each box side (default 1)
  21720. * @param scene defines the hosting scene
  21721. * @param updatable defines if the mesh must be flagged as updatable
  21722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21723. * @returns a new Mesh
  21724. */
  21725. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21726. /**
  21727. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21728. * @param name defines the name of the mesh to create
  21729. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21730. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21731. * @param scene defines the hosting scene
  21732. * @param updatable defines if the mesh must be flagged as updatable
  21733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21734. * @returns a new Mesh
  21735. */
  21736. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21737. /**
  21738. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21739. * @param name defines the name of the mesh to create
  21740. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21741. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21742. * @param scene defines the hosting scene
  21743. * @returns a new Mesh
  21744. */
  21745. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21746. /**
  21747. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21748. * @param name defines the name of the mesh to create
  21749. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21750. * @param diameterTop set the top cap diameter (floats, default 1)
  21751. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21752. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21753. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21754. * @param scene defines the hosting scene
  21755. * @param updatable defines if the mesh must be flagged as updatable
  21756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21757. * @returns a new Mesh
  21758. */
  21759. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21760. /**
  21761. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21762. * @param name defines the name of the mesh to create
  21763. * @param diameter sets the diameter size (float) of the torus (default 1)
  21764. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21765. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21766. * @param scene defines the hosting scene
  21767. * @param updatable defines if the mesh must be flagged as updatable
  21768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21769. * @returns a new Mesh
  21770. */
  21771. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21772. /**
  21773. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21774. * @param name defines the name of the mesh to create
  21775. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21776. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21777. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21778. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21779. * @param p the number of windings on X axis (positive integers, default 2)
  21780. * @param q the number of windings on Y axis (positive integers, default 3)
  21781. * @param scene defines the hosting scene
  21782. * @param updatable defines if the mesh must be flagged as updatable
  21783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21784. * @returns a new Mesh
  21785. */
  21786. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21787. /**
  21788. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21789. * @param name defines the name of the mesh to create
  21790. * @param points is an array successive Vector3
  21791. * @param scene defines the hosting scene
  21792. * @param updatable defines if the mesh must be flagged as updatable
  21793. * @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).
  21794. * @returns a new Mesh
  21795. */
  21796. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21797. /**
  21798. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21799. * @param name defines the name of the mesh to create
  21800. * @param points is an array successive Vector3
  21801. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21802. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21803. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21804. * @param scene defines the hosting scene
  21805. * @param updatable defines if the mesh must be flagged as updatable
  21806. * @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)
  21807. * @returns a new Mesh
  21808. */
  21809. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21810. /**
  21811. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21813. * 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.
  21814. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21815. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21816. * Remember you can only change the shape positions, not their number when updating a polygon.
  21817. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21818. * @param name defines the name of the mesh to create
  21819. * @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
  21820. * @param scene defines the hosting scene
  21821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21822. * @param updatable defines if the mesh must be flagged as updatable
  21823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21824. * @param earcutInjection can be used to inject your own earcut reference
  21825. * @returns a new Mesh
  21826. */
  21827. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21828. /**
  21829. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21831. * @param name defines the name of the mesh to create
  21832. * @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
  21833. * @param depth defines the height of extrusion
  21834. * @param scene defines the hosting scene
  21835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21836. * @param updatable defines if the mesh must be flagged as updatable
  21837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21838. * @param earcutInjection can be used to inject your own earcut reference
  21839. * @returns a new Mesh
  21840. */
  21841. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21842. /**
  21843. * Creates an extruded shape mesh.
  21844. * 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
  21845. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21847. * @param name defines the name of the mesh to create
  21848. * @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
  21849. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21850. * @param scale is the value to scale the shape
  21851. * @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
  21852. * @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
  21853. * @param scene defines the hosting scene
  21854. * @param updatable defines if the mesh must be flagged as updatable
  21855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21856. * @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)
  21857. * @returns a new Mesh
  21858. */
  21859. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21860. /**
  21861. * Creates an custom extruded shape mesh.
  21862. * The custom extrusion is a parametric shape.
  21863. * It has no predefined shape. Its final shape will depend on the input parameters.
  21864. * Please consider using the same method from the MeshBuilder class instead
  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 scaleFunction is a custom Javascript function called on each path point
  21870. * @param rotationFunction is a custom Javascript function called on each path point
  21871. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21872. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21873. * @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
  21874. * @param scene defines the hosting scene
  21875. * @param updatable defines if the mesh must be flagged as updatable
  21876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21877. * @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)
  21878. * @returns a new Mesh
  21879. */
  21880. 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;
  21881. /**
  21882. * Creates lathe mesh.
  21883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21884. * Please consider using the same method from the MeshBuilder class instead
  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 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
  21887. * @param radius is the radius value of the lathe
  21888. * @param tessellation is the side number of the lathe.
  21889. * @param scene defines the hosting scene
  21890. * @param updatable defines if the mesh must be flagged as updatable
  21891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21892. * @returns a new Mesh
  21893. */
  21894. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21895. /**
  21896. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21897. * @param name defines the name of the mesh to create
  21898. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21899. * @param scene defines the hosting scene
  21900. * @param updatable defines if the mesh must be flagged as updatable
  21901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21902. * @returns a new Mesh
  21903. */
  21904. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21905. /**
  21906. * Creates a ground mesh.
  21907. * Please consider using the same method from the MeshBuilder class instead
  21908. * @param name defines the name of the mesh to create
  21909. * @param width set the width of the ground
  21910. * @param height set the height of the ground
  21911. * @param subdivisions sets the number of subdivisions per side
  21912. * @param scene defines the hosting scene
  21913. * @param updatable defines if the mesh must be flagged as updatable
  21914. * @returns a new Mesh
  21915. */
  21916. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21917. /**
  21918. * Creates a tiled ground mesh.
  21919. * Please consider using the same method from the MeshBuilder class instead
  21920. * @param name defines the name of the mesh to create
  21921. * @param xmin set the ground minimum X coordinate
  21922. * @param zmin set the ground minimum Y coordinate
  21923. * @param xmax set the ground maximum X coordinate
  21924. * @param zmax set the ground maximum Z coordinate
  21925. * @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
  21926. * @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
  21927. * @param scene defines the hosting scene
  21928. * @param updatable defines if the mesh must be flagged as updatable
  21929. * @returns a new Mesh
  21930. */
  21931. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21932. w: number;
  21933. h: number;
  21934. }, precision: {
  21935. w: number;
  21936. h: number;
  21937. }, scene: Scene, updatable?: boolean): Mesh;
  21938. /**
  21939. * Creates a ground mesh from a height map.
  21940. * Please consider using the same method from the MeshBuilder class instead
  21941. * @see http://doc.babylonjs.com/babylon101/height_map
  21942. * @param name defines the name of the mesh to create
  21943. * @param url sets the URL of the height map image resource
  21944. * @param width set the ground width size
  21945. * @param height set the ground height size
  21946. * @param subdivisions sets the number of subdivision per side
  21947. * @param minHeight is the minimum altitude on the ground
  21948. * @param maxHeight is the maximum altitude on the ground
  21949. * @param scene defines the hosting scene
  21950. * @param updatable defines if the mesh must be flagged as updatable
  21951. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21952. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21953. * @returns a new Mesh
  21954. */
  21955. 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;
  21956. /**
  21957. * Creates a tube mesh.
  21958. * The tube is a parametric shape.
  21959. * It has no predefined shape. Its final shape will depend on the input parameters.
  21960. * Please consider using the same method from the MeshBuilder class instead
  21961. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21962. * @param name defines the name of the mesh to create
  21963. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21964. * @param radius sets the tube radius size
  21965. * @param tessellation is the number of sides on the tubular surface
  21966. * @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
  21967. * @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
  21968. * @param scene defines the hosting scene
  21969. * @param updatable defines if the mesh must be flagged as updatable
  21970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21971. * @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)
  21972. * @returns a new Mesh
  21973. */
  21974. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21975. (i: number, distance: number): number;
  21976. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21977. /**
  21978. * Creates a polyhedron mesh.
  21979. * Please consider using the same method from the MeshBuilder class instead.
  21980. * * 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
  21981. * * The parameter `size` (positive float, default 1) sets the polygon size
  21982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21983. * * 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`
  21984. * * 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
  21985. * * 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)`)
  21986. * * 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
  21987. * * 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
  21988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21989. * * If you create a double-sided mesh, you can choose what parts of 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
  21990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21991. * @param name defines the name of the mesh to create
  21992. * @param options defines the options used to create the mesh
  21993. * @param scene defines the hosting scene
  21994. * @returns a new Mesh
  21995. */
  21996. static CreatePolyhedron(name: string, options: {
  21997. type?: number;
  21998. size?: number;
  21999. sizeX?: number;
  22000. sizeY?: number;
  22001. sizeZ?: number;
  22002. custom?: any;
  22003. faceUV?: Vector4[];
  22004. faceColors?: Color4[];
  22005. updatable?: boolean;
  22006. sideOrientation?: number;
  22007. }, scene: Scene): Mesh;
  22008. /**
  22009. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22010. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22011. * * 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`)
  22012. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22013. * * 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
  22014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22015. * * If you create a double-sided mesh, you can choose what parts of 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
  22016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22017. * @param name defines the name of the mesh
  22018. * @param options defines the options used to create the mesh
  22019. * @param scene defines the hosting scene
  22020. * @returns a new Mesh
  22021. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22022. */
  22023. static CreateIcoSphere(name: string, options: {
  22024. radius?: number;
  22025. flat?: boolean;
  22026. subdivisions?: number;
  22027. sideOrientation?: number;
  22028. updatable?: boolean;
  22029. }, scene: Scene): Mesh;
  22030. /**
  22031. * Creates a decal mesh.
  22032. * Please consider using the same method from the MeshBuilder class instead.
  22033. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22034. * @param name defines the name of the mesh
  22035. * @param sourceMesh defines the mesh receiving the decal
  22036. * @param position sets the position of the decal in world coordinates
  22037. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22038. * @param size sets the decal scaling
  22039. * @param angle sets the angle to rotate the decal
  22040. * @returns a new Mesh
  22041. */
  22042. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22043. /**
  22044. * Prepare internal position array for software CPU skinning
  22045. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22046. */
  22047. setPositionsForCPUSkinning(): Float32Array;
  22048. /**
  22049. * Prepare internal normal array for software CPU skinning
  22050. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22051. */
  22052. setNormalsForCPUSkinning(): Float32Array;
  22053. /**
  22054. * Updates the vertex buffer by applying transformation from the bones
  22055. * @param skeleton defines the skeleton to apply to current mesh
  22056. * @returns the current mesh
  22057. */
  22058. applySkeleton(skeleton: Skeleton): Mesh;
  22059. /**
  22060. * 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
  22061. * @param meshes defines the list of meshes to scan
  22062. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22063. */
  22064. static MinMax(meshes: AbstractMesh[]): {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. };
  22068. /**
  22069. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22070. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22071. * @returns a vector3
  22072. */
  22073. static Center(meshesOrMinMaxVector: {
  22074. min: Vector3;
  22075. max: Vector3;
  22076. } | AbstractMesh[]): Vector3;
  22077. /**
  22078. * Merge the array of meshes into a single mesh for performance reasons.
  22079. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22080. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22081. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22082. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22083. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22084. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22085. * @returns a new mesh
  22086. */
  22087. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22088. /** @hidden */
  22089. addInstance(instance: InstancedMesh): void;
  22090. /** @hidden */
  22091. removeInstance(instance: InstancedMesh): void;
  22092. }
  22093. }
  22094. declare module "babylonjs/Materials/material" {
  22095. import { IAnimatable } from "babylonjs/Misc/tools";
  22096. import { SmartArray } from "babylonjs/Misc/smartArray";
  22097. import { Observable } from "babylonjs/Misc/observable";
  22098. import { Nullable } from "babylonjs/types";
  22099. import { Scene } from "babylonjs/scene";
  22100. import { Matrix } from "babylonjs/Maths/math";
  22101. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { Mesh } from "babylonjs/Meshes/mesh";
  22104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22105. import { Effect } from "babylonjs/Materials/effect";
  22106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22109. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22110. import { Animation } from "babylonjs/Animations/animation";
  22111. /**
  22112. * Base class for the main features of a material in Babylon.js
  22113. */
  22114. export class Material implements IAnimatable {
  22115. /**
  22116. * Returns the triangle fill mode
  22117. */
  22118. static readonly TriangleFillMode: number;
  22119. /**
  22120. * Returns the wireframe mode
  22121. */
  22122. static readonly WireFrameFillMode: number;
  22123. /**
  22124. * Returns the point fill mode
  22125. */
  22126. static readonly PointFillMode: number;
  22127. /**
  22128. * Returns the point list draw mode
  22129. */
  22130. static readonly PointListDrawMode: number;
  22131. /**
  22132. * Returns the line list draw mode
  22133. */
  22134. static readonly LineListDrawMode: number;
  22135. /**
  22136. * Returns the line loop draw mode
  22137. */
  22138. static readonly LineLoopDrawMode: number;
  22139. /**
  22140. * Returns the line strip draw mode
  22141. */
  22142. static readonly LineStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle strip draw mode
  22145. */
  22146. static readonly TriangleStripDrawMode: number;
  22147. /**
  22148. * Returns the triangle fan draw mode
  22149. */
  22150. static readonly TriangleFanDrawMode: number;
  22151. /**
  22152. * Stores the clock-wise side orientation
  22153. */
  22154. static readonly ClockWiseSideOrientation: number;
  22155. /**
  22156. * Stores the counter clock-wise side orientation
  22157. */
  22158. static readonly CounterClockWiseSideOrientation: number;
  22159. /**
  22160. * The dirty texture flag value
  22161. */
  22162. static readonly TextureDirtyFlag: number;
  22163. /**
  22164. * The dirty light flag value
  22165. */
  22166. static readonly LightDirtyFlag: number;
  22167. /**
  22168. * The dirty fresnel flag value
  22169. */
  22170. static readonly FresnelDirtyFlag: number;
  22171. /**
  22172. * The dirty attribute flag value
  22173. */
  22174. static readonly AttributesDirtyFlag: number;
  22175. /**
  22176. * The dirty misc flag value
  22177. */
  22178. static readonly MiscDirtyFlag: number;
  22179. /**
  22180. * The all dirty flag value
  22181. */
  22182. static readonly AllDirtyFlag: number;
  22183. /**
  22184. * The ID of the material
  22185. */
  22186. id: string;
  22187. /**
  22188. * Gets or sets the unique id of the material
  22189. */
  22190. uniqueId: number;
  22191. /**
  22192. * The name of the material
  22193. */
  22194. name: string;
  22195. /**
  22196. * Gets or sets user defined metadata
  22197. */
  22198. metadata: any;
  22199. /**
  22200. * For internal use only. Please do not use.
  22201. */
  22202. reservedDataStore: any;
  22203. /**
  22204. * Specifies if the ready state should be checked on each call
  22205. */
  22206. checkReadyOnEveryCall: boolean;
  22207. /**
  22208. * Specifies if the ready state should be checked once
  22209. */
  22210. checkReadyOnlyOnce: boolean;
  22211. /**
  22212. * The state of the material
  22213. */
  22214. state: string;
  22215. /**
  22216. * The alpha value of the material
  22217. */
  22218. protected _alpha: number;
  22219. /**
  22220. * List of inspectable custom properties (used by the Inspector)
  22221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22222. */
  22223. inspectableCustomProperties: IInspectable[];
  22224. /**
  22225. * Sets the alpha value of the material
  22226. */
  22227. /**
  22228. * Gets the alpha value of the material
  22229. */
  22230. alpha: number;
  22231. /**
  22232. * Specifies if back face culling is enabled
  22233. */
  22234. protected _backFaceCulling: boolean;
  22235. /**
  22236. * Sets the back-face culling state
  22237. */
  22238. /**
  22239. * Gets the back-face culling state
  22240. */
  22241. backFaceCulling: boolean;
  22242. /**
  22243. * Stores the value for side orientation
  22244. */
  22245. sideOrientation: number;
  22246. /**
  22247. * Callback triggered when the material is compiled
  22248. */
  22249. onCompiled: (effect: Effect) => void;
  22250. /**
  22251. * Callback triggered when an error occurs
  22252. */
  22253. onError: (effect: Effect, errors: string) => void;
  22254. /**
  22255. * Callback triggered to get the render target textures
  22256. */
  22257. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22258. /**
  22259. * Gets a boolean indicating that current material needs to register RTT
  22260. */
  22261. readonly hasRenderTargetTextures: boolean;
  22262. /**
  22263. * Specifies if the material should be serialized
  22264. */
  22265. doNotSerialize: boolean;
  22266. /**
  22267. * @hidden
  22268. */
  22269. _storeEffectOnSubMeshes: boolean;
  22270. /**
  22271. * Stores the animations for the material
  22272. */
  22273. animations: Array<Animation>;
  22274. /**
  22275. * An event triggered when the material is disposed
  22276. */
  22277. onDisposeObservable: Observable<Material>;
  22278. /**
  22279. * An observer which watches for dispose events
  22280. */
  22281. private _onDisposeObserver;
  22282. private _onUnBindObservable;
  22283. /**
  22284. * Called during a dispose event
  22285. */
  22286. onDispose: () => void;
  22287. private _onBindObservable;
  22288. /**
  22289. * An event triggered when the material is bound
  22290. */
  22291. readonly onBindObservable: Observable<AbstractMesh>;
  22292. /**
  22293. * An observer which watches for bind events
  22294. */
  22295. private _onBindObserver;
  22296. /**
  22297. * Called during a bind event
  22298. */
  22299. onBind: (Mesh: AbstractMesh) => void;
  22300. /**
  22301. * An event triggered when the material is unbound
  22302. */
  22303. readonly onUnBindObservable: Observable<Material>;
  22304. /**
  22305. * Stores the value of the alpha mode
  22306. */
  22307. private _alphaMode;
  22308. /**
  22309. * Sets the value of the alpha mode.
  22310. *
  22311. * | Value | Type | Description |
  22312. * | --- | --- | --- |
  22313. * | 0 | ALPHA_DISABLE | |
  22314. * | 1 | ALPHA_ADD | |
  22315. * | 2 | ALPHA_COMBINE | |
  22316. * | 3 | ALPHA_SUBTRACT | |
  22317. * | 4 | ALPHA_MULTIPLY | |
  22318. * | 5 | ALPHA_MAXIMIZED | |
  22319. * | 6 | ALPHA_ONEONE | |
  22320. * | 7 | ALPHA_PREMULTIPLIED | |
  22321. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22322. * | 9 | ALPHA_INTERPOLATE | |
  22323. * | 10 | ALPHA_SCREENMODE | |
  22324. *
  22325. */
  22326. /**
  22327. * Gets the value of the alpha mode
  22328. */
  22329. alphaMode: number;
  22330. /**
  22331. * Stores the state of the need depth pre-pass value
  22332. */
  22333. private _needDepthPrePass;
  22334. /**
  22335. * Sets the need depth pre-pass value
  22336. */
  22337. /**
  22338. * Gets the depth pre-pass value
  22339. */
  22340. needDepthPrePass: boolean;
  22341. /**
  22342. * Specifies if depth writing should be disabled
  22343. */
  22344. disableDepthWrite: boolean;
  22345. /**
  22346. * Specifies if depth writing should be forced
  22347. */
  22348. forceDepthWrite: boolean;
  22349. /**
  22350. * Specifies if there should be a separate pass for culling
  22351. */
  22352. separateCullingPass: boolean;
  22353. /**
  22354. * Stores the state specifing if fog should be enabled
  22355. */
  22356. private _fogEnabled;
  22357. /**
  22358. * Sets the state for enabling fog
  22359. */
  22360. /**
  22361. * Gets the value of the fog enabled state
  22362. */
  22363. fogEnabled: boolean;
  22364. /**
  22365. * Stores the size of points
  22366. */
  22367. pointSize: number;
  22368. /**
  22369. * Stores the z offset value
  22370. */
  22371. zOffset: number;
  22372. /**
  22373. * Gets a value specifying if wireframe mode is enabled
  22374. */
  22375. /**
  22376. * Sets the state of wireframe mode
  22377. */
  22378. wireframe: boolean;
  22379. /**
  22380. * Gets the value specifying if point clouds are enabled
  22381. */
  22382. /**
  22383. * Sets the state of point cloud mode
  22384. */
  22385. pointsCloud: boolean;
  22386. /**
  22387. * Gets the material fill mode
  22388. */
  22389. /**
  22390. * Sets the material fill mode
  22391. */
  22392. fillMode: number;
  22393. /**
  22394. * @hidden
  22395. * Stores the effects for the material
  22396. */
  22397. _effect: Nullable<Effect>;
  22398. /**
  22399. * @hidden
  22400. * Specifies if the material was previously ready
  22401. */
  22402. _wasPreviouslyReady: boolean;
  22403. /**
  22404. * Specifies if uniform buffers should be used
  22405. */
  22406. private _useUBO;
  22407. /**
  22408. * Stores a reference to the scene
  22409. */
  22410. private _scene;
  22411. /**
  22412. * Stores the fill mode state
  22413. */
  22414. private _fillMode;
  22415. /**
  22416. * Specifies if the depth write state should be cached
  22417. */
  22418. private _cachedDepthWriteState;
  22419. /**
  22420. * Stores the uniform buffer
  22421. */
  22422. protected _uniformBuffer: UniformBuffer;
  22423. /** @hidden */
  22424. _indexInSceneMaterialArray: number;
  22425. /** @hidden */
  22426. meshMap: Nullable<{
  22427. [id: string]: AbstractMesh | undefined;
  22428. }>;
  22429. /**
  22430. * Creates a material instance
  22431. * @param name defines the name of the material
  22432. * @param scene defines the scene to reference
  22433. * @param doNotAdd specifies if the material should be added to the scene
  22434. */
  22435. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22436. /**
  22437. * Returns a string representation of the current material
  22438. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22439. * @returns a string with material information
  22440. */
  22441. toString(fullDetails?: boolean): string;
  22442. /**
  22443. * Gets the class name of the material
  22444. * @returns a string with the class name of the material
  22445. */
  22446. getClassName(): string;
  22447. /**
  22448. * Specifies if updates for the material been locked
  22449. */
  22450. readonly isFrozen: boolean;
  22451. /**
  22452. * Locks updates for the material
  22453. */
  22454. freeze(): void;
  22455. /**
  22456. * Unlocks updates for the material
  22457. */
  22458. unfreeze(): void;
  22459. /**
  22460. * Specifies if the material is ready to be used
  22461. * @param mesh defines the mesh to check
  22462. * @param useInstances specifies if instances should be used
  22463. * @returns a boolean indicating if the material is ready to be used
  22464. */
  22465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22466. /**
  22467. * Specifies that the submesh is ready to be used
  22468. * @param mesh defines the mesh to check
  22469. * @param subMesh defines which submesh to check
  22470. * @param useInstances specifies that instances should be used
  22471. * @returns a boolean indicating that the submesh is ready or not
  22472. */
  22473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22474. /**
  22475. * Returns the material effect
  22476. * @returns the effect associated with the material
  22477. */
  22478. getEffect(): Nullable<Effect>;
  22479. /**
  22480. * Returns the current scene
  22481. * @returns a Scene
  22482. */
  22483. getScene(): Scene;
  22484. /**
  22485. * Specifies if the material will require alpha blending
  22486. * @returns a boolean specifying if alpha blending is needed
  22487. */
  22488. needAlphaBlending(): boolean;
  22489. /**
  22490. * Specifies if the mesh will require alpha blending
  22491. * @param mesh defines the mesh to check
  22492. * @returns a boolean specifying if alpha blending is needed for the mesh
  22493. */
  22494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22495. /**
  22496. * Specifies if this material should be rendered in alpha test mode
  22497. * @returns a boolean specifying if an alpha test is needed.
  22498. */
  22499. needAlphaTesting(): boolean;
  22500. /**
  22501. * Gets the texture used for the alpha test
  22502. * @returns the texture to use for alpha testing
  22503. */
  22504. getAlphaTestTexture(): Nullable<BaseTexture>;
  22505. /**
  22506. * Marks the material to indicate that it needs to be re-calculated
  22507. */
  22508. markDirty(): void;
  22509. /** @hidden */
  22510. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22511. /**
  22512. * Binds the material to the mesh
  22513. * @param world defines the world transformation matrix
  22514. * @param mesh defines the mesh to bind the material to
  22515. */
  22516. bind(world: Matrix, mesh?: Mesh): void;
  22517. /**
  22518. * Binds the submesh to the material
  22519. * @param world defines the world transformation matrix
  22520. * @param mesh defines the mesh containing the submesh
  22521. * @param subMesh defines the submesh to bind the material to
  22522. */
  22523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22524. /**
  22525. * Binds the world matrix to the material
  22526. * @param world defines the world transformation matrix
  22527. */
  22528. bindOnlyWorldMatrix(world: Matrix): void;
  22529. /**
  22530. * Binds the scene's uniform buffer to the effect.
  22531. * @param effect defines the effect to bind to the scene uniform buffer
  22532. * @param sceneUbo defines the uniform buffer storing scene data
  22533. */
  22534. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22535. /**
  22536. * Binds the view matrix to the effect
  22537. * @param effect defines the effect to bind the view matrix to
  22538. */
  22539. bindView(effect: Effect): void;
  22540. /**
  22541. * Binds the view projection matrix to the effect
  22542. * @param effect defines the effect to bind the view projection matrix to
  22543. */
  22544. bindViewProjection(effect: Effect): void;
  22545. /**
  22546. * Specifies if material alpha testing should be turned on for the mesh
  22547. * @param mesh defines the mesh to check
  22548. */
  22549. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22550. /**
  22551. * Processes to execute after binding the material to a mesh
  22552. * @param mesh defines the rendered mesh
  22553. */
  22554. protected _afterBind(mesh?: Mesh): void;
  22555. /**
  22556. * Unbinds the material from the mesh
  22557. */
  22558. unbind(): void;
  22559. /**
  22560. * Gets the active textures from the material
  22561. * @returns an array of textures
  22562. */
  22563. getActiveTextures(): BaseTexture[];
  22564. /**
  22565. * Specifies if the material uses a texture
  22566. * @param texture defines the texture to check against the material
  22567. * @returns a boolean specifying if the material uses the texture
  22568. */
  22569. hasTexture(texture: BaseTexture): boolean;
  22570. /**
  22571. * Makes a duplicate of the material, and gives it a new name
  22572. * @param name defines the new name for the duplicated material
  22573. * @returns the cloned material
  22574. */
  22575. clone(name: string): Nullable<Material>;
  22576. /**
  22577. * Gets the meshes bound to the material
  22578. * @returns an array of meshes bound to the material
  22579. */
  22580. getBindedMeshes(): AbstractMesh[];
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh associated with this material
  22584. * @param onCompiled defines a function to execute once the material is compiled
  22585. * @param options defines the options to configure the compilation
  22586. */
  22587. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): void;
  22590. /**
  22591. * Force shader compilation
  22592. * @param mesh defines the mesh that will use this material
  22593. * @param options defines additional options for compiling the shaders
  22594. * @returns a promise that resolves when the compilation completes
  22595. */
  22596. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22597. clipPlane: boolean;
  22598. }>): Promise<void>;
  22599. private static readonly _ImageProcessingDirtyCallBack;
  22600. private static readonly _TextureDirtyCallBack;
  22601. private static readonly _FresnelDirtyCallBack;
  22602. private static readonly _MiscDirtyCallBack;
  22603. private static readonly _LightsDirtyCallBack;
  22604. private static readonly _AttributeDirtyCallBack;
  22605. private static _FresnelAndMiscDirtyCallBack;
  22606. private static _TextureAndMiscDirtyCallBack;
  22607. private static readonly _DirtyCallbackArray;
  22608. private static readonly _RunDirtyCallBacks;
  22609. /**
  22610. * Marks a define in the material to indicate that it needs to be re-computed
  22611. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22612. */
  22613. markAsDirty(flag: number): void;
  22614. /**
  22615. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22616. * @param func defines a function which checks material defines against the submeshes
  22617. */
  22618. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22619. /**
  22620. * Indicates that image processing needs to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22623. /**
  22624. * Indicates that textures need to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsTexturesDirty(): void;
  22627. /**
  22628. * Indicates that fresnel needs to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelDirty(): void;
  22631. /**
  22632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22635. /**
  22636. * Indicates that lights need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsLightsDirty(): void;
  22639. /**
  22640. * Indicates that attributes need to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsAttributesDirty(): void;
  22643. /**
  22644. * Indicates that misc needs to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsMiscDirty(): void;
  22647. /**
  22648. * Indicates that textures and misc need to be re-calculated for all submeshes
  22649. */
  22650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22651. /**
  22652. * Disposes the material
  22653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22656. */
  22657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22658. /** @hidden */
  22659. private releaseVertexArrayObject;
  22660. /**
  22661. * Serializes this material
  22662. * @returns the serialized material object
  22663. */
  22664. serialize(): any;
  22665. /**
  22666. * Creates a material from parsed material data
  22667. * @param parsedMaterial defines parsed material data
  22668. * @param scene defines the hosting scene
  22669. * @param rootUrl defines the root URL to use to load textures
  22670. * @returns a new material
  22671. */
  22672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22673. }
  22674. }
  22675. declare module "babylonjs/Meshes/subMesh" {
  22676. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22677. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22678. import { Engine } from "babylonjs/Engines/engine";
  22679. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22680. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22681. import { Effect } from "babylonjs/Materials/effect";
  22682. import { Collider } from "babylonjs/Collisions/collider";
  22683. import { Material } from "babylonjs/Materials/material";
  22684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22686. import { Mesh } from "babylonjs/Meshes/mesh";
  22687. import { Ray } from "babylonjs/Culling/ray";
  22688. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22689. /**
  22690. * Base class for submeshes
  22691. */
  22692. export class BaseSubMesh {
  22693. /** @hidden */
  22694. _materialDefines: Nullable<MaterialDefines>;
  22695. /** @hidden */
  22696. _materialEffect: Nullable<Effect>;
  22697. /**
  22698. * Gets associated effect
  22699. */
  22700. readonly effect: Nullable<Effect>;
  22701. /**
  22702. * Sets associated effect (effect used to render this submesh)
  22703. * @param effect defines the effect to associate with
  22704. * @param defines defines the set of defines used to compile this effect
  22705. */
  22706. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22707. }
  22708. /**
  22709. * Defines a subdivision inside a mesh
  22710. */
  22711. export class SubMesh extends BaseSubMesh implements ICullable {
  22712. /** the material index to use */
  22713. materialIndex: number;
  22714. /** vertex index start */
  22715. verticesStart: number;
  22716. /** vertices count */
  22717. verticesCount: number;
  22718. /** index start */
  22719. indexStart: number;
  22720. /** indices count */
  22721. indexCount: number;
  22722. /** @hidden */
  22723. _linesIndexCount: number;
  22724. private _mesh;
  22725. private _renderingMesh;
  22726. private _boundingInfo;
  22727. private _linesIndexBuffer;
  22728. /** @hidden */
  22729. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22730. /** @hidden */
  22731. _trianglePlanes: Plane[];
  22732. /** @hidden */
  22733. _lastColliderTransformMatrix: Matrix;
  22734. /** @hidden */
  22735. _renderId: number;
  22736. /** @hidden */
  22737. _alphaIndex: number;
  22738. /** @hidden */
  22739. _distanceToCamera: number;
  22740. /** @hidden */
  22741. _id: number;
  22742. private _currentMaterial;
  22743. /**
  22744. * Add a new submesh to a mesh
  22745. * @param materialIndex defines the material index to use
  22746. * @param verticesStart defines vertex index start
  22747. * @param verticesCount defines vertices count
  22748. * @param indexStart defines index start
  22749. * @param indexCount defines indices count
  22750. * @param mesh defines the parent mesh
  22751. * @param renderingMesh defines an optional rendering mesh
  22752. * @param createBoundingBox defines if bounding box should be created for this submesh
  22753. * @returns the new submesh
  22754. */
  22755. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22756. /**
  22757. * Creates a new submesh
  22758. * @param materialIndex defines the material index to use
  22759. * @param verticesStart defines vertex index start
  22760. * @param verticesCount defines vertices count
  22761. * @param indexStart defines index start
  22762. * @param indexCount defines indices count
  22763. * @param mesh defines the parent mesh
  22764. * @param renderingMesh defines an optional rendering mesh
  22765. * @param createBoundingBox defines if bounding box should be created for this submesh
  22766. */
  22767. constructor(
  22768. /** the material index to use */
  22769. materialIndex: number,
  22770. /** vertex index start */
  22771. verticesStart: number,
  22772. /** vertices count */
  22773. verticesCount: number,
  22774. /** index start */
  22775. indexStart: number,
  22776. /** indices count */
  22777. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22778. /**
  22779. * Returns true if this submesh covers the entire parent mesh
  22780. * @ignorenaming
  22781. */
  22782. readonly IsGlobal: boolean;
  22783. /**
  22784. * Returns the submesh BoudingInfo object
  22785. * @returns current bounding info (or mesh's one if the submesh is global)
  22786. */
  22787. getBoundingInfo(): BoundingInfo;
  22788. /**
  22789. * Sets the submesh BoundingInfo
  22790. * @param boundingInfo defines the new bounding info to use
  22791. * @returns the SubMesh
  22792. */
  22793. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22794. /**
  22795. * Returns the mesh of the current submesh
  22796. * @return the parent mesh
  22797. */
  22798. getMesh(): AbstractMesh;
  22799. /**
  22800. * Returns the rendering mesh of the submesh
  22801. * @returns the rendering mesh (could be different from parent mesh)
  22802. */
  22803. getRenderingMesh(): Mesh;
  22804. /**
  22805. * Returns the submesh material
  22806. * @returns null or the current material
  22807. */
  22808. getMaterial(): Nullable<Material>;
  22809. /**
  22810. * Sets a new updated BoundingInfo object to the submesh
  22811. * @returns the SubMesh
  22812. */
  22813. refreshBoundingInfo(): SubMesh;
  22814. /** @hidden */
  22815. _checkCollision(collider: Collider): boolean;
  22816. /**
  22817. * Updates the submesh BoundingInfo
  22818. * @param world defines the world matrix to use to update the bounding info
  22819. * @returns the submesh
  22820. */
  22821. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22822. /**
  22823. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22824. * @param frustumPlanes defines the frustum planes
  22825. * @returns true if the submesh is intersecting with the frustum
  22826. */
  22827. isInFrustum(frustumPlanes: Plane[]): boolean;
  22828. /**
  22829. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22830. * @param frustumPlanes defines the frustum planes
  22831. * @returns true if the submesh is inside the frustum
  22832. */
  22833. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22834. /**
  22835. * Renders the submesh
  22836. * @param enableAlphaMode defines if alpha needs to be used
  22837. * @returns the submesh
  22838. */
  22839. render(enableAlphaMode: boolean): SubMesh;
  22840. /**
  22841. * @hidden
  22842. */
  22843. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22844. /**
  22845. * Checks if the submesh intersects with a ray
  22846. * @param ray defines the ray to test
  22847. * @returns true is the passed ray intersects the submesh bounding box
  22848. */
  22849. canIntersects(ray: Ray): boolean;
  22850. /**
  22851. * Intersects current submesh with a ray
  22852. * @param ray defines the ray to test
  22853. * @param positions defines mesh's positions array
  22854. * @param indices defines mesh's indices array
  22855. * @param fastCheck defines if only bounding info should be used
  22856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22857. * @returns intersection info or null if no intersection
  22858. */
  22859. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22860. /** @hidden */
  22861. private _intersectLines;
  22862. /** @hidden */
  22863. private _intersectTriangles;
  22864. /** @hidden */
  22865. _rebuild(): void;
  22866. /**
  22867. * Creates a new submesh from the passed mesh
  22868. * @param newMesh defines the new hosting mesh
  22869. * @param newRenderingMesh defines an optional rendering mesh
  22870. * @returns the new submesh
  22871. */
  22872. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22873. /**
  22874. * Release associated resources
  22875. */
  22876. dispose(): void;
  22877. /**
  22878. * Gets the class name
  22879. * @returns the string "SubMesh".
  22880. */
  22881. getClassName(): string;
  22882. /**
  22883. * Creates a new submesh from indices data
  22884. * @param materialIndex the index of the main mesh material
  22885. * @param startIndex the index where to start the copy in the mesh indices array
  22886. * @param indexCount the number of indices to copy then from the startIndex
  22887. * @param mesh the main mesh to create the submesh from
  22888. * @param renderingMesh the optional rendering mesh
  22889. * @returns a new submesh
  22890. */
  22891. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22892. }
  22893. }
  22894. declare module "babylonjs/Meshes/geometry" {
  22895. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22896. import { Scene } from "babylonjs/scene";
  22897. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22898. import { Engine } from "babylonjs/Engines/engine";
  22899. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22901. import { Effect } from "babylonjs/Materials/effect";
  22902. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22903. import { Mesh } from "babylonjs/Meshes/mesh";
  22904. /**
  22905. * Class used to store geometry data (vertex buffers + index buffer)
  22906. */
  22907. export class Geometry implements IGetSetVerticesData {
  22908. /**
  22909. * Gets or sets the ID of the geometry
  22910. */
  22911. id: string;
  22912. /**
  22913. * Gets or sets the unique ID of the geometry
  22914. */
  22915. uniqueId: number;
  22916. /**
  22917. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22918. */
  22919. delayLoadState: number;
  22920. /**
  22921. * Gets the file containing the data to load when running in delay load state
  22922. */
  22923. delayLoadingFile: Nullable<string>;
  22924. /**
  22925. * Callback called when the geometry is updated
  22926. */
  22927. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22928. private _scene;
  22929. private _engine;
  22930. private _meshes;
  22931. private _totalVertices;
  22932. /** @hidden */
  22933. _indices: IndicesArray;
  22934. /** @hidden */
  22935. _vertexBuffers: {
  22936. [key: string]: VertexBuffer;
  22937. };
  22938. private _isDisposed;
  22939. private _extend;
  22940. private _boundingBias;
  22941. /** @hidden */
  22942. _delayInfo: Array<string>;
  22943. private _indexBuffer;
  22944. private _indexBufferIsUpdatable;
  22945. /** @hidden */
  22946. _boundingInfo: Nullable<BoundingInfo>;
  22947. /** @hidden */
  22948. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22949. /** @hidden */
  22950. _softwareSkinningFrameId: number;
  22951. private _vertexArrayObjects;
  22952. private _updatable;
  22953. /** @hidden */
  22954. _positions: Nullable<Vector3[]>;
  22955. /**
  22956. * 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
  22957. */
  22958. /**
  22959. * 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
  22960. */
  22961. boundingBias: Vector2;
  22962. /**
  22963. * Static function used to attach a new empty geometry to a mesh
  22964. * @param mesh defines the mesh to attach the geometry to
  22965. * @returns the new Geometry
  22966. */
  22967. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22968. /**
  22969. * Creates a new geometry
  22970. * @param id defines the unique ID
  22971. * @param scene defines the hosting scene
  22972. * @param vertexData defines the VertexData used to get geometry data
  22973. * @param updatable defines if geometry must be updatable (false by default)
  22974. * @param mesh defines the mesh that will be associated with the geometry
  22975. */
  22976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22977. /**
  22978. * Gets the current extend of the geometry
  22979. */
  22980. readonly extend: {
  22981. minimum: Vector3;
  22982. maximum: Vector3;
  22983. };
  22984. /**
  22985. * Gets the hosting scene
  22986. * @returns the hosting Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Gets the hosting engine
  22991. * @returns the hosting Engine
  22992. */
  22993. getEngine(): Engine;
  22994. /**
  22995. * Defines if the geometry is ready to use
  22996. * @returns true if the geometry is ready to be used
  22997. */
  22998. isReady(): boolean;
  22999. /**
  23000. * Gets a value indicating that the geometry should not be serialized
  23001. */
  23002. readonly doNotSerialize: boolean;
  23003. /** @hidden */
  23004. _rebuild(): void;
  23005. /**
  23006. * Affects all geometry data in one call
  23007. * @param vertexData defines the geometry data
  23008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23009. */
  23010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23011. /**
  23012. * Set specific vertex data
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the vertex data to use
  23015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23017. */
  23018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23019. /**
  23020. * Removes a specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. */
  23023. removeVerticesData(kind: string): void;
  23024. /**
  23025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23026. * @param buffer defines the vertex buffer to use
  23027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23028. */
  23029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23030. /**
  23031. * Update a specific vertex buffer
  23032. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23033. * It will do nothing if the buffer is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param offset defines the offset in the target buffer where to store the data
  23037. * @param useBytes set to true if the offset is in bytes
  23038. */
  23039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23040. /**
  23041. * Update a specific vertex buffer
  23042. * This function will create a new buffer if the current one is not updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @param data defines the data to use
  23045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23048. private _updateBoundingInfo;
  23049. /** @hidden */
  23050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23051. /**
  23052. * Gets total number of vertices
  23053. * @returns the total number of vertices
  23054. */
  23055. getTotalVertices(): number;
  23056. /**
  23057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23058. * @param kind defines the data kind (Position, normal, etc...)
  23059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23061. * @returns a float array containing vertex data
  23062. */
  23063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23064. /**
  23065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23066. * @param kind defines the data kind (Position, normal, etc...)
  23067. * @returns true if the vertex buffer with the specified kind is updatable
  23068. */
  23069. isVertexBufferUpdatable(kind: string): boolean;
  23070. /**
  23071. * Gets a specific vertex buffer
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @returns a VertexBuffer
  23074. */
  23075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23076. /**
  23077. * Returns all vertex buffers
  23078. * @return an object holding all vertex buffers indexed by kind
  23079. */
  23080. getVertexBuffers(): Nullable<{
  23081. [key: string]: VertexBuffer;
  23082. }>;
  23083. /**
  23084. * Gets a boolean indicating if specific vertex buffer is present
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if data is present
  23087. */
  23088. isVerticesDataPresent(kind: string): boolean;
  23089. /**
  23090. * Gets a list of all attached data kinds (Position, normal, etc...)
  23091. * @returns a list of string containing all kinds
  23092. */
  23093. getVerticesDataKinds(): string[];
  23094. /**
  23095. * Update index buffer
  23096. * @param indices defines the indices to store in the index buffer
  23097. * @param offset defines the offset in the target buffer where to store the data
  23098. * @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)
  23099. */
  23100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23101. /**
  23102. * Creates a new index buffer
  23103. * @param indices defines the indices to store in the index buffer
  23104. * @param totalVertices defines the total number of vertices (could be null)
  23105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23106. */
  23107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23108. /**
  23109. * Return the total number of indices
  23110. * @returns the total number of indices
  23111. */
  23112. getTotalIndices(): number;
  23113. /**
  23114. * Gets the index buffer array
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the index buffer array
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Gets the index buffer
  23122. * @return the index buffer
  23123. */
  23124. getIndexBuffer(): Nullable<WebGLBuffer>;
  23125. /** @hidden */
  23126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23127. /**
  23128. * Release the associated resources for a specific mesh
  23129. * @param mesh defines the source mesh
  23130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23131. */
  23132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23133. /**
  23134. * Apply current geometry to a given mesh
  23135. * @param mesh defines the mesh to apply geometry to
  23136. */
  23137. applyToMesh(mesh: Mesh): void;
  23138. private _updateExtend;
  23139. private _applyToMesh;
  23140. private notifyUpdate;
  23141. /**
  23142. * Load the geometry if it was flagged as delay loaded
  23143. * @param scene defines the hosting scene
  23144. * @param onLoaded defines a callback called when the geometry is loaded
  23145. */
  23146. load(scene: Scene, onLoaded?: () => void): void;
  23147. private _queueLoad;
  23148. /**
  23149. * Invert the geometry to move from a right handed system to a left handed one.
  23150. */
  23151. toLeftHanded(): void;
  23152. /** @hidden */
  23153. _resetPointsArrayCache(): void;
  23154. /** @hidden */
  23155. _generatePointsArray(): boolean;
  23156. /**
  23157. * Gets a value indicating if the geometry is disposed
  23158. * @returns true if the geometry was disposed
  23159. */
  23160. isDisposed(): boolean;
  23161. private _disposeVertexArrayObjects;
  23162. /**
  23163. * Free all associated resources
  23164. */
  23165. dispose(): void;
  23166. /**
  23167. * Clone the current geometry into a new geometry
  23168. * @param id defines the unique ID of the new geometry
  23169. * @returns a new geometry object
  23170. */
  23171. copy(id: string): Geometry;
  23172. /**
  23173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23174. * @return a JSON representation of the current geometry data (without the vertices data)
  23175. */
  23176. serialize(): any;
  23177. private toNumberArray;
  23178. /**
  23179. * Serialize all vertices data into a JSON oject
  23180. * @returns a JSON representation of the current geometry data
  23181. */
  23182. serializeVerticeData(): any;
  23183. /**
  23184. * Extracts a clone of a mesh geometry
  23185. * @param mesh defines the source mesh
  23186. * @param id defines the unique ID of the new geometry object
  23187. * @returns the new geometry object
  23188. */
  23189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23190. /**
  23191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23193. * Be aware Math.random() could cause collisions, but:
  23194. * "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"
  23195. * @returns a string containing a new GUID
  23196. */
  23197. static RandomId(): string;
  23198. /** @hidden */
  23199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23200. private static _CleanMatricesWeights;
  23201. /**
  23202. * Create a new geometry from persisted data (Using .babylon file format)
  23203. * @param parsedVertexData defines the persisted data
  23204. * @param scene defines the hosting scene
  23205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23206. * @returns the new geometry object
  23207. */
  23208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23209. }
  23210. }
  23211. declare module "babylonjs/Meshes/mesh.vertexData" {
  23212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23213. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23214. import { Geometry } from "babylonjs/Meshes/geometry";
  23215. import { Mesh } from "babylonjs/Meshes/mesh";
  23216. /**
  23217. * Define an interface for all classes that will get and set the data on vertices
  23218. */
  23219. export interface IGetSetVerticesData {
  23220. /**
  23221. * Gets a boolean indicating if specific vertex data is present
  23222. * @param kind defines the vertex data kind to use
  23223. * @returns true is data kind is present
  23224. */
  23225. isVerticesDataPresent(kind: string): boolean;
  23226. /**
  23227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23228. * @param kind defines the data kind (Position, normal, etc...)
  23229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23231. * @returns a float array containing vertex data
  23232. */
  23233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23234. /**
  23235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23236. * @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.
  23237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23238. * @returns the indices array or an empty array if the mesh has no geometry
  23239. */
  23240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23241. /**
  23242. * Set specific vertex data
  23243. * @param kind defines the data kind (Position, normal, etc...)
  23244. * @param data defines the vertex data to use
  23245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23247. */
  23248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23249. /**
  23250. * Update a specific associated vertex buffer
  23251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23252. * - VertexBuffer.PositionKind
  23253. * - VertexBuffer.UVKind
  23254. * - VertexBuffer.UV2Kind
  23255. * - VertexBuffer.UV3Kind
  23256. * - VertexBuffer.UV4Kind
  23257. * - VertexBuffer.UV5Kind
  23258. * - VertexBuffer.UV6Kind
  23259. * - VertexBuffer.ColorKind
  23260. * - VertexBuffer.MatricesIndicesKind
  23261. * - VertexBuffer.MatricesIndicesExtraKind
  23262. * - VertexBuffer.MatricesWeightsKind
  23263. * - VertexBuffer.MatricesWeightsExtraKind
  23264. * @param data defines the data source
  23265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23266. * @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)
  23267. */
  23268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23269. /**
  23270. * Creates a new index buffer
  23271. * @param indices defines the indices to store in the index buffer
  23272. * @param totalVertices defines the total number of vertices (could be null)
  23273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23274. */
  23275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23276. }
  23277. /**
  23278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23279. */
  23280. export class VertexData {
  23281. /**
  23282. * Mesh side orientation : usually the external or front surface
  23283. */
  23284. static readonly FRONTSIDE: number;
  23285. /**
  23286. * Mesh side orientation : usually the internal or back surface
  23287. */
  23288. static readonly BACKSIDE: number;
  23289. /**
  23290. * Mesh side orientation : both internal and external or front and back surfaces
  23291. */
  23292. static readonly DOUBLESIDE: number;
  23293. /**
  23294. * Mesh side orientation : by default, `FRONTSIDE`
  23295. */
  23296. static readonly DEFAULTSIDE: number;
  23297. /**
  23298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23299. */
  23300. positions: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. normals: Nullable<FloatArray>;
  23305. /**
  23306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23307. */
  23308. tangents: Nullable<FloatArray>;
  23309. /**
  23310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs: Nullable<FloatArray>;
  23313. /**
  23314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs2: Nullable<FloatArray>;
  23317. /**
  23318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs3: Nullable<FloatArray>;
  23321. /**
  23322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs4: Nullable<FloatArray>;
  23325. /**
  23326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs5: Nullable<FloatArray>;
  23329. /**
  23330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23331. */
  23332. uvs6: Nullable<FloatArray>;
  23333. /**
  23334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23335. */
  23336. colors: Nullable<FloatArray>;
  23337. /**
  23338. * 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).
  23339. */
  23340. matricesIndices: Nullable<FloatArray>;
  23341. /**
  23342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23343. */
  23344. matricesWeights: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible indices
  23347. */
  23348. matricesIndicesExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array extending the number of possible weights when the number of indices is extended
  23351. */
  23352. matricesWeightsExtra: Nullable<FloatArray>;
  23353. /**
  23354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23355. */
  23356. indices: Nullable<IndicesArray>;
  23357. /**
  23358. * Uses the passed data array to set the set the values for the specified kind of data
  23359. * @param data a linear array of floating numbers
  23360. * @param kind the type of data that is being set, eg positions, colors etc
  23361. */
  23362. set(data: FloatArray, kind: string): void;
  23363. /**
  23364. * Associates the vertexData to the passed Mesh.
  23365. * Sets it as updatable or not (default `false`)
  23366. * @param mesh the mesh the vertexData is applied to
  23367. * @param updatable when used and having the value true allows new data to update the vertexData
  23368. * @returns the VertexData
  23369. */
  23370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23371. /**
  23372. * Associates the vertexData to the passed Geometry.
  23373. * Sets it as updatable or not (default `false`)
  23374. * @param geometry the geometry the vertexData is applied to
  23375. * @param updatable when used and having the value true allows new data to update the vertexData
  23376. * @returns VertexData
  23377. */
  23378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23379. /**
  23380. * Updates the associated mesh
  23381. * @param mesh the mesh to be updated
  23382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23383. * @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
  23384. * @returns VertexData
  23385. */
  23386. updateMesh(mesh: Mesh): VertexData;
  23387. /**
  23388. * Updates the associated geometry
  23389. * @param geometry the geometry to be updated
  23390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23391. * @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
  23392. * @returns VertexData.
  23393. */
  23394. updateGeometry(geometry: Geometry): VertexData;
  23395. private _applyTo;
  23396. private _update;
  23397. /**
  23398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23399. * @param matrix the transforming matrix
  23400. * @returns the VertexData
  23401. */
  23402. transform(matrix: Matrix): VertexData;
  23403. /**
  23404. * Merges the passed VertexData into the current one
  23405. * @param other the VertexData to be merged into the current one
  23406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23407. * @returns the modified VertexData
  23408. */
  23409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23410. private _mergeElement;
  23411. private _validate;
  23412. /**
  23413. * Serializes the VertexData
  23414. * @returns a serialized object
  23415. */
  23416. serialize(): any;
  23417. /**
  23418. * Extracts the vertexData from a mesh
  23419. * @param mesh the mesh from which to extract the VertexData
  23420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23422. * @returns the object VertexData associated to the passed mesh
  23423. */
  23424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23425. /**
  23426. * Extracts the vertexData from the geometry
  23427. * @param geometry the geometry from which to extract the VertexData
  23428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23430. * @returns the object VertexData associated to the passed mesh
  23431. */
  23432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23433. private static _ExtractFrom;
  23434. /**
  23435. * Creates the VertexData for a Ribbon
  23436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23437. * * pathArray array of paths, each of which an array of successive Vector3
  23438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23440. * * 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
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23447. * @returns the VertexData of the ribbon
  23448. */
  23449. static CreateRibbon(options: {
  23450. pathArray: Vector3[][];
  23451. closeArray?: boolean;
  23452. closePath?: boolean;
  23453. offset?: number;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. invertUV?: boolean;
  23458. uvs?: Vector2[];
  23459. colors?: Color4[];
  23460. }): VertexData;
  23461. /**
  23462. * Creates the VertexData for a box
  23463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23471. * * 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)
  23472. * * 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)
  23473. * @returns the VertexData of the box
  23474. */
  23475. static CreateBox(options: {
  23476. size?: number;
  23477. width?: number;
  23478. height?: number;
  23479. depth?: number;
  23480. faceUV?: Vector4[];
  23481. faceColors?: Color4[];
  23482. sideOrientation?: number;
  23483. frontUVs?: Vector4;
  23484. backUVs?: Vector4;
  23485. }): VertexData;
  23486. /**
  23487. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23489. * * segments sets the number of horizontal strips optional, default 32
  23490. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23491. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23492. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23493. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23494. * * 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
  23495. * * 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
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the ellipsoid
  23500. */
  23501. static CreateSphere(options: {
  23502. segments?: number;
  23503. diameter?: number;
  23504. diameterX?: number;
  23505. diameterY?: number;
  23506. diameterZ?: number;
  23507. arc?: number;
  23508. slice?: number;
  23509. sideOrientation?: number;
  23510. frontUVs?: Vector4;
  23511. backUVs?: Vector4;
  23512. }): VertexData;
  23513. /**
  23514. * Creates the VertexData for a cylinder, cone or prism
  23515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23516. * * height sets the height (y direction) of the cylinder, optional, default 2
  23517. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23518. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23519. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23520. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23521. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23522. * * 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
  23523. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23525. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23526. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23528. * * 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)
  23529. * * 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)
  23530. * @returns the VertexData of the cylinder, cone or prism
  23531. */
  23532. static CreateCylinder(options: {
  23533. height?: number;
  23534. diameterTop?: number;
  23535. diameterBottom?: number;
  23536. diameter?: number;
  23537. tessellation?: number;
  23538. subdivisions?: number;
  23539. arc?: number;
  23540. faceColors?: Color4[];
  23541. faceUV?: Vector4[];
  23542. hasRings?: boolean;
  23543. enclose?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }): VertexData;
  23548. /**
  23549. * Creates the VertexData for a torus
  23550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23551. * * diameter the diameter of the torus, optional default 1
  23552. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23553. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23555. * * 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)
  23556. * * 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)
  23557. * @returns the VertexData of the torus
  23558. */
  23559. static CreateTorus(options: {
  23560. diameter?: number;
  23561. thickness?: number;
  23562. tessellation?: number;
  23563. sideOrientation?: number;
  23564. frontUVs?: Vector4;
  23565. backUVs?: Vector4;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData of the LineSystem
  23569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23570. * - lines an array of lines, each line being an array of successive Vector3
  23571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23572. * @returns the VertexData of the LineSystem
  23573. */
  23574. static CreateLineSystem(options: {
  23575. lines: Vector3[][];
  23576. colors?: Nullable<Color4[][]>;
  23577. }): VertexData;
  23578. /**
  23579. * Create the VertexData for a DashedLines
  23580. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23581. * - points an array successive Vector3
  23582. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23583. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23584. * - dashNb the intended total number of dashes, optional, default 200
  23585. * @returns the VertexData for the DashedLines
  23586. */
  23587. static CreateDashedLines(options: {
  23588. points: Vector3[];
  23589. dashSize?: number;
  23590. gapSize?: number;
  23591. dashNb?: number;
  23592. }): VertexData;
  23593. /**
  23594. * Creates the VertexData for a Ground
  23595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23596. * - width the width (x direction) of the ground, optional, default 1
  23597. * - height the height (z direction) of the ground, optional, default 1
  23598. * - subdivisions the number of subdivisions per side, optional, default 1
  23599. * @returns the VertexData of the Ground
  23600. */
  23601. static CreateGround(options: {
  23602. width?: number;
  23603. height?: number;
  23604. subdivisions?: number;
  23605. subdivisionsX?: number;
  23606. subdivisionsY?: number;
  23607. }): VertexData;
  23608. /**
  23609. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23610. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23611. * * xmin the ground minimum X coordinate, optional, default -1
  23612. * * zmin the ground minimum Z coordinate, optional, default -1
  23613. * * xmax the ground maximum X coordinate, optional, default 1
  23614. * * zmax the ground maximum Z coordinate, optional, default 1
  23615. * * 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}
  23616. * * 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}
  23617. * @returns the VertexData of the TiledGround
  23618. */
  23619. static CreateTiledGround(options: {
  23620. xmin: number;
  23621. zmin: number;
  23622. xmax: number;
  23623. zmax: number;
  23624. subdivisions?: {
  23625. w: number;
  23626. h: number;
  23627. };
  23628. precision?: {
  23629. w: number;
  23630. h: number;
  23631. };
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData of the Ground designed from a heightmap
  23635. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23636. * * width the width (x direction) of the ground
  23637. * * height the height (z direction) of the ground
  23638. * * subdivisions the number of subdivisions per side
  23639. * * minHeight the minimum altitude on the ground, optional, default 0
  23640. * * maxHeight the maximum altitude on the ground, optional default 1
  23641. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23642. * * buffer the array holding the image color data
  23643. * * bufferWidth the width of image
  23644. * * bufferHeight the height of image
  23645. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23646. * @returns the VertexData of the Ground designed from a heightmap
  23647. */
  23648. static CreateGroundFromHeightMap(options: {
  23649. width: number;
  23650. height: number;
  23651. subdivisions: number;
  23652. minHeight: number;
  23653. maxHeight: number;
  23654. colorFilter: Color3;
  23655. buffer: Uint8Array;
  23656. bufferWidth: number;
  23657. bufferHeight: number;
  23658. alphaFilter: number;
  23659. }): VertexData;
  23660. /**
  23661. * Creates the VertexData for a Plane
  23662. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23663. * * size sets the width and height of the plane to the value of size, optional default 1
  23664. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23665. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23667. * * 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)
  23668. * * 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)
  23669. * @returns the VertexData of the box
  23670. */
  23671. static CreatePlane(options: {
  23672. size?: number;
  23673. width?: number;
  23674. height?: number;
  23675. sideOrientation?: number;
  23676. frontUVs?: Vector4;
  23677. backUVs?: Vector4;
  23678. }): VertexData;
  23679. /**
  23680. * Creates the VertexData of the Disc or regular Polygon
  23681. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23682. * * radius the radius of the disc, optional default 0.5
  23683. * * tessellation the number of polygon sides, optional, default 64
  23684. * * 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
  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 CreateDisc(options: {
  23691. radius?: number;
  23692. tessellation?: number;
  23693. arc?: number;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23700. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23701. * @param polygon a mesh built from polygonTriangulation.build()
  23702. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23703. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23704. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23705. * @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)
  23706. * @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)
  23707. * @returns the VertexData of the Polygon
  23708. */
  23709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23710. /**
  23711. * Creates the VertexData of the IcoSphere
  23712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23713. * * radius the radius of the IcoSphere, optional default 1
  23714. * * radiusX allows stretching in the x direction, optional, default radius
  23715. * * radiusY allows stretching in the y direction, optional, default radius
  23716. * * radiusZ allows stretching in the z direction, optional, default radius
  23717. * * flat when true creates a flat shaded mesh, optional, default true
  23718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23720. * * 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)
  23721. * * 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)
  23722. * @returns the VertexData of the IcoSphere
  23723. */
  23724. static CreateIcoSphere(options: {
  23725. radius?: number;
  23726. radiusX?: number;
  23727. radiusY?: number;
  23728. radiusZ?: number;
  23729. flat?: boolean;
  23730. subdivisions?: number;
  23731. sideOrientation?: number;
  23732. frontUVs?: Vector4;
  23733. backUVs?: Vector4;
  23734. }): VertexData;
  23735. /**
  23736. * Creates the VertexData for a Polyhedron
  23737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23738. * * type provided types are:
  23739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23740. * * 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)
  23741. * * size the size of the IcoSphere, optional default 1
  23742. * * sizeX allows stretching in the x direction, optional, default size
  23743. * * sizeY allows stretching in the y direction, optional, default size
  23744. * * sizeZ allows stretching in the z direction, optional, default size
  23745. * * 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
  23746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23748. * * flat when true creates a flat shaded mesh, optional, default true
  23749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23751. * * 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)
  23752. * * 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)
  23753. * @returns the VertexData of the Polyhedron
  23754. */
  23755. static CreatePolyhedron(options: {
  23756. type?: number;
  23757. size?: number;
  23758. sizeX?: number;
  23759. sizeY?: number;
  23760. sizeZ?: number;
  23761. custom?: any;
  23762. faceUV?: Vector4[];
  23763. faceColors?: Color4[];
  23764. flat?: boolean;
  23765. sideOrientation?: number;
  23766. frontUVs?: Vector4;
  23767. backUVs?: Vector4;
  23768. }): VertexData;
  23769. /**
  23770. * Creates the VertexData for a TorusKnot
  23771. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23772. * * radius the radius of the torus knot, optional, default 2
  23773. * * tube the thickness of the tube, optional, default 0.5
  23774. * * radialSegments the number of sides on each tube segments, optional, default 32
  23775. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23776. * * p the number of windings around the z axis, optional, default 2
  23777. * * q the number of windings around the x axis, optional, default 3
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the Torus Knot
  23782. */
  23783. static CreateTorusKnot(options: {
  23784. radius?: number;
  23785. tube?: number;
  23786. radialSegments?: number;
  23787. tubularSegments?: number;
  23788. p?: number;
  23789. q?: number;
  23790. sideOrientation?: number;
  23791. frontUVs?: Vector4;
  23792. backUVs?: Vector4;
  23793. }): VertexData;
  23794. /**
  23795. * Compute normals for given positions and indices
  23796. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23797. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23798. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23799. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23800. * * facetNormals : optional array of facet normals (vector3)
  23801. * * facetPositions : optional array of facet positions (vector3)
  23802. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23803. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23804. * * bInfo : optional bounding info, required for facetPartitioning computation
  23805. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23806. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23807. * * useRightHandedSystem: optional boolean to for right handed system computation
  23808. * * depthSort : optional boolean to enable the facet depth sort computation
  23809. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23810. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23811. */
  23812. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23813. facetNormals?: any;
  23814. facetPositions?: any;
  23815. facetPartitioning?: any;
  23816. ratio?: number;
  23817. bInfo?: any;
  23818. bbSize?: Vector3;
  23819. subDiv?: any;
  23820. useRightHandedSystem?: boolean;
  23821. depthSort?: boolean;
  23822. distanceTo?: Vector3;
  23823. depthSortedFacets?: any;
  23824. }): void;
  23825. /** @hidden */
  23826. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23827. /**
  23828. * Applies VertexData created from the imported parameters to the geometry
  23829. * @param parsedVertexData the parsed data from an imported file
  23830. * @param geometry the geometry to apply the VertexData to
  23831. */
  23832. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23833. }
  23834. }
  23835. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23836. import { Nullable } from "babylonjs/types";
  23837. import { Scene } from "babylonjs/scene";
  23838. import { Vector4 } from "babylonjs/Maths/math";
  23839. import { Mesh } from "babylonjs/Meshes/mesh";
  23840. /**
  23841. * Class containing static functions to help procedurally build meshes
  23842. */
  23843. export class DiscBuilder {
  23844. /**
  23845. * Creates a plane polygonal mesh. By default, this is a disc
  23846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23847. * * 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
  23848. * * 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
  23849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23852. * @param name defines the name of the mesh
  23853. * @param options defines the options used to create the mesh
  23854. * @param scene defines the hosting scene
  23855. * @returns the plane polygonal mesh
  23856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23857. */
  23858. static CreateDisc(name: string, options: {
  23859. radius?: number;
  23860. tessellation?: number;
  23861. arc?: number;
  23862. updatable?: boolean;
  23863. sideOrientation?: number;
  23864. frontUVs?: Vector4;
  23865. backUVs?: Vector4;
  23866. }, scene?: Nullable<Scene>): Mesh;
  23867. }
  23868. }
  23869. declare module "babylonjs/Particles/solidParticleSystem" {
  23870. import { Vector3 } from "babylonjs/Maths/math";
  23871. import { Mesh } from "babylonjs/Meshes/mesh";
  23872. import { Scene, IDisposable } from "babylonjs/scene";
  23873. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23874. /**
  23875. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23876. *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.
  23877. * The SPS is also a particle system. It provides some methods to manage the particles.
  23878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23879. *
  23880. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23881. */
  23882. export class SolidParticleSystem implements IDisposable {
  23883. /**
  23884. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23885. * Example : var p = SPS.particles[i];
  23886. */
  23887. particles: SolidParticle[];
  23888. /**
  23889. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23890. */
  23891. nbParticles: number;
  23892. /**
  23893. * If the particles must ever face the camera (default false). Useful for planar particles.
  23894. */
  23895. billboard: boolean;
  23896. /**
  23897. * Recompute normals when adding a shape
  23898. */
  23899. recomputeNormals: boolean;
  23900. /**
  23901. * This a counter ofr your own usage. It's not set by any SPS functions.
  23902. */
  23903. counter: number;
  23904. /**
  23905. * The SPS name. This name is also given to the underlying mesh.
  23906. */
  23907. name: string;
  23908. /**
  23909. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23910. */
  23911. mesh: Mesh;
  23912. /**
  23913. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23915. */
  23916. vars: any;
  23917. /**
  23918. * This array is populated when the SPS is set as 'pickable'.
  23919. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23920. * Each element of this array is an object `{idx: int, faceId: int}`.
  23921. * `idx` is the picked particle index in the `SPS.particles` array
  23922. * `faceId` is the picked face index counted within this particle.
  23923. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23924. */
  23925. pickedParticles: {
  23926. idx: number;
  23927. faceId: number;
  23928. }[];
  23929. /**
  23930. * This array is populated when `enableDepthSort` is set to true.
  23931. * Each element of this array is an instance of the class DepthSortedParticle.
  23932. */
  23933. depthSortedParticles: DepthSortedParticle[];
  23934. /**
  23935. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23936. * @hidden
  23937. */
  23938. _bSphereOnly: boolean;
  23939. /**
  23940. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23941. * @hidden
  23942. */
  23943. _bSphereRadiusFactor: number;
  23944. private _scene;
  23945. private _positions;
  23946. private _indices;
  23947. private _normals;
  23948. private _colors;
  23949. private _uvs;
  23950. private _indices32;
  23951. private _positions32;
  23952. private _normals32;
  23953. private _fixedNormal32;
  23954. private _colors32;
  23955. private _uvs32;
  23956. private _index;
  23957. private _updatable;
  23958. private _pickable;
  23959. private _isVisibilityBoxLocked;
  23960. private _alwaysVisible;
  23961. private _depthSort;
  23962. private _shapeCounter;
  23963. private _copy;
  23964. private _color;
  23965. private _computeParticleColor;
  23966. private _computeParticleTexture;
  23967. private _computeParticleRotation;
  23968. private _computeParticleVertex;
  23969. private _computeBoundingBox;
  23970. private _depthSortParticles;
  23971. private _camera;
  23972. private _mustUnrotateFixedNormals;
  23973. private _particlesIntersect;
  23974. private _needs32Bits;
  23975. /**
  23976. * Creates a SPS (Solid Particle System) object.
  23977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23978. * @param scene (Scene) is the scene in which the SPS is added.
  23979. * @param options defines the options of the sps e.g.
  23980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23983. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23984. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23985. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23986. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23987. */
  23988. constructor(name: string, scene: Scene, options?: {
  23989. updatable?: boolean;
  23990. isPickable?: boolean;
  23991. enableDepthSort?: boolean;
  23992. particleIntersection?: boolean;
  23993. boundingSphereOnly?: boolean;
  23994. bSphereRadiusFactor?: number;
  23995. });
  23996. /**
  23997. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23998. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23999. * @returns the created mesh
  24000. */
  24001. buildMesh(): Mesh;
  24002. /**
  24003. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24004. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24005. * Thus the particles generated from `digest()` have their property `position` set yet.
  24006. * @param mesh ( Mesh ) is the mesh to be digested
  24007. * @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
  24008. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24009. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24010. * @returns the current SPS
  24011. */
  24012. digest(mesh: Mesh, options?: {
  24013. facetNb?: number;
  24014. number?: number;
  24015. delta?: number;
  24016. }): SolidParticleSystem;
  24017. private _unrotateFixedNormals;
  24018. private _resetCopy;
  24019. private _meshBuilder;
  24020. private _posToShape;
  24021. private _uvsToShapeUV;
  24022. private _addParticle;
  24023. /**
  24024. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24025. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24026. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24027. * @param nb (positive integer) the number of particles to be created from this model
  24028. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24029. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24030. * @returns the number of shapes in the system
  24031. */
  24032. addShape(mesh: Mesh, nb: number, options?: {
  24033. positionFunction?: any;
  24034. vertexFunction?: any;
  24035. }): number;
  24036. private _rebuildParticle;
  24037. /**
  24038. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24039. * @returns the SPS.
  24040. */
  24041. rebuildMesh(): SolidParticleSystem;
  24042. /**
  24043. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24044. * This method calls `updateParticle()` for each particle of the SPS.
  24045. * For an animated SPS, it is usually called within the render loop.
  24046. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24047. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24048. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24049. * @returns the SPS.
  24050. */
  24051. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24052. /**
  24053. * Disposes the SPS.
  24054. */
  24055. dispose(): void;
  24056. /**
  24057. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24059. * @returns the SPS.
  24060. */
  24061. refreshVisibleSize(): SolidParticleSystem;
  24062. /**
  24063. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24064. * @param size the size (float) of the visibility box
  24065. * note : this doesn't lock the SPS mesh bounding box.
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. setVisibilityBox(size: number): void;
  24069. /**
  24070. * Gets whether the SPS as always visible or not
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Sets the SPS as always visible or not
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isAlwaysVisible: boolean;
  24078. /**
  24079. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. /**
  24083. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24085. */
  24086. isVisibilityBoxLocked: boolean;
  24087. /**
  24088. * Tells to `setParticles()` to compute the particle rotations or not.
  24089. * Default value : true. The SPS is faster when it's set to false.
  24090. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24091. */
  24092. /**
  24093. * Gets if `setParticles()` computes the particle rotations or not.
  24094. * Default value : true. The SPS is faster when it's set to false.
  24095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24096. */
  24097. computeParticleRotation: boolean;
  24098. /**
  24099. * Tells to `setParticles()` to compute the particle colors or not.
  24100. * Default value : true. The SPS is faster when it's set to false.
  24101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24102. */
  24103. /**
  24104. * Gets if `setParticles()` computes the particle colors or not.
  24105. * Default value : true. The SPS is faster when it's set to false.
  24106. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24107. */
  24108. computeParticleColor: boolean;
  24109. /**
  24110. * Gets if `setParticles()` computes the particle textures or not.
  24111. * Default value : true. The SPS is faster when it's set to false.
  24112. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24113. */
  24114. computeParticleTexture: boolean;
  24115. /**
  24116. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24117. * Default value : false. The SPS is faster when it's set to false.
  24118. * Note : the particle custom vertex positions aren't stored values.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24122. * Default value : false. The SPS is faster when it's set to false.
  24123. * Note : the particle custom vertex positions aren't stored values.
  24124. */
  24125. computeParticleVertex: boolean;
  24126. /**
  24127. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24131. */
  24132. computeBoundingBox: boolean;
  24133. /**
  24134. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24135. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24136. * Default : `true`
  24137. */
  24138. /**
  24139. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24140. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24141. * Default : `true`
  24142. */
  24143. depthSortParticles: boolean;
  24144. /**
  24145. * This function does nothing. It may be overwritten to set all the particle first values.
  24146. * The SPS doesn't call this function, you may have to call it by your own.
  24147. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24148. */
  24149. initParticles(): void;
  24150. /**
  24151. * This function does nothing. It may be overwritten to recycle a particle.
  24152. * The SPS doesn't call this function, you may have to call it by your own.
  24153. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24154. * @param particle The particle to recycle
  24155. * @returns the recycled particle
  24156. */
  24157. recycleParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a particle : this function should be overwritten by the user.
  24160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24162. * @example : just set a particle position or velocity and recycle conditions
  24163. * @param particle The particle to update
  24164. * @returns the updated particle
  24165. */
  24166. updateParticle(particle: SolidParticle): SolidParticle;
  24167. /**
  24168. * Updates a vertex of a particle : it can be overwritten by the user.
  24169. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24170. * @param particle the current particle
  24171. * @param vertex the current index of the current particle
  24172. * @param pt the index of the current vertex in the particle shape
  24173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24174. * @example : just set a vertex particle position
  24175. * @returns the updated vertex
  24176. */
  24177. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24178. /**
  24179. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. /**
  24187. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24188. * This will be passed three parameters.
  24189. * This does nothing and may be overwritten by the user.
  24190. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24192. * @param update the boolean update value actually passed to setParticles()
  24193. */
  24194. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24195. }
  24196. }
  24197. declare module "babylonjs/Particles/solidParticle" {
  24198. import { Nullable } from "babylonjs/types";
  24199. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24200. import { Mesh } from "babylonjs/Meshes/mesh";
  24201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24202. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24203. /**
  24204. * Represents one particle of a solid particle system.
  24205. */
  24206. export class SolidParticle {
  24207. /**
  24208. * particle global index
  24209. */
  24210. idx: number;
  24211. /**
  24212. * The color of the particle
  24213. */
  24214. color: Nullable<Color4>;
  24215. /**
  24216. * The world space position of the particle.
  24217. */
  24218. position: Vector3;
  24219. /**
  24220. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24221. */
  24222. rotation: Vector3;
  24223. /**
  24224. * The world space rotation quaternion of the particle.
  24225. */
  24226. rotationQuaternion: Nullable<Quaternion>;
  24227. /**
  24228. * The scaling of the particle.
  24229. */
  24230. scaling: Vector3;
  24231. /**
  24232. * The uvs of the particle.
  24233. */
  24234. uvs: Vector4;
  24235. /**
  24236. * The current speed of the particle.
  24237. */
  24238. velocity: Vector3;
  24239. /**
  24240. * The pivot point in the particle local space.
  24241. */
  24242. pivot: Vector3;
  24243. /**
  24244. * Must the particle be translated from its pivot point in its local space ?
  24245. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24246. * Default : false
  24247. */
  24248. translateFromPivot: boolean;
  24249. /**
  24250. * Is the particle active or not ?
  24251. */
  24252. alive: boolean;
  24253. /**
  24254. * Is the particle visible or not ?
  24255. */
  24256. isVisible: boolean;
  24257. /**
  24258. * Index of this particle in the global "positions" array (Internal use)
  24259. * @hidden
  24260. */
  24261. _pos: number;
  24262. /**
  24263. * @hidden Index of this particle in the global "indices" array (Internal use)
  24264. */
  24265. _ind: number;
  24266. /**
  24267. * @hidden ModelShape of this particle (Internal use)
  24268. */
  24269. _model: ModelShape;
  24270. /**
  24271. * ModelShape id of this particle
  24272. */
  24273. shapeId: number;
  24274. /**
  24275. * Index of the particle in its shape id (Internal use)
  24276. */
  24277. idxInShape: number;
  24278. /**
  24279. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24280. */
  24281. _modelBoundingInfo: BoundingInfo;
  24282. /**
  24283. * @hidden Particle BoundingInfo object (Internal use)
  24284. */
  24285. _boundingInfo: BoundingInfo;
  24286. /**
  24287. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24288. */
  24289. _sps: SolidParticleSystem;
  24290. /**
  24291. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24292. */
  24293. _stillInvisible: boolean;
  24294. /**
  24295. * @hidden Last computed particle rotation matrix
  24296. */
  24297. _rotationMatrix: number[];
  24298. /**
  24299. * Parent particle Id, if any.
  24300. * Default null.
  24301. */
  24302. parentId: Nullable<number>;
  24303. /**
  24304. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24305. * The possible values are :
  24306. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24307. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24310. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24311. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24312. * */
  24313. cullingStrategy: number;
  24314. /**
  24315. * @hidden Internal global position in the SPS.
  24316. */
  24317. _globalPosition: Vector3;
  24318. /**
  24319. * Creates a Solid Particle object.
  24320. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24321. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24322. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24323. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24324. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24325. * @param shapeId (integer) is the model shape identifier in the SPS.
  24326. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24327. * @param sps defines the sps it is associated to
  24328. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24329. */
  24330. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24331. /**
  24332. * Legacy support, changed scale to scaling
  24333. */
  24334. /**
  24335. * Legacy support, changed scale to scaling
  24336. */
  24337. scale: Vector3;
  24338. /**
  24339. * Legacy support, changed quaternion to rotationQuaternion
  24340. */
  24341. /**
  24342. * Legacy support, changed quaternion to rotationQuaternion
  24343. */
  24344. quaternion: Nullable<Quaternion>;
  24345. /**
  24346. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24347. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24348. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24349. * @returns true if it intersects
  24350. */
  24351. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24352. /**
  24353. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24354. * A particle is in the frustum if its bounding box intersects the frustum
  24355. * @param frustumPlanes defines the frustum to test
  24356. * @returns true if the particle is in the frustum planes
  24357. */
  24358. isInFrustum(frustumPlanes: Plane[]): boolean;
  24359. /**
  24360. * get the rotation matrix of the particle
  24361. * @hidden
  24362. */
  24363. getRotationMatrix(m: Matrix): void;
  24364. }
  24365. /**
  24366. * Represents the shape of the model used by one particle of a solid particle system.
  24367. * SPS internal tool, don't use it manually.
  24368. */
  24369. export class ModelShape {
  24370. /**
  24371. * The shape id
  24372. * @hidden
  24373. */
  24374. shapeID: number;
  24375. /**
  24376. * flat array of model positions (internal use)
  24377. * @hidden
  24378. */
  24379. _shape: Vector3[];
  24380. /**
  24381. * flat array of model UVs (internal use)
  24382. * @hidden
  24383. */
  24384. _shapeUV: number[];
  24385. /**
  24386. * length of the shape in the model indices array (internal use)
  24387. * @hidden
  24388. */
  24389. _indicesLength: number;
  24390. /**
  24391. * Custom position function (internal use)
  24392. * @hidden
  24393. */
  24394. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24395. /**
  24396. * Custom vertex function (internal use)
  24397. * @hidden
  24398. */
  24399. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24400. /**
  24401. * 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.
  24402. * SPS internal tool, don't use it manually.
  24403. * @hidden
  24404. */
  24405. 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>);
  24406. }
  24407. /**
  24408. * Represents a Depth Sorted Particle in the solid particle system.
  24409. */
  24410. export class DepthSortedParticle {
  24411. /**
  24412. * Index of the particle in the "indices" array
  24413. */
  24414. ind: number;
  24415. /**
  24416. * Length of the particle shape in the "indices" array
  24417. */
  24418. indicesLength: number;
  24419. /**
  24420. * Squared distance from the particle to the camera
  24421. */
  24422. sqDistance: number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Meshes/abstractMesh" {
  24426. import { Observable } from "babylonjs/Misc/observable";
  24427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24428. import { Camera } from "babylonjs/Cameras/camera";
  24429. import { Scene, IDisposable } from "babylonjs/scene";
  24430. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24431. import { Node } from "babylonjs/node";
  24432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24437. import { Material } from "babylonjs/Materials/material";
  24438. import { Light } from "babylonjs/Lights/light";
  24439. import { Skeleton } from "babylonjs/Bones/skeleton";
  24440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24443. import { Ray } from "babylonjs/Culling/ray";
  24444. import { Collider } from "babylonjs/Collisions/collider";
  24445. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24446. /**
  24447. * Class used to store all common mesh properties
  24448. */
  24449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24450. /** No occlusion */
  24451. static OCCLUSION_TYPE_NONE: number;
  24452. /** Occlusion set to optimisitic */
  24453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24454. /** Occlusion set to strict */
  24455. static OCCLUSION_TYPE_STRICT: number;
  24456. /** Use an accurante occlusion algorithm */
  24457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24458. /** Use a conservative occlusion algorithm */
  24459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24461. * Test order :
  24462. * Is the bounding sphere outside the frustum ?
  24463. * If not, are the bounding box vertices outside the frustum ?
  24464. * It not, then the cullable object is in the frustum.
  24465. */
  24466. static readonly CULLINGSTRATEGY_STANDARD: number;
  24467. /** Culling strategy : Bounding Sphere Only.
  24468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24469. * It's also less accurate than the standard because some not visible objects can still be selected.
  24470. * Test : is the bounding sphere outside the frustum ?
  24471. * If not, then the cullable object is in the frustum.
  24472. */
  24473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24474. /** Culling strategy : Optimistic Inclusion.
  24475. * This in an inclusion test first, then the standard exclusion test.
  24476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24477. * 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.
  24478. * Anyway, it's as accurate as the standard strategy.
  24479. * Test :
  24480. * Is the cullable object bounding sphere center in the frustum ?
  24481. * If not, apply the default culling strategy.
  24482. */
  24483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24487. * 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.
  24488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24489. * Test :
  24490. * Is the cullable object bounding sphere center in the frustum ?
  24491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24492. */
  24493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24494. /**
  24495. * No billboard
  24496. */
  24497. static readonly BILLBOARDMODE_NONE: number;
  24498. /** Billboard on X axis */
  24499. static readonly BILLBOARDMODE_X: number;
  24500. /** Billboard on Y axis */
  24501. static readonly BILLBOARDMODE_Y: number;
  24502. /** Billboard on Z axis */
  24503. static readonly BILLBOARDMODE_Z: number;
  24504. /** Billboard on all axes */
  24505. static readonly BILLBOARDMODE_ALL: number;
  24506. private _facetData;
  24507. /**
  24508. * The culling strategy to use to check whether the mesh must be rendered or not.
  24509. * This value can be changed at any time and will be used on the next render mesh selection.
  24510. * The possible values are :
  24511. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24512. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24515. * Please read each static variable documentation to get details about the culling process.
  24516. * */
  24517. cullingStrategy: number;
  24518. /**
  24519. * Gets the number of facets in the mesh
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24521. */
  24522. readonly facetNb: number;
  24523. /**
  24524. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24526. */
  24527. partitioningSubdivisions: number;
  24528. /**
  24529. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24530. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24532. */
  24533. partitioningBBoxRatio: number;
  24534. /**
  24535. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24536. * Works only for updatable meshes.
  24537. * Doesn't work with multi-materials
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24539. */
  24540. mustDepthSortFacets: boolean;
  24541. /**
  24542. * The location (Vector3) where the facet depth sort must be computed from.
  24543. * By default, the active camera position.
  24544. * Used only when facet depth sort is enabled
  24545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24546. */
  24547. facetDepthSortFrom: Vector3;
  24548. /**
  24549. * gets a boolean indicating if facetData is enabled
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24551. */
  24552. readonly isFacetDataEnabled: boolean;
  24553. /** @hidden */
  24554. _updateNonUniformScalingState(value: boolean): boolean;
  24555. /**
  24556. * An event triggered when this mesh collides with another one
  24557. */
  24558. onCollideObservable: Observable<AbstractMesh>;
  24559. private _onCollideObserver;
  24560. /** Set a function to call when this mesh collides with another one */
  24561. onCollide: () => void;
  24562. /**
  24563. * An event triggered when the collision's position changes
  24564. */
  24565. onCollisionPositionChangeObservable: Observable<Vector3>;
  24566. private _onCollisionPositionChangeObserver;
  24567. /** Set a function to call when the collision's position changes */
  24568. onCollisionPositionChange: () => void;
  24569. /**
  24570. * An event triggered when material is changed
  24571. */
  24572. onMaterialChangedObservable: Observable<AbstractMesh>;
  24573. /**
  24574. * Gets or sets the orientation for POV movement & rotation
  24575. */
  24576. definedFacingForward: boolean;
  24577. /** @hidden */
  24578. _occlusionQuery: Nullable<WebGLQuery>;
  24579. private _visibility;
  24580. /**
  24581. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24582. */
  24583. /**
  24584. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24585. */
  24586. visibility: number;
  24587. /** Gets or sets the alpha index used to sort transparent meshes
  24588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24589. */
  24590. alphaIndex: number;
  24591. /**
  24592. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24593. */
  24594. isVisible: boolean;
  24595. /**
  24596. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24597. */
  24598. isPickable: boolean;
  24599. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24600. showSubMeshesBoundingBox: boolean;
  24601. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24603. */
  24604. isBlocker: boolean;
  24605. /**
  24606. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24607. */
  24608. enablePointerMoveEvents: boolean;
  24609. /**
  24610. * Specifies the rendering group id for this mesh (0 by default)
  24611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24612. */
  24613. renderingGroupId: number;
  24614. private _material;
  24615. /** Gets or sets current material */
  24616. material: Nullable<Material>;
  24617. private _receiveShadows;
  24618. /**
  24619. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24620. * @see http://doc.babylonjs.com/babylon101/shadows
  24621. */
  24622. receiveShadows: boolean;
  24623. /** Defines color to use when rendering outline */
  24624. outlineColor: Color3;
  24625. /** Define width to use when rendering outline */
  24626. outlineWidth: number;
  24627. /** Defines color to use when rendering overlay */
  24628. overlayColor: Color3;
  24629. /** Defines alpha to use when rendering overlay */
  24630. overlayAlpha: number;
  24631. private _hasVertexAlpha;
  24632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24633. hasVertexAlpha: boolean;
  24634. private _useVertexColors;
  24635. /** 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) */
  24636. useVertexColors: boolean;
  24637. private _computeBonesUsingShaders;
  24638. /**
  24639. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24640. */
  24641. computeBonesUsingShaders: boolean;
  24642. private _numBoneInfluencers;
  24643. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24644. numBoneInfluencers: number;
  24645. private _applyFog;
  24646. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24647. applyFog: boolean;
  24648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24649. useOctreeForRenderingSelection: boolean;
  24650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24651. useOctreeForPicking: boolean;
  24652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24653. useOctreeForCollisions: boolean;
  24654. private _layerMask;
  24655. /**
  24656. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24657. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24658. */
  24659. layerMask: number;
  24660. /**
  24661. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24662. */
  24663. alwaysSelectAsActiveMesh: boolean;
  24664. /**
  24665. * Gets or sets the current action manager
  24666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24667. */
  24668. actionManager: Nullable<AbstractActionManager>;
  24669. private _checkCollisions;
  24670. private _collisionMask;
  24671. private _collisionGroup;
  24672. /**
  24673. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24675. */
  24676. ellipsoid: Vector3;
  24677. /**
  24678. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24680. */
  24681. ellipsoidOffset: Vector3;
  24682. private _collider;
  24683. private _oldPositionForCollisions;
  24684. private _diffPositionForCollisions;
  24685. /**
  24686. * Gets or sets a collision mask used to mask collisions (default is -1).
  24687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24688. */
  24689. collisionMask: number;
  24690. /**
  24691. * Gets or sets the current collision group mask (-1 by default).
  24692. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24693. */
  24694. collisionGroup: number;
  24695. /**
  24696. * Defines edge width used when edgesRenderer is enabled
  24697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24698. */
  24699. edgesWidth: number;
  24700. /**
  24701. * Defines edge color used when edgesRenderer is enabled
  24702. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24703. */
  24704. edgesColor: Color4;
  24705. /** @hidden */
  24706. _edgesRenderer: Nullable<IEdgesRenderer>;
  24707. /** @hidden */
  24708. _masterMesh: Nullable<AbstractMesh>;
  24709. /** @hidden */
  24710. _boundingInfo: Nullable<BoundingInfo>;
  24711. /** @hidden */
  24712. _renderId: number;
  24713. /**
  24714. * Gets or sets the list of subMeshes
  24715. * @see http://doc.babylonjs.com/how_to/multi_materials
  24716. */
  24717. subMeshes: SubMesh[];
  24718. /** @hidden */
  24719. _intersectionsInProgress: AbstractMesh[];
  24720. /** @hidden */
  24721. _unIndexed: boolean;
  24722. /** @hidden */
  24723. _lightSources: Light[];
  24724. /** @hidden */
  24725. readonly _positions: Nullable<Vector3[]>;
  24726. /** @hidden */
  24727. _waitingActions: any;
  24728. /** @hidden */
  24729. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24730. private _skeleton;
  24731. /** @hidden */
  24732. _bonesTransformMatrices: Nullable<Float32Array>;
  24733. /**
  24734. * Gets or sets a skeleton to apply skining transformations
  24735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24736. */
  24737. skeleton: Nullable<Skeleton>;
  24738. /**
  24739. * An event triggered when the mesh is rebuilt.
  24740. */
  24741. onRebuildObservable: Observable<AbstractMesh>;
  24742. /**
  24743. * Creates a new AbstractMesh
  24744. * @param name defines the name of the mesh
  24745. * @param scene defines the hosting scene
  24746. */
  24747. constructor(name: string, scene?: Nullable<Scene>);
  24748. /**
  24749. * Returns the string "AbstractMesh"
  24750. * @returns "AbstractMesh"
  24751. */
  24752. getClassName(): string;
  24753. /**
  24754. * Gets a string representation of the current mesh
  24755. * @param fullDetails defines a boolean indicating if full details must be included
  24756. * @returns a string representation of the current mesh
  24757. */
  24758. toString(fullDetails?: boolean): string;
  24759. /**
  24760. * @hidden
  24761. */
  24762. protected _getEffectiveParent(): Nullable<Node>;
  24763. /** @hidden */
  24764. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24765. /** @hidden */
  24766. _rebuild(): void;
  24767. /** @hidden */
  24768. _resyncLightSources(): void;
  24769. /** @hidden */
  24770. _resyncLighSource(light: Light): void;
  24771. /** @hidden */
  24772. _unBindEffect(): void;
  24773. /** @hidden */
  24774. _removeLightSource(light: Light): void;
  24775. private _markSubMeshesAsDirty;
  24776. /** @hidden */
  24777. _markSubMeshesAsLightDirty(): void;
  24778. /** @hidden */
  24779. _markSubMeshesAsAttributesDirty(): void;
  24780. /** @hidden */
  24781. _markSubMeshesAsMiscDirty(): void;
  24782. /**
  24783. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24784. */
  24785. scaling: Vector3;
  24786. /**
  24787. * Returns true if the mesh is blocked. Implemented by child classes
  24788. */
  24789. readonly isBlocked: boolean;
  24790. /**
  24791. * Returns the mesh itself by default. Implemented by child classes
  24792. * @param camera defines the camera to use to pick the right LOD level
  24793. * @returns the currentAbstractMesh
  24794. */
  24795. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24796. /**
  24797. * Returns 0 by default. Implemented by child classes
  24798. * @returns an integer
  24799. */
  24800. getTotalVertices(): number;
  24801. /**
  24802. * Returns a positive integer : the total number of indices in this mesh geometry.
  24803. * @returns the numner of indices or zero if the mesh has no geometry.
  24804. */
  24805. getTotalIndices(): number;
  24806. /**
  24807. * Returns null by default. Implemented by child classes
  24808. * @returns null
  24809. */
  24810. getIndices(): Nullable<IndicesArray>;
  24811. /**
  24812. * Returns the array of the requested vertex data kind. Implemented by child classes
  24813. * @param kind defines the vertex data kind to use
  24814. * @returns null
  24815. */
  24816. getVerticesData(kind: string): Nullable<FloatArray>;
  24817. /**
  24818. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24819. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24820. * Note that a new underlying VertexBuffer object is created each call.
  24821. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24822. * @param kind defines vertex data kind:
  24823. * * VertexBuffer.PositionKind
  24824. * * VertexBuffer.UVKind
  24825. * * VertexBuffer.UV2Kind
  24826. * * VertexBuffer.UV3Kind
  24827. * * VertexBuffer.UV4Kind
  24828. * * VertexBuffer.UV5Kind
  24829. * * VertexBuffer.UV6Kind
  24830. * * VertexBuffer.ColorKind
  24831. * * VertexBuffer.MatricesIndicesKind
  24832. * * VertexBuffer.MatricesIndicesExtraKind
  24833. * * VertexBuffer.MatricesWeightsKind
  24834. * * VertexBuffer.MatricesWeightsExtraKind
  24835. * @param data defines the data source
  24836. * @param updatable defines if the data must be flagged as updatable (or static)
  24837. * @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
  24838. * @returns the current mesh
  24839. */
  24840. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24841. /**
  24842. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24843. * If the mesh has no geometry, it is simply returned as it is.
  24844. * @param kind defines vertex data kind:
  24845. * * VertexBuffer.PositionKind
  24846. * * VertexBuffer.UVKind
  24847. * * VertexBuffer.UV2Kind
  24848. * * VertexBuffer.UV3Kind
  24849. * * VertexBuffer.UV4Kind
  24850. * * VertexBuffer.UV5Kind
  24851. * * VertexBuffer.UV6Kind
  24852. * * VertexBuffer.ColorKind
  24853. * * VertexBuffer.MatricesIndicesKind
  24854. * * VertexBuffer.MatricesIndicesExtraKind
  24855. * * VertexBuffer.MatricesWeightsKind
  24856. * * VertexBuffer.MatricesWeightsExtraKind
  24857. * @param data defines the data source
  24858. * @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
  24859. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24860. * @returns the current mesh
  24861. */
  24862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24863. /**
  24864. * Sets the mesh indices,
  24865. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24866. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24867. * @param totalVertices Defines the total number of vertices
  24868. * @returns the current mesh
  24869. */
  24870. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24871. /**
  24872. * Gets a boolean indicating if specific vertex data is present
  24873. * @param kind defines the vertex data kind to use
  24874. * @returns true is data kind is present
  24875. */
  24876. isVerticesDataPresent(kind: string): boolean;
  24877. /**
  24878. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24879. * @returns a BoundingInfo
  24880. */
  24881. getBoundingInfo(): BoundingInfo;
  24882. /**
  24883. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24884. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24885. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24886. * @returns the current mesh
  24887. */
  24888. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24889. /**
  24890. * Overwrite the current bounding info
  24891. * @param boundingInfo defines the new bounding info
  24892. * @returns the current mesh
  24893. */
  24894. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24895. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24896. readonly useBones: boolean;
  24897. /** @hidden */
  24898. _preActivate(): void;
  24899. /** @hidden */
  24900. _preActivateForIntermediateRendering(renderId: number): void;
  24901. /** @hidden */
  24902. _activate(renderId: number): void;
  24903. /**
  24904. * Gets the current world matrix
  24905. * @returns a Matrix
  24906. */
  24907. getWorldMatrix(): Matrix;
  24908. /** @hidden */
  24909. _getWorldMatrixDeterminant(): number;
  24910. /**
  24911. * Perform relative position change from the point of view of behind the front of the mesh.
  24912. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24913. * Supports definition of mesh facing forward or backward
  24914. * @param amountRight defines the distance on the right axis
  24915. * @param amountUp defines the distance on the up axis
  24916. * @param amountForward defines the distance on the forward axis
  24917. * @returns the current mesh
  24918. */
  24919. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24920. /**
  24921. * Calculate relative position change from the point of view of behind the front of the mesh.
  24922. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24923. * Supports definition of mesh facing forward or backward
  24924. * @param amountRight defines the distance on the right axis
  24925. * @param amountUp defines the distance on the up axis
  24926. * @param amountForward defines the distance on the forward axis
  24927. * @returns the new displacement vector
  24928. */
  24929. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24930. /**
  24931. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24932. * Supports definition of mesh facing forward or backward
  24933. * @param flipBack defines the flip
  24934. * @param twirlClockwise defines the twirl
  24935. * @param tiltRight defines the tilt
  24936. * @returns the current mesh
  24937. */
  24938. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24939. /**
  24940. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24941. * Supports definition of mesh facing forward or backward.
  24942. * @param flipBack defines the flip
  24943. * @param twirlClockwise defines the twirl
  24944. * @param tiltRight defines the tilt
  24945. * @returns the new rotation vector
  24946. */
  24947. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24948. /**
  24949. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24950. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24951. * @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
  24952. * @returns the new bounding vectors
  24953. */
  24954. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24955. min: Vector3;
  24956. max: Vector3;
  24957. };
  24958. /**
  24959. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24960. * This means the mesh underlying bounding box and sphere are recomputed.
  24961. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24962. * @returns the current mesh
  24963. */
  24964. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24965. /** @hidden */
  24966. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24967. /** @hidden */
  24968. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24969. /** @hidden */
  24970. _updateBoundingInfo(): AbstractMesh;
  24971. /** @hidden */
  24972. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24973. /** @hidden */
  24974. protected _afterComputeWorldMatrix(): void;
  24975. /** @hidden */
  24976. readonly _effectiveMesh: AbstractMesh;
  24977. /**
  24978. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24979. * A mesh is in the frustum if its bounding box intersects the frustum
  24980. * @param frustumPlanes defines the frustum to test
  24981. * @returns true if the mesh is in the frustum planes
  24982. */
  24983. isInFrustum(frustumPlanes: Plane[]): boolean;
  24984. /**
  24985. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24986. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24987. * @param frustumPlanes defines the frustum to test
  24988. * @returns true if the mesh is completely in the frustum planes
  24989. */
  24990. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24991. /**
  24992. * True if the mesh intersects another mesh or a SolidParticle object
  24993. * @param mesh defines a target mesh or SolidParticle to test
  24994. * @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)
  24995. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24996. * @returns true if there is an intersection
  24997. */
  24998. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24999. /**
  25000. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25001. * @param point defines the point to test
  25002. * @returns true if there is an intersection
  25003. */
  25004. intersectsPoint(point: Vector3): boolean;
  25005. /**
  25006. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25008. */
  25009. checkCollisions: boolean;
  25010. /**
  25011. * Gets Collider object used to compute collisions (not physics)
  25012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25013. */
  25014. readonly collider: Collider;
  25015. /**
  25016. * Move the mesh using collision engine
  25017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25018. * @param displacement defines the requested displacement vector
  25019. * @returns the current mesh
  25020. */
  25021. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25022. private _onCollisionPositionChange;
  25023. /** @hidden */
  25024. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25025. /** @hidden */
  25026. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25027. /** @hidden */
  25028. _checkCollision(collider: Collider): AbstractMesh;
  25029. /** @hidden */
  25030. _generatePointsArray(): boolean;
  25031. /**
  25032. * Checks if the passed Ray intersects with the mesh
  25033. * @param ray defines the ray to use
  25034. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25035. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25036. * @returns the picking info
  25037. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25038. */
  25039. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25040. /**
  25041. * Clones the current mesh
  25042. * @param name defines the mesh name
  25043. * @param newParent defines the new mesh parent
  25044. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25045. * @returns the new mesh
  25046. */
  25047. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25048. /**
  25049. * Disposes all the submeshes of the current meshnp
  25050. * @returns the current mesh
  25051. */
  25052. releaseSubMeshes(): AbstractMesh;
  25053. /**
  25054. * Releases resources associated with this abstract mesh.
  25055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25057. */
  25058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25059. /**
  25060. * Adds the passed mesh as a child to the current mesh
  25061. * @param mesh defines the child mesh
  25062. * @returns the current mesh
  25063. */
  25064. addChild(mesh: AbstractMesh): AbstractMesh;
  25065. /**
  25066. * Removes the passed mesh from the current mesh children list
  25067. * @param mesh defines the child mesh
  25068. * @returns the current mesh
  25069. */
  25070. removeChild(mesh: AbstractMesh): AbstractMesh;
  25071. /** @hidden */
  25072. private _initFacetData;
  25073. /**
  25074. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25075. * This method can be called within the render loop.
  25076. * 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
  25077. * @returns the current mesh
  25078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25079. */
  25080. updateFacetData(): AbstractMesh;
  25081. /**
  25082. * Returns the facetLocalNormals array.
  25083. * The normals are expressed in the mesh local spac
  25084. * @returns an array of Vector3
  25085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25086. */
  25087. getFacetLocalNormals(): Vector3[];
  25088. /**
  25089. * Returns the facetLocalPositions array.
  25090. * The facet positions are expressed in the mesh local space
  25091. * @returns an array of Vector3
  25092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25093. */
  25094. getFacetLocalPositions(): Vector3[];
  25095. /**
  25096. * Returns the facetLocalPartioning array
  25097. * @returns an array of array of numbers
  25098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25099. */
  25100. getFacetLocalPartitioning(): number[][];
  25101. /**
  25102. * Returns the i-th facet position in the world system.
  25103. * This method allocates a new Vector3 per call
  25104. * @param i defines the facet index
  25105. * @returns a new Vector3
  25106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25107. */
  25108. getFacetPosition(i: number): Vector3;
  25109. /**
  25110. * Sets the reference Vector3 with the i-th facet position in the world system
  25111. * @param i defines the facet index
  25112. * @param ref defines the target vector
  25113. * @returns the current mesh
  25114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25115. */
  25116. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25117. /**
  25118. * Returns the i-th facet normal in the world system.
  25119. * This method allocates a new Vector3 per call
  25120. * @param i defines the facet index
  25121. * @returns a new Vector3
  25122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25123. */
  25124. getFacetNormal(i: number): Vector3;
  25125. /**
  25126. * Sets the reference Vector3 with the i-th facet normal in the world system
  25127. * @param i defines the facet index
  25128. * @param ref defines the target vector
  25129. * @returns the current mesh
  25130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25131. */
  25132. getFacetNormalToRef(i: number, ref: Vector3): this;
  25133. /**
  25134. * 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)
  25135. * @param x defines x coordinate
  25136. * @param y defines y coordinate
  25137. * @param z defines z coordinate
  25138. * @returns the array of facet indexes
  25139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25140. */
  25141. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25142. /**
  25143. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25144. * @param projected sets as the (x,y,z) world projection on the facet
  25145. * @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
  25146. * @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
  25147. * @param x defines x coordinate
  25148. * @param y defines y coordinate
  25149. * @param z defines z coordinate
  25150. * @returns the face index if found (or null instead)
  25151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25152. */
  25153. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25154. /**
  25155. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25156. * @param projected sets as the (x,y,z) local projection on the facet
  25157. * @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
  25158. * @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
  25159. * @param x defines x coordinate
  25160. * @param y defines y coordinate
  25161. * @param z defines z coordinate
  25162. * @returns the face index if found (or null instead)
  25163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25164. */
  25165. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25166. /**
  25167. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25168. * @returns the parameters
  25169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25170. */
  25171. getFacetDataParameters(): any;
  25172. /**
  25173. * Disables the feature FacetData and frees the related memory
  25174. * @returns the current mesh
  25175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25176. */
  25177. disableFacetData(): AbstractMesh;
  25178. /**
  25179. * Updates the AbstractMesh indices array
  25180. * @param indices defines the data source
  25181. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25182. * @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)
  25183. * @returns the current mesh
  25184. */
  25185. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25186. /**
  25187. * Creates new normals data for the mesh
  25188. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25189. * @returns the current mesh
  25190. */
  25191. createNormals(updatable: boolean): AbstractMesh;
  25192. /**
  25193. * Align the mesh with a normal
  25194. * @param normal defines the normal to use
  25195. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25196. * @returns the current mesh
  25197. */
  25198. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25199. /** @hidden */
  25200. _checkOcclusionQuery(): boolean;
  25201. }
  25202. }
  25203. declare module "babylonjs/Actions/actionEvent" {
  25204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25205. import { Nullable } from "babylonjs/types";
  25206. import { Sprite } from "babylonjs/Sprites/sprite";
  25207. import { Scene } from "babylonjs/scene";
  25208. import { Vector2 } from "babylonjs/Maths/math";
  25209. /**
  25210. * Interface used to define ActionEvent
  25211. */
  25212. export interface IActionEvent {
  25213. /** The mesh or sprite that triggered the action */
  25214. source: any;
  25215. /** The X mouse cursor position at the time of the event */
  25216. pointerX: number;
  25217. /** The Y mouse cursor position at the time of the event */
  25218. pointerY: number;
  25219. /** The mesh that is currently pointed at (can be null) */
  25220. meshUnderPointer: Nullable<AbstractMesh>;
  25221. /** the original (browser) event that triggered the ActionEvent */
  25222. sourceEvent?: any;
  25223. /** additional data for the event */
  25224. additionalData?: any;
  25225. }
  25226. /**
  25227. * ActionEvent is the event being sent when an action is triggered.
  25228. */
  25229. export class ActionEvent implements IActionEvent {
  25230. /** The mesh or sprite that triggered the action */
  25231. source: any;
  25232. /** The X mouse cursor position at the time of the event */
  25233. pointerX: number;
  25234. /** The Y mouse cursor position at the time of the event */
  25235. pointerY: number;
  25236. /** The mesh that is currently pointed at (can be null) */
  25237. meshUnderPointer: Nullable<AbstractMesh>;
  25238. /** the original (browser) event that triggered the ActionEvent */
  25239. sourceEvent?: any;
  25240. /** additional data for the event */
  25241. additionalData?: any;
  25242. /**
  25243. * Creates a new ActionEvent
  25244. * @param source The mesh or sprite that triggered the action
  25245. * @param pointerX The X mouse cursor position at the time of the event
  25246. * @param pointerY The Y mouse cursor position at the time of the event
  25247. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25248. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25249. * @param additionalData additional data for the event
  25250. */
  25251. constructor(
  25252. /** The mesh or sprite that triggered the action */
  25253. source: any,
  25254. /** The X mouse cursor position at the time of the event */
  25255. pointerX: number,
  25256. /** The Y mouse cursor position at the time of the event */
  25257. pointerY: number,
  25258. /** The mesh that is currently pointed at (can be null) */
  25259. meshUnderPointer: Nullable<AbstractMesh>,
  25260. /** the original (browser) event that triggered the ActionEvent */
  25261. sourceEvent?: any,
  25262. /** additional data for the event */
  25263. additionalData?: any);
  25264. /**
  25265. * Helper function to auto-create an ActionEvent from a source mesh.
  25266. * @param source The source mesh that triggered the event
  25267. * @param evt The original (browser) event
  25268. * @param additionalData additional data for the event
  25269. * @returns the new ActionEvent
  25270. */
  25271. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25272. /**
  25273. * Helper function to auto-create an ActionEvent from a source sprite
  25274. * @param source The source sprite that triggered the event
  25275. * @param scene Scene associated with the sprite
  25276. * @param evt The original (browser) event
  25277. * @param additionalData additional data for the event
  25278. * @returns the new ActionEvent
  25279. */
  25280. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25281. /**
  25282. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25283. * @param scene the scene where the event occurred
  25284. * @param evt The original (browser) event
  25285. * @returns the new ActionEvent
  25286. */
  25287. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25288. /**
  25289. * Helper function to auto-create an ActionEvent from a primitive
  25290. * @param prim defines the target primitive
  25291. * @param pointerPos defines the pointer position
  25292. * @param evt The original (browser) event
  25293. * @param additionalData additional data for the event
  25294. * @returns the new ActionEvent
  25295. */
  25296. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25297. }
  25298. }
  25299. declare module "babylonjs/Actions/abstractActionManager" {
  25300. import { IDisposable } from "babylonjs/scene";
  25301. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25302. import { IAction } from "babylonjs/Actions/action";
  25303. import { Nullable } from "babylonjs/types";
  25304. /**
  25305. * Abstract class used to decouple action Manager from scene and meshes.
  25306. * Do not instantiate.
  25307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25308. */
  25309. export abstract class AbstractActionManager implements IDisposable {
  25310. /** Gets the list of active triggers */
  25311. static Triggers: {
  25312. [key: string]: number;
  25313. };
  25314. /** Gets the cursor to use when hovering items */
  25315. hoverCursor: string;
  25316. /** Gets the list of actions */
  25317. actions: IAction[];
  25318. /**
  25319. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25320. */
  25321. isRecursive: boolean;
  25322. /**
  25323. * Releases all associated resources
  25324. */
  25325. abstract dispose(): void;
  25326. /**
  25327. * Does this action manager has pointer triggers
  25328. */
  25329. abstract readonly hasPointerTriggers: boolean;
  25330. /**
  25331. * Does this action manager has pick triggers
  25332. */
  25333. abstract readonly hasPickTriggers: boolean;
  25334. /**
  25335. * Process a specific trigger
  25336. * @param trigger defines the trigger to process
  25337. * @param evt defines the event details to be processed
  25338. */
  25339. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25340. /**
  25341. * Does this action manager handles actions of any of the given triggers
  25342. * @param triggers defines the triggers to be tested
  25343. * @return a boolean indicating whether one (or more) of the triggers is handled
  25344. */
  25345. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25346. /**
  25347. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25348. * speed.
  25349. * @param triggerA defines the trigger to be tested
  25350. * @param triggerB defines the trigger to be tested
  25351. * @return a boolean indicating whether one (or more) of the triggers is handled
  25352. */
  25353. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25354. /**
  25355. * Does this action manager handles actions of a given trigger
  25356. * @param trigger defines the trigger to be tested
  25357. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25358. * @return whether the trigger is handled
  25359. */
  25360. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25361. /**
  25362. * Serialize this manager to a JSON object
  25363. * @param name defines the property name to store this manager
  25364. * @returns a JSON representation of this manager
  25365. */
  25366. abstract serialize(name: string): any;
  25367. /**
  25368. * Registers an action to this action manager
  25369. * @param action defines the action to be registered
  25370. * @return the action amended (prepared) after registration
  25371. */
  25372. abstract registerAction(action: IAction): Nullable<IAction>;
  25373. /**
  25374. * Unregisters an action to this action manager
  25375. * @param action defines the action to be unregistered
  25376. * @return a boolean indicating whether the action has been unregistered
  25377. */
  25378. abstract unregisterAction(action: IAction): Boolean;
  25379. /**
  25380. * Does exist one action manager with at least one trigger
  25381. **/
  25382. static readonly HasTriggers: boolean;
  25383. /**
  25384. * Does exist one action manager with at least one pick trigger
  25385. **/
  25386. static readonly HasPickTriggers: boolean;
  25387. /**
  25388. * Does exist one action manager that handles actions of a given trigger
  25389. * @param trigger defines the trigger to be tested
  25390. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25391. **/
  25392. static HasSpecificTrigger(trigger: number): boolean;
  25393. }
  25394. }
  25395. declare module "babylonjs/node" {
  25396. import { Scene } from "babylonjs/scene";
  25397. import { Nullable } from "babylonjs/types";
  25398. import { Matrix } from "babylonjs/Maths/math";
  25399. import { Engine } from "babylonjs/Engines/engine";
  25400. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25401. import { Observable } from "babylonjs/Misc/observable";
  25402. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25403. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25404. import { Animatable } from "babylonjs/Animations/animatable";
  25405. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25406. import { Animation } from "babylonjs/Animations/animation";
  25407. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25409. /**
  25410. * Defines how a node can be built from a string name.
  25411. */
  25412. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25413. /**
  25414. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25415. */
  25416. export class Node implements IBehaviorAware<Node> {
  25417. /** @hidden */
  25418. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25419. private static _NodeConstructors;
  25420. /**
  25421. * Add a new node constructor
  25422. * @param type defines the type name of the node to construct
  25423. * @param constructorFunc defines the constructor function
  25424. */
  25425. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25426. /**
  25427. * Returns a node constructor based on type name
  25428. * @param type defines the type name
  25429. * @param name defines the new node name
  25430. * @param scene defines the hosting scene
  25431. * @param options defines optional options to transmit to constructors
  25432. * @returns the new constructor or null
  25433. */
  25434. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25435. /**
  25436. * Gets or sets the name of the node
  25437. */
  25438. name: string;
  25439. /**
  25440. * Gets or sets the id of the node
  25441. */
  25442. id: string;
  25443. /**
  25444. * Gets or sets the unique id of the node
  25445. */
  25446. uniqueId: number;
  25447. /**
  25448. * Gets or sets a string used to store user defined state for the node
  25449. */
  25450. state: string;
  25451. /**
  25452. * Gets or sets an object used to store user defined information for the node
  25453. */
  25454. metadata: any;
  25455. /**
  25456. * For internal use only. Please do not use.
  25457. */
  25458. reservedDataStore: any;
  25459. /**
  25460. * List of inspectable custom properties (used by the Inspector)
  25461. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25462. */
  25463. inspectableCustomProperties: IInspectable[];
  25464. /**
  25465. * Gets or sets a boolean used to define if the node must be serialized
  25466. */
  25467. doNotSerialize: boolean;
  25468. /** @hidden */
  25469. _isDisposed: boolean;
  25470. /**
  25471. * Gets a list of Animations associated with the node
  25472. */
  25473. animations: import("babylonjs/Animations/animation").Animation[];
  25474. protected _ranges: {
  25475. [name: string]: Nullable<AnimationRange>;
  25476. };
  25477. /**
  25478. * Callback raised when the node is ready to be used
  25479. */
  25480. onReady: (node: Node) => void;
  25481. private _isEnabled;
  25482. private _isParentEnabled;
  25483. private _isReady;
  25484. /** @hidden */
  25485. _currentRenderId: number;
  25486. private _parentUpdateId;
  25487. protected _childUpdateId: number;
  25488. /** @hidden */
  25489. _waitingParentId: Nullable<string>;
  25490. /** @hidden */
  25491. _scene: Scene;
  25492. /** @hidden */
  25493. _cache: any;
  25494. private _parentNode;
  25495. private _children;
  25496. /** @hidden */
  25497. _worldMatrix: Matrix;
  25498. /** @hidden */
  25499. _worldMatrixDeterminant: number;
  25500. /** @hidden */
  25501. private _sceneRootNodesIndex;
  25502. /**
  25503. * Gets a boolean indicating if the node has been disposed
  25504. * @returns true if the node was disposed
  25505. */
  25506. isDisposed(): boolean;
  25507. /**
  25508. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25509. * @see https://doc.babylonjs.com/how_to/parenting
  25510. */
  25511. parent: Nullable<Node>;
  25512. private addToSceneRootNodes;
  25513. private removeFromSceneRootNodes;
  25514. private _animationPropertiesOverride;
  25515. /**
  25516. * Gets or sets the animation properties override
  25517. */
  25518. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25519. /**
  25520. * Gets a string idenfifying the name of the class
  25521. * @returns "Node" string
  25522. */
  25523. getClassName(): string;
  25524. /** @hidden */
  25525. readonly _isNode: boolean;
  25526. /**
  25527. * An event triggered when the mesh is disposed
  25528. */
  25529. onDisposeObservable: Observable<Node>;
  25530. private _onDisposeObserver;
  25531. /**
  25532. * Sets a callback that will be raised when the node will be disposed
  25533. */
  25534. onDispose: () => void;
  25535. /**
  25536. * Creates a new Node
  25537. * @param name the name and id to be given to this node
  25538. * @param scene the scene this node will be added to
  25539. * @param addToRootNodes the node will be added to scene.rootNodes
  25540. */
  25541. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25542. /**
  25543. * Gets the scene of the node
  25544. * @returns a scene
  25545. */
  25546. getScene(): Scene;
  25547. /**
  25548. * Gets the engine of the node
  25549. * @returns a Engine
  25550. */
  25551. getEngine(): Engine;
  25552. private _behaviors;
  25553. /**
  25554. * Attach a behavior to the node
  25555. * @see http://doc.babylonjs.com/features/behaviour
  25556. * @param behavior defines the behavior to attach
  25557. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25558. * @returns the current Node
  25559. */
  25560. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25561. /**
  25562. * Remove an attached behavior
  25563. * @see http://doc.babylonjs.com/features/behaviour
  25564. * @param behavior defines the behavior to attach
  25565. * @returns the current Node
  25566. */
  25567. removeBehavior(behavior: Behavior<Node>): Node;
  25568. /**
  25569. * Gets the list of attached behaviors
  25570. * @see http://doc.babylonjs.com/features/behaviour
  25571. */
  25572. readonly behaviors: Behavior<Node>[];
  25573. /**
  25574. * Gets an attached behavior by name
  25575. * @param name defines the name of the behavior to look for
  25576. * @see http://doc.babylonjs.com/features/behaviour
  25577. * @returns null if behavior was not found else the requested behavior
  25578. */
  25579. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25580. /**
  25581. * Returns the latest update of the World matrix
  25582. * @returns a Matrix
  25583. */
  25584. getWorldMatrix(): Matrix;
  25585. /** @hidden */
  25586. _getWorldMatrixDeterminant(): number;
  25587. /**
  25588. * Returns directly the latest state of the mesh World matrix.
  25589. * A Matrix is returned.
  25590. */
  25591. readonly worldMatrixFromCache: Matrix;
  25592. /** @hidden */
  25593. _initCache(): void;
  25594. /** @hidden */
  25595. updateCache(force?: boolean): void;
  25596. /** @hidden */
  25597. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25598. /** @hidden */
  25599. _updateCache(ignoreParentClass?: boolean): void;
  25600. /** @hidden */
  25601. _isSynchronized(): boolean;
  25602. /** @hidden */
  25603. _markSyncedWithParent(): void;
  25604. /** @hidden */
  25605. isSynchronizedWithParent(): boolean;
  25606. /** @hidden */
  25607. isSynchronized(): boolean;
  25608. /**
  25609. * Is this node ready to be used/rendered
  25610. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25611. * @return true if the node is ready
  25612. */
  25613. isReady(completeCheck?: boolean): boolean;
  25614. /**
  25615. * Is this node enabled?
  25616. * 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
  25617. * @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
  25618. * @return whether this node (and its parent) is enabled
  25619. */
  25620. isEnabled(checkAncestors?: boolean): boolean;
  25621. /** @hidden */
  25622. protected _syncParentEnabledState(): void;
  25623. /**
  25624. * Set the enabled state of this node
  25625. * @param value defines the new enabled state
  25626. */
  25627. setEnabled(value: boolean): void;
  25628. /**
  25629. * Is this node a descendant of the given node?
  25630. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25631. * @param ancestor defines the parent node to inspect
  25632. * @returns a boolean indicating if this node is a descendant of the given node
  25633. */
  25634. isDescendantOf(ancestor: Node): boolean;
  25635. /** @hidden */
  25636. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25637. /**
  25638. * Will return all nodes that have this node as ascendant
  25639. * @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
  25640. * @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
  25641. * @return all children nodes of all types
  25642. */
  25643. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25644. /**
  25645. * Get all child-meshes of this node
  25646. * @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)
  25647. * @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
  25648. * @returns an array of AbstractMesh
  25649. */
  25650. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25651. /**
  25652. * Get all direct children of this node
  25653. * @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
  25654. * @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)
  25655. * @returns an array of Node
  25656. */
  25657. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25658. /** @hidden */
  25659. _setReady(state: boolean): void;
  25660. /**
  25661. * Get an animation by name
  25662. * @param name defines the name of the animation to look for
  25663. * @returns null if not found else the requested animation
  25664. */
  25665. getAnimationByName(name: string): Nullable<Animation>;
  25666. /**
  25667. * Creates an animation range for this node
  25668. * @param name defines the name of the range
  25669. * @param from defines the starting key
  25670. * @param to defines the end key
  25671. */
  25672. createAnimationRange(name: string, from: number, to: number): void;
  25673. /**
  25674. * Delete a specific animation range
  25675. * @param name defines the name of the range to delete
  25676. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25677. */
  25678. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25679. /**
  25680. * Get an animation range by name
  25681. * @param name defines the name of the animation range to look for
  25682. * @returns null if not found else the requested animation range
  25683. */
  25684. getAnimationRange(name: string): Nullable<AnimationRange>;
  25685. /**
  25686. * Gets the list of all animation ranges defined on this node
  25687. * @returns an array
  25688. */
  25689. getAnimationRanges(): Nullable<AnimationRange>[];
  25690. /**
  25691. * Will start the animation sequence
  25692. * @param name defines the range frames for animation sequence
  25693. * @param loop defines if the animation should loop (false by default)
  25694. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25695. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25696. * @returns the object created for this animation. If range does not exist, it will return null
  25697. */
  25698. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25699. /**
  25700. * Serialize animation ranges into a JSON compatible object
  25701. * @returns serialization object
  25702. */
  25703. serializeAnimationRanges(): any;
  25704. /**
  25705. * Computes the world matrix of the node
  25706. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25707. * @returns the world matrix
  25708. */
  25709. computeWorldMatrix(force?: boolean): Matrix;
  25710. /**
  25711. * Releases resources associated with this node.
  25712. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25713. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25714. */
  25715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25716. /**
  25717. * Parse animation range data from a serialization object and store them into a given node
  25718. * @param node defines where to store the animation ranges
  25719. * @param parsedNode defines the serialization object to read data from
  25720. * @param scene defines the hosting scene
  25721. */
  25722. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25723. }
  25724. }
  25725. declare module "babylonjs/Animations/animation" {
  25726. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25727. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25728. import { Nullable } from "babylonjs/types";
  25729. import { Scene } from "babylonjs/scene";
  25730. import { IAnimatable } from "babylonjs/Misc/tools";
  25731. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25732. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25733. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25734. import { Node } from "babylonjs/node";
  25735. import { Animatable } from "babylonjs/Animations/animatable";
  25736. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25737. /**
  25738. * Class used to store any kind of animation
  25739. */
  25740. export class Animation {
  25741. /**Name of the animation */
  25742. name: string;
  25743. /**Property to animate */
  25744. targetProperty: string;
  25745. /**The frames per second of the animation */
  25746. framePerSecond: number;
  25747. /**The data type of the animation */
  25748. dataType: number;
  25749. /**The loop mode of the animation */
  25750. loopMode?: number | undefined;
  25751. /**Specifies if blending should be enabled */
  25752. enableBlending?: boolean | undefined;
  25753. /**
  25754. * Use matrix interpolation instead of using direct key value when animating matrices
  25755. */
  25756. static AllowMatricesInterpolation: boolean;
  25757. /**
  25758. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25759. */
  25760. static AllowMatrixDecomposeForInterpolation: boolean;
  25761. /**
  25762. * Stores the key frames of the animation
  25763. */
  25764. private _keys;
  25765. /**
  25766. * Stores the easing function of the animation
  25767. */
  25768. private _easingFunction;
  25769. /**
  25770. * @hidden Internal use only
  25771. */
  25772. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25773. /**
  25774. * The set of event that will be linked to this animation
  25775. */
  25776. private _events;
  25777. /**
  25778. * Stores an array of target property paths
  25779. */
  25780. targetPropertyPath: string[];
  25781. /**
  25782. * Stores the blending speed of the animation
  25783. */
  25784. blendingSpeed: number;
  25785. /**
  25786. * Stores the animation ranges for the animation
  25787. */
  25788. private _ranges;
  25789. /**
  25790. * @hidden Internal use
  25791. */
  25792. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25793. /**
  25794. * Sets up an animation
  25795. * @param property The property to animate
  25796. * @param animationType The animation type to apply
  25797. * @param framePerSecond The frames per second of the animation
  25798. * @param easingFunction The easing function used in the animation
  25799. * @returns The created animation
  25800. */
  25801. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25802. /**
  25803. * Create and start an animation on a node
  25804. * @param name defines the name of the global animation that will be run on all nodes
  25805. * @param node defines the root node where the animation will take place
  25806. * @param targetProperty defines property to animate
  25807. * @param framePerSecond defines the number of frame per second yo use
  25808. * @param totalFrame defines the number of frames in total
  25809. * @param from defines the initial value
  25810. * @param to defines the final value
  25811. * @param loopMode defines which loop mode you want to use (off by default)
  25812. * @param easingFunction defines the easing function to use (linear by default)
  25813. * @param onAnimationEnd defines the callback to call when animation end
  25814. * @returns the animatable created for this animation
  25815. */
  25816. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25817. /**
  25818. * Create and start an animation on a node and its descendants
  25819. * @param name defines the name of the global animation that will be run on all nodes
  25820. * @param node defines the root node where the animation will take place
  25821. * @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
  25822. * @param targetProperty defines property to animate
  25823. * @param framePerSecond defines the number of frame per second to use
  25824. * @param totalFrame defines the number of frames in total
  25825. * @param from defines the initial value
  25826. * @param to defines the final value
  25827. * @param loopMode defines which loop mode you want to use (off by default)
  25828. * @param easingFunction defines the easing function to use (linear by default)
  25829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25830. * @returns the list of animatables created for all nodes
  25831. * @example https://www.babylonjs-playground.com/#MH0VLI
  25832. */
  25833. 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[]>;
  25834. /**
  25835. * Creates a new animation, merges it with the existing animations and starts it
  25836. * @param name Name of the animation
  25837. * @param node Node which contains the scene that begins the animations
  25838. * @param targetProperty Specifies which property to animate
  25839. * @param framePerSecond The frames per second of the animation
  25840. * @param totalFrame The total number of frames
  25841. * @param from The frame at the beginning of the animation
  25842. * @param to The frame at the end of the animation
  25843. * @param loopMode Specifies the loop mode of the animation
  25844. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25845. * @param onAnimationEnd Callback to run once the animation is complete
  25846. * @returns Nullable animation
  25847. */
  25848. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25849. /**
  25850. * Transition property of an host to the target Value
  25851. * @param property The property to transition
  25852. * @param targetValue The target Value of the property
  25853. * @param host The object where the property to animate belongs
  25854. * @param scene Scene used to run the animation
  25855. * @param frameRate Framerate (in frame/s) to use
  25856. * @param transition The transition type we want to use
  25857. * @param duration The duration of the animation, in milliseconds
  25858. * @param onAnimationEnd Callback trigger at the end of the animation
  25859. * @returns Nullable animation
  25860. */
  25861. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25862. /**
  25863. * Return the array of runtime animations currently using this animation
  25864. */
  25865. readonly runtimeAnimations: RuntimeAnimation[];
  25866. /**
  25867. * Specifies if any of the runtime animations are currently running
  25868. */
  25869. readonly hasRunningRuntimeAnimations: boolean;
  25870. /**
  25871. * Initializes the animation
  25872. * @param name Name of the animation
  25873. * @param targetProperty Property to animate
  25874. * @param framePerSecond The frames per second of the animation
  25875. * @param dataType The data type of the animation
  25876. * @param loopMode The loop mode of the animation
  25877. * @param enableBlending Specifies if blending should be enabled
  25878. */
  25879. constructor(
  25880. /**Name of the animation */
  25881. name: string,
  25882. /**Property to animate */
  25883. targetProperty: string,
  25884. /**The frames per second of the animation */
  25885. framePerSecond: number,
  25886. /**The data type of the animation */
  25887. dataType: number,
  25888. /**The loop mode of the animation */
  25889. loopMode?: number | undefined,
  25890. /**Specifies if blending should be enabled */
  25891. enableBlending?: boolean | undefined);
  25892. /**
  25893. * Converts the animation to a string
  25894. * @param fullDetails support for multiple levels of logging within scene loading
  25895. * @returns String form of the animation
  25896. */
  25897. toString(fullDetails?: boolean): string;
  25898. /**
  25899. * Add an event to this animation
  25900. * @param event Event to add
  25901. */
  25902. addEvent(event: AnimationEvent): void;
  25903. /**
  25904. * Remove all events found at the given frame
  25905. * @param frame The frame to remove events from
  25906. */
  25907. removeEvents(frame: number): void;
  25908. /**
  25909. * Retrieves all the events from the animation
  25910. * @returns Events from the animation
  25911. */
  25912. getEvents(): AnimationEvent[];
  25913. /**
  25914. * Creates an animation range
  25915. * @param name Name of the animation range
  25916. * @param from Starting frame of the animation range
  25917. * @param to Ending frame of the animation
  25918. */
  25919. createRange(name: string, from: number, to: number): void;
  25920. /**
  25921. * Deletes an animation range by name
  25922. * @param name Name of the animation range to delete
  25923. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25924. */
  25925. deleteRange(name: string, deleteFrames?: boolean): void;
  25926. /**
  25927. * Gets the animation range by name, or null if not defined
  25928. * @param name Name of the animation range
  25929. * @returns Nullable animation range
  25930. */
  25931. getRange(name: string): Nullable<AnimationRange>;
  25932. /**
  25933. * Gets the key frames from the animation
  25934. * @returns The key frames of the animation
  25935. */
  25936. getKeys(): Array<IAnimationKey>;
  25937. /**
  25938. * Gets the highest frame rate of the animation
  25939. * @returns Highest frame rate of the animation
  25940. */
  25941. getHighestFrame(): number;
  25942. /**
  25943. * Gets the easing function of the animation
  25944. * @returns Easing function of the animation
  25945. */
  25946. getEasingFunction(): IEasingFunction;
  25947. /**
  25948. * Sets the easing function of the animation
  25949. * @param easingFunction A custom mathematical formula for animation
  25950. */
  25951. setEasingFunction(easingFunction: EasingFunction): void;
  25952. /**
  25953. * Interpolates a scalar linearly
  25954. * @param startValue Start value of the animation curve
  25955. * @param endValue End value of the animation curve
  25956. * @param gradient Scalar amount to interpolate
  25957. * @returns Interpolated scalar value
  25958. */
  25959. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25960. /**
  25961. * Interpolates a scalar cubically
  25962. * @param startValue Start value of the animation curve
  25963. * @param outTangent End tangent of the animation
  25964. * @param endValue End value of the animation curve
  25965. * @param inTangent Start tangent of the animation curve
  25966. * @param gradient Scalar amount to interpolate
  25967. * @returns Interpolated scalar value
  25968. */
  25969. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25970. /**
  25971. * Interpolates a quaternion using a spherical linear interpolation
  25972. * @param startValue Start value of the animation curve
  25973. * @param endValue End value of the animation curve
  25974. * @param gradient Scalar amount to interpolate
  25975. * @returns Interpolated quaternion value
  25976. */
  25977. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25978. /**
  25979. * Interpolates a quaternion cubically
  25980. * @param startValue Start value of the animation curve
  25981. * @param outTangent End tangent of the animation curve
  25982. * @param endValue End value of the animation curve
  25983. * @param inTangent Start tangent of the animation curve
  25984. * @param gradient Scalar amount to interpolate
  25985. * @returns Interpolated quaternion value
  25986. */
  25987. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25988. /**
  25989. * Interpolates a Vector3 linearl
  25990. * @param startValue Start value of the animation curve
  25991. * @param endValue End value of the animation curve
  25992. * @param gradient Scalar amount to interpolate
  25993. * @returns Interpolated scalar value
  25994. */
  25995. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25996. /**
  25997. * Interpolates a Vector3 cubically
  25998. * @param startValue Start value of the animation curve
  25999. * @param outTangent End tangent of the animation
  26000. * @param endValue End value of the animation curve
  26001. * @param inTangent Start tangent of the animation curve
  26002. * @param gradient Scalar amount to interpolate
  26003. * @returns InterpolatedVector3 value
  26004. */
  26005. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26006. /**
  26007. * Interpolates a Vector2 linearly
  26008. * @param startValue Start value of the animation curve
  26009. * @param endValue End value of the animation curve
  26010. * @param gradient Scalar amount to interpolate
  26011. * @returns Interpolated Vector2 value
  26012. */
  26013. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26014. /**
  26015. * Interpolates a Vector2 cubically
  26016. * @param startValue Start value of the animation curve
  26017. * @param outTangent End tangent of the animation
  26018. * @param endValue End value of the animation curve
  26019. * @param inTangent Start tangent of the animation curve
  26020. * @param gradient Scalar amount to interpolate
  26021. * @returns Interpolated Vector2 value
  26022. */
  26023. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26024. /**
  26025. * Interpolates a size linearly
  26026. * @param startValue Start value of the animation curve
  26027. * @param endValue End value of the animation curve
  26028. * @param gradient Scalar amount to interpolate
  26029. * @returns Interpolated Size value
  26030. */
  26031. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26032. /**
  26033. * Interpolates a Color3 linearly
  26034. * @param startValue Start value of the animation curve
  26035. * @param endValue End value of the animation curve
  26036. * @param gradient Scalar amount to interpolate
  26037. * @returns Interpolated Color3 value
  26038. */
  26039. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26040. /**
  26041. * @hidden Internal use only
  26042. */
  26043. _getKeyValue(value: any): any;
  26044. /**
  26045. * @hidden Internal use only
  26046. */
  26047. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26048. /**
  26049. * Defines the function to use to interpolate matrices
  26050. * @param startValue defines the start matrix
  26051. * @param endValue defines the end matrix
  26052. * @param gradient defines the gradient between both matrices
  26053. * @param result defines an optional target matrix where to store the interpolation
  26054. * @returns the interpolated matrix
  26055. */
  26056. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26057. /**
  26058. * Makes a copy of the animation
  26059. * @returns Cloned animation
  26060. */
  26061. clone(): Animation;
  26062. /**
  26063. * Sets the key frames of the animation
  26064. * @param values The animation key frames to set
  26065. */
  26066. setKeys(values: Array<IAnimationKey>): void;
  26067. /**
  26068. * Serializes the animation to an object
  26069. * @returns Serialized object
  26070. */
  26071. serialize(): any;
  26072. /**
  26073. * Float animation type
  26074. */
  26075. private static _ANIMATIONTYPE_FLOAT;
  26076. /**
  26077. * Vector3 animation type
  26078. */
  26079. private static _ANIMATIONTYPE_VECTOR3;
  26080. /**
  26081. * Quaternion animation type
  26082. */
  26083. private static _ANIMATIONTYPE_QUATERNION;
  26084. /**
  26085. * Matrix animation type
  26086. */
  26087. private static _ANIMATIONTYPE_MATRIX;
  26088. /**
  26089. * Color3 animation type
  26090. */
  26091. private static _ANIMATIONTYPE_COLOR3;
  26092. /**
  26093. * Vector2 animation type
  26094. */
  26095. private static _ANIMATIONTYPE_VECTOR2;
  26096. /**
  26097. * Size animation type
  26098. */
  26099. private static _ANIMATIONTYPE_SIZE;
  26100. /**
  26101. * Relative Loop Mode
  26102. */
  26103. private static _ANIMATIONLOOPMODE_RELATIVE;
  26104. /**
  26105. * Cycle Loop Mode
  26106. */
  26107. private static _ANIMATIONLOOPMODE_CYCLE;
  26108. /**
  26109. * Constant Loop Mode
  26110. */
  26111. private static _ANIMATIONLOOPMODE_CONSTANT;
  26112. /**
  26113. * Get the float animation type
  26114. */
  26115. static readonly ANIMATIONTYPE_FLOAT: number;
  26116. /**
  26117. * Get the Vector3 animation type
  26118. */
  26119. static readonly ANIMATIONTYPE_VECTOR3: number;
  26120. /**
  26121. * Get the Vector2 animation type
  26122. */
  26123. static readonly ANIMATIONTYPE_VECTOR2: number;
  26124. /**
  26125. * Get the Size animation type
  26126. */
  26127. static readonly ANIMATIONTYPE_SIZE: number;
  26128. /**
  26129. * Get the Quaternion animation type
  26130. */
  26131. static readonly ANIMATIONTYPE_QUATERNION: number;
  26132. /**
  26133. * Get the Matrix animation type
  26134. */
  26135. static readonly ANIMATIONTYPE_MATRIX: number;
  26136. /**
  26137. * Get the Color3 animation type
  26138. */
  26139. static readonly ANIMATIONTYPE_COLOR3: number;
  26140. /**
  26141. * Get the Relative Loop Mode
  26142. */
  26143. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26144. /**
  26145. * Get the Cycle Loop Mode
  26146. */
  26147. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26148. /**
  26149. * Get the Constant Loop Mode
  26150. */
  26151. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26152. /** @hidden */
  26153. static _UniversalLerp(left: any, right: any, amount: number): any;
  26154. /**
  26155. * Parses an animation object and creates an animation
  26156. * @param parsedAnimation Parsed animation object
  26157. * @returns Animation object
  26158. */
  26159. static Parse(parsedAnimation: any): Animation;
  26160. /**
  26161. * Appends the serialized animations from the source animations
  26162. * @param source Source containing the animations
  26163. * @param destination Target to store the animations
  26164. */
  26165. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26166. }
  26167. }
  26168. declare module "babylonjs/Materials/Textures/baseTexture" {
  26169. import { Observable } from "babylonjs/Misc/observable";
  26170. import { IAnimatable } from "babylonjs/Misc/tools";
  26171. import { Nullable } from "babylonjs/types";
  26172. import { Scene } from "babylonjs/scene";
  26173. import { Matrix, ISize } from "babylonjs/Maths/math";
  26174. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26176. /**
  26177. * Base class of all the textures in babylon.
  26178. * It groups all the common properties the materials, post process, lights... might need
  26179. * in order to make a correct use of the texture.
  26180. */
  26181. export class BaseTexture implements IAnimatable {
  26182. /**
  26183. * Default anisotropic filtering level for the application.
  26184. * It is set to 4 as a good tradeoff between perf and quality.
  26185. */
  26186. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26187. /**
  26188. * Gets or sets the unique id of the texture
  26189. */
  26190. uniqueId: number;
  26191. /**
  26192. * Define the name of the texture.
  26193. */
  26194. name: string;
  26195. /**
  26196. * Gets or sets an object used to store user defined information.
  26197. */
  26198. metadata: any;
  26199. /**
  26200. * For internal use only. Please do not use.
  26201. */
  26202. reservedDataStore: any;
  26203. private _hasAlpha;
  26204. /**
  26205. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26206. */
  26207. hasAlpha: boolean;
  26208. /**
  26209. * Defines if the alpha value should be determined via the rgb values.
  26210. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26211. */
  26212. getAlphaFromRGB: boolean;
  26213. /**
  26214. * Intensity or strength of the texture.
  26215. * It is commonly used by materials to fine tune the intensity of the texture
  26216. */
  26217. level: number;
  26218. /**
  26219. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26220. * This is part of the texture as textures usually maps to one uv set.
  26221. */
  26222. coordinatesIndex: number;
  26223. private _coordinatesMode;
  26224. /**
  26225. * How a texture is mapped.
  26226. *
  26227. * | Value | Type | Description |
  26228. * | ----- | ----------------------------------- | ----------- |
  26229. * | 0 | EXPLICIT_MODE | |
  26230. * | 1 | SPHERICAL_MODE | |
  26231. * | 2 | PLANAR_MODE | |
  26232. * | 3 | CUBIC_MODE | |
  26233. * | 4 | PROJECTION_MODE | |
  26234. * | 5 | SKYBOX_MODE | |
  26235. * | 6 | INVCUBIC_MODE | |
  26236. * | 7 | EQUIRECTANGULAR_MODE | |
  26237. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26238. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26239. */
  26240. coordinatesMode: number;
  26241. /**
  26242. * | Value | Type | Description |
  26243. * | ----- | ------------------ | ----------- |
  26244. * | 0 | CLAMP_ADDRESSMODE | |
  26245. * | 1 | WRAP_ADDRESSMODE | |
  26246. * | 2 | MIRROR_ADDRESSMODE | |
  26247. */
  26248. wrapU: number;
  26249. /**
  26250. * | Value | Type | Description |
  26251. * | ----- | ------------------ | ----------- |
  26252. * | 0 | CLAMP_ADDRESSMODE | |
  26253. * | 1 | WRAP_ADDRESSMODE | |
  26254. * | 2 | MIRROR_ADDRESSMODE | |
  26255. */
  26256. wrapV: number;
  26257. /**
  26258. * | Value | Type | Description |
  26259. * | ----- | ------------------ | ----------- |
  26260. * | 0 | CLAMP_ADDRESSMODE | |
  26261. * | 1 | WRAP_ADDRESSMODE | |
  26262. * | 2 | MIRROR_ADDRESSMODE | |
  26263. */
  26264. wrapR: number;
  26265. /**
  26266. * With compliant hardware and browser (supporting anisotropic filtering)
  26267. * this defines the level of anisotropic filtering in the texture.
  26268. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26269. */
  26270. anisotropicFilteringLevel: number;
  26271. /**
  26272. * Define if the texture is a cube texture or if false a 2d texture.
  26273. */
  26274. isCube: boolean;
  26275. /**
  26276. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26277. */
  26278. is3D: boolean;
  26279. /**
  26280. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26281. * HDR texture are usually stored in linear space.
  26282. * This only impacts the PBR and Background materials
  26283. */
  26284. gammaSpace: boolean;
  26285. /**
  26286. * Gets whether or not the texture contains RGBD data.
  26287. */
  26288. readonly isRGBD: boolean;
  26289. /**
  26290. * Is Z inverted in the texture (useful in a cube texture).
  26291. */
  26292. invertZ: boolean;
  26293. /**
  26294. * Are mip maps generated for this texture or not.
  26295. */
  26296. readonly noMipmap: boolean;
  26297. /**
  26298. * @hidden
  26299. */
  26300. lodLevelInAlpha: boolean;
  26301. /**
  26302. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26303. */
  26304. lodGenerationOffset: number;
  26305. /**
  26306. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26307. */
  26308. lodGenerationScale: number;
  26309. /**
  26310. * Define if the texture is a render target.
  26311. */
  26312. isRenderTarget: boolean;
  26313. /**
  26314. * Define the unique id of the texture in the scene.
  26315. */
  26316. readonly uid: string;
  26317. /**
  26318. * Return a string representation of the texture.
  26319. * @returns the texture as a string
  26320. */
  26321. toString(): string;
  26322. /**
  26323. * Get the class name of the texture.
  26324. * @returns "BaseTexture"
  26325. */
  26326. getClassName(): string;
  26327. /**
  26328. * Define the list of animation attached to the texture.
  26329. */
  26330. animations: import("babylonjs/Animations/animation").Animation[];
  26331. /**
  26332. * An event triggered when the texture is disposed.
  26333. */
  26334. onDisposeObservable: Observable<BaseTexture>;
  26335. private _onDisposeObserver;
  26336. /**
  26337. * Callback triggered when the texture has been disposed.
  26338. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26339. */
  26340. onDispose: () => void;
  26341. /**
  26342. * Define the current state of the loading sequence when in delayed load mode.
  26343. */
  26344. delayLoadState: number;
  26345. private _scene;
  26346. /** @hidden */
  26347. _texture: Nullable<InternalTexture>;
  26348. private _uid;
  26349. /**
  26350. * Define if the texture is preventinga material to render or not.
  26351. * If not and the texture is not ready, the engine will use a default black texture instead.
  26352. */
  26353. readonly isBlocking: boolean;
  26354. /**
  26355. * Instantiates a new BaseTexture.
  26356. * Base class of all the textures in babylon.
  26357. * It groups all the common properties the materials, post process, lights... might need
  26358. * in order to make a correct use of the texture.
  26359. * @param scene Define the scene the texture blongs to
  26360. */
  26361. constructor(scene: Nullable<Scene>);
  26362. /**
  26363. * Get the scene the texture belongs to.
  26364. * @returns the scene or null if undefined
  26365. */
  26366. getScene(): Nullable<Scene>;
  26367. /**
  26368. * Get the texture transform matrix used to offset tile the texture for istance.
  26369. * @returns the transformation matrix
  26370. */
  26371. getTextureMatrix(): Matrix;
  26372. /**
  26373. * Get the texture reflection matrix used to rotate/transform the reflection.
  26374. * @returns the reflection matrix
  26375. */
  26376. getReflectionTextureMatrix(): Matrix;
  26377. /**
  26378. * Get the underlying lower level texture from Babylon.
  26379. * @returns the insternal texture
  26380. */
  26381. getInternalTexture(): Nullable<InternalTexture>;
  26382. /**
  26383. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26384. * @returns true if ready or not blocking
  26385. */
  26386. isReadyOrNotBlocking(): boolean;
  26387. /**
  26388. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26389. * @returns true if fully ready
  26390. */
  26391. isReady(): boolean;
  26392. private _cachedSize;
  26393. /**
  26394. * Get the size of the texture.
  26395. * @returns the texture size.
  26396. */
  26397. getSize(): ISize;
  26398. /**
  26399. * Get the base size of the texture.
  26400. * It can be different from the size if the texture has been resized for POT for instance
  26401. * @returns the base size
  26402. */
  26403. getBaseSize(): ISize;
  26404. /**
  26405. * Update the sampling mode of the texture.
  26406. * Default is Trilinear mode.
  26407. *
  26408. * | Value | Type | Description |
  26409. * | ----- | ------------------ | ----------- |
  26410. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26411. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26412. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26413. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26414. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26415. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26416. * | 7 | NEAREST_LINEAR | |
  26417. * | 8 | NEAREST_NEAREST | |
  26418. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26419. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26420. * | 11 | LINEAR_LINEAR | |
  26421. * | 12 | LINEAR_NEAREST | |
  26422. *
  26423. * > _mag_: magnification filter (close to the viewer)
  26424. * > _min_: minification filter (far from the viewer)
  26425. * > _mip_: filter used between mip map levels
  26426. *@param samplingMode Define the new sampling mode of the texture
  26427. */
  26428. updateSamplingMode(samplingMode: number): void;
  26429. /**
  26430. * Scales the texture if is `canRescale()`
  26431. * @param ratio the resize factor we want to use to rescale
  26432. */
  26433. scale(ratio: number): void;
  26434. /**
  26435. * Get if the texture can rescale.
  26436. */
  26437. readonly canRescale: boolean;
  26438. /** @hidden */
  26439. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26440. /** @hidden */
  26441. _rebuild(): void;
  26442. /**
  26443. * Triggers the load sequence in delayed load mode.
  26444. */
  26445. delayLoad(): void;
  26446. /**
  26447. * Clones the texture.
  26448. * @returns the cloned texture
  26449. */
  26450. clone(): Nullable<BaseTexture>;
  26451. /**
  26452. * Get the texture underlying type (INT, FLOAT...)
  26453. */
  26454. readonly textureType: number;
  26455. /**
  26456. * Get the texture underlying format (RGB, RGBA...)
  26457. */
  26458. readonly textureFormat: number;
  26459. /**
  26460. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26461. * This will returns an RGBA array buffer containing either in values (0-255) or
  26462. * float values (0-1) depending of the underlying buffer type.
  26463. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26464. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26465. * @param buffer defines a user defined buffer to fill with data (can be null)
  26466. * @returns The Array buffer containing the pixels data.
  26467. */
  26468. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26469. /**
  26470. * Release and destroy the underlying lower level texture aka internalTexture.
  26471. */
  26472. releaseInternalTexture(): void;
  26473. /**
  26474. * Get the polynomial representation of the texture data.
  26475. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26476. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26477. */
  26478. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26479. /** @hidden */
  26480. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26481. /** @hidden */
  26482. readonly _lodTextureMid: Nullable<BaseTexture>;
  26483. /** @hidden */
  26484. readonly _lodTextureLow: Nullable<BaseTexture>;
  26485. /**
  26486. * Dispose the texture and release its associated resources.
  26487. */
  26488. dispose(): void;
  26489. /**
  26490. * Serialize the texture into a JSON representation that can be parsed later on.
  26491. * @returns the JSON representation of the texture
  26492. */
  26493. serialize(): any;
  26494. /**
  26495. * Helper function to be called back once a list of texture contains only ready textures.
  26496. * @param textures Define the list of textures to wait for
  26497. * @param callback Define the callback triggered once the entire list will be ready
  26498. */
  26499. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26500. }
  26501. }
  26502. declare module "babylonjs/Materials/uniformBuffer" {
  26503. import { Nullable, FloatArray } from "babylonjs/types";
  26504. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26505. import { Engine } from "babylonjs/Engines/engine";
  26506. import { Effect } from "babylonjs/Materials/effect";
  26507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26508. /**
  26509. * Uniform buffer objects.
  26510. *
  26511. * Handles blocks of uniform on the GPU.
  26512. *
  26513. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26514. *
  26515. * For more information, please refer to :
  26516. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26517. */
  26518. export class UniformBuffer {
  26519. private _engine;
  26520. private _buffer;
  26521. private _data;
  26522. private _bufferData;
  26523. private _dynamic?;
  26524. private _uniformLocations;
  26525. private _uniformSizes;
  26526. private _uniformLocationPointer;
  26527. private _needSync;
  26528. private _noUBO;
  26529. private _currentEffect;
  26530. private static _MAX_UNIFORM_SIZE;
  26531. private static _tempBuffer;
  26532. /**
  26533. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26534. * This is dynamic to allow compat with webgl 1 and 2.
  26535. * You will need to pass the name of the uniform as well as the value.
  26536. */
  26537. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26538. /**
  26539. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26540. * This is dynamic to allow compat with webgl 1 and 2.
  26541. * You will need to pass the name of the uniform as well as the value.
  26542. */
  26543. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26544. /**
  26545. * Lambda to Update a single float in a uniform buffer.
  26546. * This is dynamic to allow compat with webgl 1 and 2.
  26547. * You will need to pass the name of the uniform as well as the value.
  26548. */
  26549. updateFloat: (name: string, x: number) => void;
  26550. /**
  26551. * Lambda to Update a vec2 of float in a uniform buffer.
  26552. * This is dynamic to allow compat with webgl 1 and 2.
  26553. * You will need to pass the name of the uniform as well as the value.
  26554. */
  26555. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26556. /**
  26557. * Lambda to Update a vec3 of float in a uniform buffer.
  26558. * This is dynamic to allow compat with webgl 1 and 2.
  26559. * You will need to pass the name of the uniform as well as the value.
  26560. */
  26561. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26562. /**
  26563. * Lambda to Update a vec4 of float in a uniform buffer.
  26564. * This is dynamic to allow compat with webgl 1 and 2.
  26565. * You will need to pass the name of the uniform as well as the value.
  26566. */
  26567. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26568. /**
  26569. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26570. * This is dynamic to allow compat with webgl 1 and 2.
  26571. * You will need to pass the name of the uniform as well as the value.
  26572. */
  26573. updateMatrix: (name: string, mat: Matrix) => void;
  26574. /**
  26575. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26576. * This is dynamic to allow compat with webgl 1 and 2.
  26577. * You will need to pass the name of the uniform as well as the value.
  26578. */
  26579. updateVector3: (name: string, vector: Vector3) => void;
  26580. /**
  26581. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26582. * This is dynamic to allow compat with webgl 1 and 2.
  26583. * You will need to pass the name of the uniform as well as the value.
  26584. */
  26585. updateVector4: (name: string, vector: Vector4) => void;
  26586. /**
  26587. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26588. * This is dynamic to allow compat with webgl 1 and 2.
  26589. * You will need to pass the name of the uniform as well as the value.
  26590. */
  26591. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26592. /**
  26593. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26594. * This is dynamic to allow compat with webgl 1 and 2.
  26595. * You will need to pass the name of the uniform as well as the value.
  26596. */
  26597. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26598. /**
  26599. * Instantiates a new Uniform buffer objects.
  26600. *
  26601. * Handles blocks of uniform on the GPU.
  26602. *
  26603. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26604. *
  26605. * For more information, please refer to :
  26606. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26607. * @param engine Define the engine the buffer is associated with
  26608. * @param data Define the data contained in the buffer
  26609. * @param dynamic Define if the buffer is updatable
  26610. */
  26611. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26612. /**
  26613. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26614. * or just falling back on setUniformXXX calls.
  26615. */
  26616. readonly useUbo: boolean;
  26617. /**
  26618. * Indicates if the WebGL underlying uniform buffer is in sync
  26619. * with the javascript cache data.
  26620. */
  26621. readonly isSync: boolean;
  26622. /**
  26623. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26624. * Also, a dynamic UniformBuffer will disable cache verification and always
  26625. * update the underlying WebGL uniform buffer to the GPU.
  26626. * @returns if Dynamic, otherwise false
  26627. */
  26628. isDynamic(): boolean;
  26629. /**
  26630. * The data cache on JS side.
  26631. * @returns the underlying data as a float array
  26632. */
  26633. getData(): Float32Array;
  26634. /**
  26635. * The underlying WebGL Uniform buffer.
  26636. * @returns the webgl buffer
  26637. */
  26638. getBuffer(): Nullable<WebGLBuffer>;
  26639. /**
  26640. * std140 layout specifies how to align data within an UBO structure.
  26641. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26642. * for specs.
  26643. */
  26644. private _fillAlignment;
  26645. /**
  26646. * Adds an uniform in the buffer.
  26647. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26648. * for the layout to be correct !
  26649. * @param name Name of the uniform, as used in the uniform block in the shader.
  26650. * @param size Data size, or data directly.
  26651. */
  26652. addUniform(name: string, size: number | number[]): void;
  26653. /**
  26654. * Adds a Matrix 4x4 to the uniform buffer.
  26655. * @param name Name of the uniform, as used in the uniform block in the shader.
  26656. * @param mat A 4x4 matrix.
  26657. */
  26658. addMatrix(name: string, mat: Matrix): void;
  26659. /**
  26660. * Adds a vec2 to the uniform buffer.
  26661. * @param name Name of the uniform, as used in the uniform block in the shader.
  26662. * @param x Define the x component value of the vec2
  26663. * @param y Define the y component value of the vec2
  26664. */
  26665. addFloat2(name: string, x: number, y: number): void;
  26666. /**
  26667. * Adds a vec3 to the uniform buffer.
  26668. * @param name Name of the uniform, as used in the uniform block in the shader.
  26669. * @param x Define the x component value of the vec3
  26670. * @param y Define the y component value of the vec3
  26671. * @param z Define the z component value of the vec3
  26672. */
  26673. addFloat3(name: string, x: number, y: number, z: number): void;
  26674. /**
  26675. * Adds a vec3 to the uniform buffer.
  26676. * @param name Name of the uniform, as used in the uniform block in the shader.
  26677. * @param color Define the vec3 from a Color
  26678. */
  26679. addColor3(name: string, color: Color3): void;
  26680. /**
  26681. * Adds a vec4 to the uniform buffer.
  26682. * @param name Name of the uniform, as used in the uniform block in the shader.
  26683. * @param color Define the rgb components from a Color
  26684. * @param alpha Define the a component of the vec4
  26685. */
  26686. addColor4(name: string, color: Color3, alpha: number): void;
  26687. /**
  26688. * Adds a vec3 to the uniform buffer.
  26689. * @param name Name of the uniform, as used in the uniform block in the shader.
  26690. * @param vector Define the vec3 components from a Vector
  26691. */
  26692. addVector3(name: string, vector: Vector3): void;
  26693. /**
  26694. * Adds a Matrix 3x3 to the uniform buffer.
  26695. * @param name Name of the uniform, as used in the uniform block in the shader.
  26696. */
  26697. addMatrix3x3(name: string): void;
  26698. /**
  26699. * Adds a Matrix 2x2 to the uniform buffer.
  26700. * @param name Name of the uniform, as used in the uniform block in the shader.
  26701. */
  26702. addMatrix2x2(name: string): void;
  26703. /**
  26704. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26705. */
  26706. create(): void;
  26707. /** @hidden */
  26708. _rebuild(): void;
  26709. /**
  26710. * Updates the WebGL Uniform Buffer on the GPU.
  26711. * If the `dynamic` flag is set to true, no cache comparison is done.
  26712. * Otherwise, the buffer will be updated only if the cache differs.
  26713. */
  26714. update(): void;
  26715. /**
  26716. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26717. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26718. * @param data Define the flattened data
  26719. * @param size Define the size of the data.
  26720. */
  26721. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26722. private _updateMatrix3x3ForUniform;
  26723. private _updateMatrix3x3ForEffect;
  26724. private _updateMatrix2x2ForEffect;
  26725. private _updateMatrix2x2ForUniform;
  26726. private _updateFloatForEffect;
  26727. private _updateFloatForUniform;
  26728. private _updateFloat2ForEffect;
  26729. private _updateFloat2ForUniform;
  26730. private _updateFloat3ForEffect;
  26731. private _updateFloat3ForUniform;
  26732. private _updateFloat4ForEffect;
  26733. private _updateFloat4ForUniform;
  26734. private _updateMatrixForEffect;
  26735. private _updateMatrixForUniform;
  26736. private _updateVector3ForEffect;
  26737. private _updateVector3ForUniform;
  26738. private _updateVector4ForEffect;
  26739. private _updateVector4ForUniform;
  26740. private _updateColor3ForEffect;
  26741. private _updateColor3ForUniform;
  26742. private _updateColor4ForEffect;
  26743. private _updateColor4ForUniform;
  26744. /**
  26745. * Sets a sampler uniform on the effect.
  26746. * @param name Define the name of the sampler.
  26747. * @param texture Define the texture to set in the sampler
  26748. */
  26749. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26750. /**
  26751. * Directly updates the value of the uniform in the cache AND on the GPU.
  26752. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26753. * @param data Define the flattened data
  26754. */
  26755. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26756. /**
  26757. * Binds this uniform buffer to an effect.
  26758. * @param effect Define the effect to bind the buffer to
  26759. * @param name Name of the uniform block in the shader.
  26760. */
  26761. bindToEffect(effect: Effect, name: string): void;
  26762. /**
  26763. * Disposes the uniform buffer.
  26764. */
  26765. dispose(): void;
  26766. }
  26767. }
  26768. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26769. import { Nullable } from "babylonjs/types";
  26770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26771. /**
  26772. * This represents the required contract to create a new type of texture loader.
  26773. */
  26774. export interface IInternalTextureLoader {
  26775. /**
  26776. * Defines wether the loader supports cascade loading the different faces.
  26777. */
  26778. supportCascades: boolean;
  26779. /**
  26780. * This returns if the loader support the current file information.
  26781. * @param extension defines the file extension of the file being loaded
  26782. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26783. * @param fallback defines the fallback internal texture if any
  26784. * @param isBase64 defines whether the texture is encoded as a base64
  26785. * @param isBuffer defines whether the texture data are stored as a buffer
  26786. * @returns true if the loader can load the specified file
  26787. */
  26788. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26789. /**
  26790. * Transform the url before loading if required.
  26791. * @param rootUrl the url of the texture
  26792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26793. * @returns the transformed texture
  26794. */
  26795. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26796. /**
  26797. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26798. * @param rootUrl the url of the texture
  26799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26800. * @returns the fallback texture
  26801. */
  26802. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26803. /**
  26804. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26805. * @param data contains the texture data
  26806. * @param texture defines the BabylonJS internal texture
  26807. * @param createPolynomials will be true if polynomials have been requested
  26808. * @param onLoad defines the callback to trigger once the texture is ready
  26809. * @param onError defines the callback to trigger in case of error
  26810. */
  26811. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26812. /**
  26813. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26814. * @param data contains the texture data
  26815. * @param texture defines the BabylonJS internal texture
  26816. * @param callback defines the method to call once ready to upload
  26817. */
  26818. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26819. }
  26820. }
  26821. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26822. import { Scene } from "babylonjs/scene";
  26823. import { Engine } from "babylonjs/Engines/engine";
  26824. import { Texture } from "babylonjs/Materials/Textures/texture";
  26825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26826. /**
  26827. * Creation options of the multi render target texture.
  26828. */
  26829. export interface IMultiRenderTargetOptions {
  26830. /**
  26831. * Define if the texture needs to create mip maps after render.
  26832. */
  26833. generateMipMaps?: boolean;
  26834. /**
  26835. * Define the types of all the draw buffers we want to create
  26836. */
  26837. types?: number[];
  26838. /**
  26839. * Define the sampling modes of all the draw buffers we want to create
  26840. */
  26841. samplingModes?: number[];
  26842. /**
  26843. * Define if a depth buffer is required
  26844. */
  26845. generateDepthBuffer?: boolean;
  26846. /**
  26847. * Define if a stencil buffer is required
  26848. */
  26849. generateStencilBuffer?: boolean;
  26850. /**
  26851. * Define if a depth texture is required instead of a depth buffer
  26852. */
  26853. generateDepthTexture?: boolean;
  26854. /**
  26855. * Define the number of desired draw buffers
  26856. */
  26857. textureCount?: number;
  26858. /**
  26859. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26860. */
  26861. doNotChangeAspectRatio?: boolean;
  26862. /**
  26863. * Define the default type of the buffers we are creating
  26864. */
  26865. defaultType?: number;
  26866. }
  26867. /**
  26868. * A multi render target, like a render target provides the ability to render to a texture.
  26869. * Unlike the render target, it can render to several draw buffers in one draw.
  26870. * This is specially interesting in deferred rendering or for any effects requiring more than
  26871. * just one color from a single pass.
  26872. */
  26873. export class MultiRenderTarget extends RenderTargetTexture {
  26874. private _internalTextures;
  26875. private _textures;
  26876. private _multiRenderTargetOptions;
  26877. /**
  26878. * Get if draw buffers are currently supported by the used hardware and browser.
  26879. */
  26880. readonly isSupported: boolean;
  26881. /**
  26882. * Get the list of textures generated by the multi render target.
  26883. */
  26884. readonly textures: Texture[];
  26885. /**
  26886. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26887. */
  26888. readonly depthTexture: Texture;
  26889. /**
  26890. * Set the wrapping mode on U of all the textures we are rendering to.
  26891. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26892. */
  26893. wrapU: number;
  26894. /**
  26895. * Set the wrapping mode on V of all the textures we are rendering to.
  26896. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26897. */
  26898. wrapV: number;
  26899. /**
  26900. * Instantiate a new multi render target texture.
  26901. * A multi render target, like a render target provides the ability to render to a texture.
  26902. * Unlike the render target, it can render to several draw buffers in one draw.
  26903. * This is specially interesting in deferred rendering or for any effects requiring more than
  26904. * just one color from a single pass.
  26905. * @param name Define the name of the texture
  26906. * @param size Define the size of the buffers to render to
  26907. * @param count Define the number of target we are rendering into
  26908. * @param scene Define the scene the texture belongs to
  26909. * @param options Define the options used to create the multi render target
  26910. */
  26911. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26912. /** @hidden */
  26913. _rebuild(): void;
  26914. private _createInternalTextures;
  26915. private _createTextures;
  26916. /**
  26917. * Define the number of samples used if MSAA is enabled.
  26918. */
  26919. samples: number;
  26920. /**
  26921. * Resize all the textures in the multi render target.
  26922. * Be carrefull as it will recreate all the data in the new texture.
  26923. * @param size Define the new size
  26924. */
  26925. resize(size: any): void;
  26926. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26927. /**
  26928. * Dispose the render targets and their associated resources
  26929. */
  26930. dispose(): void;
  26931. /**
  26932. * Release all the underlying texture used as draw buffers.
  26933. */
  26934. releaseInternalTextures(): void;
  26935. }
  26936. }
  26937. declare module "babylonjs/Audio/analyser" {
  26938. import { Scene } from "babylonjs/scene";
  26939. /**
  26940. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26942. */
  26943. export class Analyser {
  26944. /**
  26945. * Gets or sets the smoothing
  26946. * @ignorenaming
  26947. */
  26948. SMOOTHING: number;
  26949. /**
  26950. * Gets or sets the FFT table size
  26951. * @ignorenaming
  26952. */
  26953. FFT_SIZE: number;
  26954. /**
  26955. * Gets or sets the bar graph amplitude
  26956. * @ignorenaming
  26957. */
  26958. BARGRAPHAMPLITUDE: number;
  26959. /**
  26960. * Gets or sets the position of the debug canvas
  26961. * @ignorenaming
  26962. */
  26963. DEBUGCANVASPOS: {
  26964. x: number;
  26965. y: number;
  26966. };
  26967. /**
  26968. * Gets or sets the debug canvas size
  26969. * @ignorenaming
  26970. */
  26971. DEBUGCANVASSIZE: {
  26972. width: number;
  26973. height: number;
  26974. };
  26975. private _byteFreqs;
  26976. private _byteTime;
  26977. private _floatFreqs;
  26978. private _webAudioAnalyser;
  26979. private _debugCanvas;
  26980. private _debugCanvasContext;
  26981. private _scene;
  26982. private _registerFunc;
  26983. private _audioEngine;
  26984. /**
  26985. * Creates a new analyser
  26986. * @param scene defines hosting scene
  26987. */
  26988. constructor(scene: Scene);
  26989. /**
  26990. * Get the number of data values you will have to play with for the visualization
  26991. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26992. * @returns a number
  26993. */
  26994. getFrequencyBinCount(): number;
  26995. /**
  26996. * Gets the current frequency data as a byte array
  26997. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26998. * @returns a Uint8Array
  26999. */
  27000. getByteFrequencyData(): Uint8Array;
  27001. /**
  27002. * Gets the current waveform as a byte array
  27003. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27004. * @returns a Uint8Array
  27005. */
  27006. getByteTimeDomainData(): Uint8Array;
  27007. /**
  27008. * Gets the current frequency data as a float array
  27009. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27010. * @returns a Float32Array
  27011. */
  27012. getFloatFrequencyData(): Float32Array;
  27013. /**
  27014. * Renders the debug canvas
  27015. */
  27016. drawDebugCanvas(): void;
  27017. /**
  27018. * Stops rendering the debug canvas and removes it
  27019. */
  27020. stopDebugCanvas(): void;
  27021. /**
  27022. * Connects two audio nodes
  27023. * @param inputAudioNode defines first node to connect
  27024. * @param outputAudioNode defines second node to connect
  27025. */
  27026. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27027. /**
  27028. * Releases all associated resources
  27029. */
  27030. dispose(): void;
  27031. }
  27032. }
  27033. declare module "babylonjs/Audio/audioEngine" {
  27034. import { IDisposable } from "babylonjs/scene";
  27035. import { Analyser } from "babylonjs/Audio/analyser";
  27036. import { Nullable } from "babylonjs/types";
  27037. import { Observable } from "babylonjs/Misc/observable";
  27038. /**
  27039. * This represents an audio engine and it is responsible
  27040. * to play, synchronize and analyse sounds throughout the application.
  27041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27042. */
  27043. export interface IAudioEngine extends IDisposable {
  27044. /**
  27045. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27046. */
  27047. readonly canUseWebAudio: boolean;
  27048. /**
  27049. * Gets the current AudioContext if available.
  27050. */
  27051. readonly audioContext: Nullable<AudioContext>;
  27052. /**
  27053. * The master gain node defines the global audio volume of your audio engine.
  27054. */
  27055. readonly masterGain: GainNode;
  27056. /**
  27057. * Gets whether or not mp3 are supported by your browser.
  27058. */
  27059. readonly isMP3supported: boolean;
  27060. /**
  27061. * Gets whether or not ogg are supported by your browser.
  27062. */
  27063. readonly isOGGsupported: boolean;
  27064. /**
  27065. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27066. * @ignoreNaming
  27067. */
  27068. WarnedWebAudioUnsupported: boolean;
  27069. /**
  27070. * Defines if the audio engine relies on a custom unlocked button.
  27071. * In this case, the embedded button will not be displayed.
  27072. */
  27073. useCustomUnlockedButton: boolean;
  27074. /**
  27075. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27076. */
  27077. readonly unlocked: boolean;
  27078. /**
  27079. * Event raised when audio has been unlocked on the browser.
  27080. */
  27081. onAudioUnlockedObservable: Observable<AudioEngine>;
  27082. /**
  27083. * Event raised when audio has been locked on the browser.
  27084. */
  27085. onAudioLockedObservable: Observable<AudioEngine>;
  27086. /**
  27087. * Flags the audio engine in Locked state.
  27088. * This happens due to new browser policies preventing audio to autoplay.
  27089. */
  27090. lock(): void;
  27091. /**
  27092. * Unlocks the audio engine once a user action has been done on the dom.
  27093. * This is helpful to resume play once browser policies have been satisfied.
  27094. */
  27095. unlock(): void;
  27096. }
  27097. /**
  27098. * This represents the default audio engine used in babylon.
  27099. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27101. */
  27102. export class AudioEngine implements IAudioEngine {
  27103. private _audioContext;
  27104. private _audioContextInitialized;
  27105. private _muteButton;
  27106. private _hostElement;
  27107. /**
  27108. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27109. */
  27110. canUseWebAudio: boolean;
  27111. /**
  27112. * The master gain node defines the global audio volume of your audio engine.
  27113. */
  27114. masterGain: GainNode;
  27115. /**
  27116. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27117. * @ignoreNaming
  27118. */
  27119. WarnedWebAudioUnsupported: boolean;
  27120. /**
  27121. * Gets whether or not mp3 are supported by your browser.
  27122. */
  27123. isMP3supported: boolean;
  27124. /**
  27125. * Gets whether or not ogg are supported by your browser.
  27126. */
  27127. isOGGsupported: boolean;
  27128. /**
  27129. * Gets whether audio has been unlocked on the device.
  27130. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27131. * a user interaction has happened.
  27132. */
  27133. unlocked: boolean;
  27134. /**
  27135. * Defines if the audio engine relies on a custom unlocked button.
  27136. * In this case, the embedded button will not be displayed.
  27137. */
  27138. useCustomUnlockedButton: boolean;
  27139. /**
  27140. * Event raised when audio has been unlocked on the browser.
  27141. */
  27142. onAudioUnlockedObservable: Observable<AudioEngine>;
  27143. /**
  27144. * Event raised when audio has been locked on the browser.
  27145. */
  27146. onAudioLockedObservable: Observable<AudioEngine>;
  27147. /**
  27148. * Gets the current AudioContext if available.
  27149. */
  27150. readonly audioContext: Nullable<AudioContext>;
  27151. private _connectedAnalyser;
  27152. /**
  27153. * Instantiates a new audio engine.
  27154. *
  27155. * There should be only one per page as some browsers restrict the number
  27156. * of audio contexts you can create.
  27157. * @param hostElement defines the host element where to display the mute icon if necessary
  27158. */
  27159. constructor(hostElement?: Nullable<HTMLElement>);
  27160. /**
  27161. * Flags the audio engine in Locked state.
  27162. * This happens due to new browser policies preventing audio to autoplay.
  27163. */
  27164. lock(): void;
  27165. /**
  27166. * Unlocks the audio engine once a user action has been done on the dom.
  27167. * This is helpful to resume play once browser policies have been satisfied.
  27168. */
  27169. unlock(): void;
  27170. private _resumeAudioContext;
  27171. private _initializeAudioContext;
  27172. private _tryToRun;
  27173. private _triggerRunningState;
  27174. private _triggerSuspendedState;
  27175. private _displayMuteButton;
  27176. private _moveButtonToTopLeft;
  27177. private _onResize;
  27178. private _hideMuteButton;
  27179. /**
  27180. * Destroy and release the resources associated with the audio ccontext.
  27181. */
  27182. dispose(): void;
  27183. /**
  27184. * Gets the global volume sets on the master gain.
  27185. * @returns the global volume if set or -1 otherwise
  27186. */
  27187. getGlobalVolume(): number;
  27188. /**
  27189. * Sets the global volume of your experience (sets on the master gain).
  27190. * @param newVolume Defines the new global volume of the application
  27191. */
  27192. setGlobalVolume(newVolume: number): void;
  27193. /**
  27194. * Connect the audio engine to an audio analyser allowing some amazing
  27195. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27197. * @param analyser The analyser to connect to the engine
  27198. */
  27199. connectToAnalyser(analyser: Analyser): void;
  27200. }
  27201. }
  27202. declare module "babylonjs/Loading/loadingScreen" {
  27203. /**
  27204. * Interface used to present a loading screen while loading a scene
  27205. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27206. */
  27207. export interface ILoadingScreen {
  27208. /**
  27209. * Function called to display the loading screen
  27210. */
  27211. displayLoadingUI: () => void;
  27212. /**
  27213. * Function called to hide the loading screen
  27214. */
  27215. hideLoadingUI: () => void;
  27216. /**
  27217. * Gets or sets the color to use for the background
  27218. */
  27219. loadingUIBackgroundColor: string;
  27220. /**
  27221. * Gets or sets the text to display while loading
  27222. */
  27223. loadingUIText: string;
  27224. }
  27225. /**
  27226. * Class used for the default loading screen
  27227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27228. */
  27229. export class DefaultLoadingScreen implements ILoadingScreen {
  27230. private _renderingCanvas;
  27231. private _loadingText;
  27232. private _loadingDivBackgroundColor;
  27233. private _loadingDiv;
  27234. private _loadingTextDiv;
  27235. /**
  27236. * Creates a new default loading screen
  27237. * @param _renderingCanvas defines the canvas used to render the scene
  27238. * @param _loadingText defines the default text to display
  27239. * @param _loadingDivBackgroundColor defines the default background color
  27240. */
  27241. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  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 text to display while loading
  27252. */
  27253. loadingUIText: string;
  27254. /**
  27255. * Gets or sets the color to use for the background
  27256. */
  27257. loadingUIBackgroundColor: string;
  27258. private _resizeLoadingUI;
  27259. }
  27260. }
  27261. declare module "babylonjs/Materials/Textures/videoTexture" {
  27262. import { Observable } from "babylonjs/Misc/observable";
  27263. import { Nullable } from "babylonjs/types";
  27264. import { Scene } from "babylonjs/scene";
  27265. import { Texture } from "babylonjs/Materials/Textures/texture";
  27266. /**
  27267. * Settings for finer control over video usage
  27268. */
  27269. export interface VideoTextureSettings {
  27270. /**
  27271. * Applies `autoplay` to video, if specified
  27272. */
  27273. autoPlay?: boolean;
  27274. /**
  27275. * Applies `loop` to video, if specified
  27276. */
  27277. loop?: boolean;
  27278. /**
  27279. * Automatically updates internal texture from video at every frame in the render loop
  27280. */
  27281. autoUpdateTexture: boolean;
  27282. /**
  27283. * Image src displayed during the video loading or until the user interacts with the video.
  27284. */
  27285. poster?: string;
  27286. }
  27287. /**
  27288. * If you want to display a video in your scene, this is the special texture for that.
  27289. * This special texture works similar to other textures, with the exception of a few parameters.
  27290. * @see https://doc.babylonjs.com/how_to/video_texture
  27291. */
  27292. export class VideoTexture extends Texture {
  27293. /**
  27294. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27295. */
  27296. readonly autoUpdateTexture: boolean;
  27297. /**
  27298. * The video instance used by the texture internally
  27299. */
  27300. readonly video: HTMLVideoElement;
  27301. private _onUserActionRequestedObservable;
  27302. /**
  27303. * Event triggerd when a dom action is required by the user to play the video.
  27304. * This happens due to recent changes in browser policies preventing video to auto start.
  27305. */
  27306. readonly onUserActionRequestedObservable: Observable<Texture>;
  27307. private _generateMipMaps;
  27308. private _engine;
  27309. private _stillImageCaptured;
  27310. private _displayingPosterTexture;
  27311. private _settings;
  27312. private _createInternalTextureOnEvent;
  27313. /**
  27314. * Creates a video texture.
  27315. * If you want to display a video in your scene, this is the special texture for that.
  27316. * This special texture works similar to other textures, with the exception of a few parameters.
  27317. * @see https://doc.babylonjs.com/how_to/video_texture
  27318. * @param name optional name, will detect from video source, if not defined
  27319. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27320. * @param scene is obviously the current scene.
  27321. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27322. * @param invertY is false by default but can be used to invert video on Y axis
  27323. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27324. * @param settings allows finer control over video usage
  27325. */
  27326. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27327. private _getName;
  27328. private _getVideo;
  27329. private _createInternalTexture;
  27330. private reset;
  27331. /**
  27332. * @hidden Internal method to initiate `update`.
  27333. */
  27334. _rebuild(): void;
  27335. /**
  27336. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27337. */
  27338. update(): void;
  27339. /**
  27340. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27341. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27342. */
  27343. updateTexture(isVisible: boolean): void;
  27344. protected _updateInternalTexture: () => void;
  27345. /**
  27346. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27347. * @param url New url.
  27348. */
  27349. updateURL(url: string): void;
  27350. /**
  27351. * Dispose the texture and release its associated resources.
  27352. */
  27353. dispose(): void;
  27354. /**
  27355. * Creates a video texture straight from a stream.
  27356. * @param scene Define the scene the texture should be created in
  27357. * @param stream Define the stream the texture should be created from
  27358. * @returns The created video texture as a promise
  27359. */
  27360. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27361. /**
  27362. * Creates a video texture straight from your WebCam video feed.
  27363. * @param scene Define the scene the texture should be created in
  27364. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27365. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27366. * @returns The created video texture as a promise
  27367. */
  27368. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27369. minWidth: number;
  27370. maxWidth: number;
  27371. minHeight: number;
  27372. maxHeight: number;
  27373. deviceId: string;
  27374. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27375. /**
  27376. * Creates a video texture straight from your WebCam video feed.
  27377. * @param scene Define the scene the texture should be created in
  27378. * @param onReady Define a callback to triggered once the texture will be ready
  27379. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27380. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27381. */
  27382. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27383. minWidth: number;
  27384. maxWidth: number;
  27385. minHeight: number;
  27386. maxHeight: number;
  27387. deviceId: string;
  27388. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27389. }
  27390. }
  27391. declare module "babylonjs/Engines/engine" {
  27392. import { Observable } from "babylonjs/Misc/observable";
  27393. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27394. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27395. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27396. import { Camera } from "babylonjs/Cameras/camera";
  27397. import { Scene } from "babylonjs/scene";
  27398. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27399. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27400. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27402. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27403. import { Material } from "babylonjs/Materials/material";
  27404. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27405. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27407. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27408. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27409. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27410. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27411. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27412. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27413. import { WebRequest } from "babylonjs/Misc/webRequest";
  27414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27416. /**
  27417. * Interface for attribute information associated with buffer instanciation
  27418. */
  27419. export class InstancingAttributeInfo {
  27420. /**
  27421. * Index/offset of the attribute in the vertex shader
  27422. */
  27423. index: number;
  27424. /**
  27425. * size of the attribute, 1, 2, 3 or 4
  27426. */
  27427. attributeSize: number;
  27428. /**
  27429. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27430. * default is FLOAT
  27431. */
  27432. attribyteType: number;
  27433. /**
  27434. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27435. */
  27436. normalized: boolean;
  27437. /**
  27438. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27439. */
  27440. offset: number;
  27441. /**
  27442. * Name of the GLSL attribute, for debugging purpose only
  27443. */
  27444. attributeName: string;
  27445. }
  27446. /**
  27447. * Define options used to create a depth texture
  27448. */
  27449. export class DepthTextureCreationOptions {
  27450. /** Specifies whether or not a stencil should be allocated in the texture */
  27451. generateStencil?: boolean;
  27452. /** Specifies whether or not bilinear filtering is enable on the texture */
  27453. bilinearFiltering?: boolean;
  27454. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27455. comparisonFunction?: number;
  27456. /** Specifies if the created texture is a cube texture */
  27457. isCube?: boolean;
  27458. }
  27459. /**
  27460. * Class used to describe the capabilities of the engine relatively to the current browser
  27461. */
  27462. export class EngineCapabilities {
  27463. /** Maximum textures units per fragment shader */
  27464. maxTexturesImageUnits: number;
  27465. /** Maximum texture units per vertex shader */
  27466. maxVertexTextureImageUnits: number;
  27467. /** Maximum textures units in the entire pipeline */
  27468. maxCombinedTexturesImageUnits: number;
  27469. /** Maximum texture size */
  27470. maxTextureSize: number;
  27471. /** Maximum cube texture size */
  27472. maxCubemapTextureSize: number;
  27473. /** Maximum render texture size */
  27474. maxRenderTextureSize: number;
  27475. /** Maximum number of vertex attributes */
  27476. maxVertexAttribs: number;
  27477. /** Maximum number of varyings */
  27478. maxVaryingVectors: number;
  27479. /** Maximum number of uniforms per vertex shader */
  27480. maxVertexUniformVectors: number;
  27481. /** Maximum number of uniforms per fragment shader */
  27482. maxFragmentUniformVectors: number;
  27483. /** Defines if standard derivates (dx/dy) are supported */
  27484. standardDerivatives: boolean;
  27485. /** Defines if s3tc texture compression is supported */
  27486. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27487. /** Defines if pvrtc texture compression is supported */
  27488. pvrtc: any;
  27489. /** Defines if etc1 texture compression is supported */
  27490. etc1: any;
  27491. /** Defines if etc2 texture compression is supported */
  27492. etc2: any;
  27493. /** Defines if astc texture compression is supported */
  27494. astc: any;
  27495. /** Defines if float textures are supported */
  27496. textureFloat: boolean;
  27497. /** Defines if vertex array objects are supported */
  27498. vertexArrayObject: boolean;
  27499. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27500. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27501. /** Gets the maximum level of anisotropy supported */
  27502. maxAnisotropy: number;
  27503. /** Defines if instancing is supported */
  27504. instancedArrays: boolean;
  27505. /** Defines if 32 bits indices are supported */
  27506. uintIndices: boolean;
  27507. /** Defines if high precision shaders are supported */
  27508. highPrecisionShaderSupported: boolean;
  27509. /** Defines if depth reading in the fragment shader is supported */
  27510. fragmentDepthSupported: boolean;
  27511. /** Defines if float texture linear filtering is supported*/
  27512. textureFloatLinearFiltering: boolean;
  27513. /** Defines if rendering to float textures is supported */
  27514. textureFloatRender: boolean;
  27515. /** Defines if half float textures are supported*/
  27516. textureHalfFloat: boolean;
  27517. /** Defines if half float texture linear filtering is supported*/
  27518. textureHalfFloatLinearFiltering: boolean;
  27519. /** Defines if rendering to half float textures is supported */
  27520. textureHalfFloatRender: boolean;
  27521. /** Defines if textureLOD shader command is supported */
  27522. textureLOD: boolean;
  27523. /** Defines if draw buffers extension is supported */
  27524. drawBuffersExtension: boolean;
  27525. /** Defines if depth textures are supported */
  27526. depthTextureExtension: boolean;
  27527. /** Defines if float color buffer are supported */
  27528. colorBufferFloat: boolean;
  27529. /** Gets disjoint timer query extension (null if not supported) */
  27530. timerQuery: EXT_disjoint_timer_query;
  27531. /** Defines if timestamp can be used with timer query */
  27532. canUseTimestampForTimerQuery: boolean;
  27533. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27534. multiview: any;
  27535. /** Function used to let the system compiles shaders in background */
  27536. parallelShaderCompile: {
  27537. COMPLETION_STATUS_KHR: number;
  27538. };
  27539. }
  27540. /** Interface defining initialization parameters for Engine class */
  27541. export interface EngineOptions extends WebGLContextAttributes {
  27542. /**
  27543. * Defines if the engine should no exceed a specified device ratio
  27544. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27545. */
  27546. limitDeviceRatio?: number;
  27547. /**
  27548. * Defines if webvr should be enabled automatically
  27549. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27550. */
  27551. autoEnableWebVR?: boolean;
  27552. /**
  27553. * Defines if webgl2 should be turned off even if supported
  27554. * @see http://doc.babylonjs.com/features/webgl2
  27555. */
  27556. disableWebGL2Support?: boolean;
  27557. /**
  27558. * Defines if webaudio should be initialized as well
  27559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27560. */
  27561. audioEngine?: boolean;
  27562. /**
  27563. * Defines if animations should run using a deterministic lock step
  27564. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27565. */
  27566. deterministicLockstep?: boolean;
  27567. /** Defines the maximum steps to use with deterministic lock step mode */
  27568. lockstepMaxSteps?: number;
  27569. /**
  27570. * Defines that engine should ignore context lost events
  27571. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27572. */
  27573. doNotHandleContextLost?: boolean;
  27574. /**
  27575. * Defines that engine should ignore modifying touch action attribute and style
  27576. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27577. */
  27578. doNotHandleTouchAction?: boolean;
  27579. /**
  27580. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27581. */
  27582. useHighPrecisionFloats?: boolean;
  27583. }
  27584. /**
  27585. * Defines the interface used by display changed events
  27586. */
  27587. export interface IDisplayChangedEventArgs {
  27588. /** Gets the vrDisplay object (if any) */
  27589. vrDisplay: Nullable<any>;
  27590. /** Gets a boolean indicating if webVR is supported */
  27591. vrSupported: boolean;
  27592. }
  27593. /**
  27594. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27595. */
  27596. export class Engine {
  27597. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27598. static ExceptionList: ({
  27599. key: string;
  27600. capture: string;
  27601. captureConstraint: number;
  27602. targets: string[];
  27603. } | {
  27604. key: string;
  27605. capture: null;
  27606. captureConstraint: null;
  27607. targets: string[];
  27608. })[];
  27609. /** Gets the list of created engines */
  27610. static readonly Instances: Engine[];
  27611. /**
  27612. * Gets the latest created engine
  27613. */
  27614. static readonly LastCreatedEngine: Nullable<Engine>;
  27615. /**
  27616. * Gets the latest created scene
  27617. */
  27618. static readonly LastCreatedScene: Nullable<Scene>;
  27619. /**
  27620. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27621. * @param flag defines which part of the materials must be marked as dirty
  27622. * @param predicate defines a predicate used to filter which materials should be affected
  27623. */
  27624. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27625. /**
  27626. * Hidden
  27627. */
  27628. static _TextureLoaders: IInternalTextureLoader[];
  27629. /** Defines that alpha blending is disabled */
  27630. static readonly ALPHA_DISABLE: number;
  27631. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27632. static readonly ALPHA_ADD: number;
  27633. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27634. static readonly ALPHA_COMBINE: number;
  27635. /** Defines that alpha blending to DEST - SRC * DEST */
  27636. static readonly ALPHA_SUBTRACT: number;
  27637. /** Defines that alpha blending to SRC * DEST */
  27638. static readonly ALPHA_MULTIPLY: number;
  27639. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27640. static readonly ALPHA_MAXIMIZED: number;
  27641. /** Defines that alpha blending to SRC + DEST */
  27642. static readonly ALPHA_ONEONE: number;
  27643. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27644. static readonly ALPHA_PREMULTIPLIED: number;
  27645. /**
  27646. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27647. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27648. */
  27649. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27650. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27651. static readonly ALPHA_INTERPOLATE: number;
  27652. /**
  27653. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27654. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27655. */
  27656. static readonly ALPHA_SCREENMODE: number;
  27657. /** Defines that the ressource is not delayed*/
  27658. static readonly DELAYLOADSTATE_NONE: number;
  27659. /** Defines that the ressource was successfully delay loaded */
  27660. static readonly DELAYLOADSTATE_LOADED: number;
  27661. /** Defines that the ressource is currently delay loading */
  27662. static readonly DELAYLOADSTATE_LOADING: number;
  27663. /** Defines that the ressource is delayed and has not started loading */
  27664. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27666. static readonly NEVER: number;
  27667. /** 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 */
  27668. static readonly ALWAYS: number;
  27669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27670. static readonly LESS: number;
  27671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27672. static readonly EQUAL: number;
  27673. /** 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 */
  27674. static readonly LEQUAL: number;
  27675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27676. static readonly GREATER: number;
  27677. /** 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 */
  27678. static readonly GEQUAL: number;
  27679. /** 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 */
  27680. static readonly NOTEQUAL: number;
  27681. /** Passed to stencilOperation to specify that stencil value must be kept */
  27682. static readonly KEEP: number;
  27683. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27684. static readonly REPLACE: number;
  27685. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27686. static readonly INCR: number;
  27687. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27688. static readonly DECR: number;
  27689. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27690. static readonly INVERT: number;
  27691. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27692. static readonly INCR_WRAP: number;
  27693. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27694. static readonly DECR_WRAP: number;
  27695. /** Texture is not repeating outside of 0..1 UVs */
  27696. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27697. /** Texture is repeating outside of 0..1 UVs */
  27698. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27699. /** Texture is repeating and mirrored */
  27700. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27701. /** ALPHA */
  27702. static readonly TEXTUREFORMAT_ALPHA: number;
  27703. /** LUMINANCE */
  27704. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27705. /** LUMINANCE_ALPHA */
  27706. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27707. /** RGB */
  27708. static readonly TEXTUREFORMAT_RGB: number;
  27709. /** RGBA */
  27710. static readonly TEXTUREFORMAT_RGBA: number;
  27711. /** RED */
  27712. static readonly TEXTUREFORMAT_RED: number;
  27713. /** RED (2nd reference) */
  27714. static readonly TEXTUREFORMAT_R: number;
  27715. /** RG */
  27716. static readonly TEXTUREFORMAT_RG: number;
  27717. /** RED_INTEGER */
  27718. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27719. /** RED_INTEGER (2nd reference) */
  27720. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27721. /** RG_INTEGER */
  27722. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27723. /** RGB_INTEGER */
  27724. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27725. /** RGBA_INTEGER */
  27726. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27727. /** UNSIGNED_BYTE */
  27728. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27729. /** UNSIGNED_BYTE (2nd reference) */
  27730. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27731. /** FLOAT */
  27732. static readonly TEXTURETYPE_FLOAT: number;
  27733. /** HALF_FLOAT */
  27734. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27735. /** BYTE */
  27736. static readonly TEXTURETYPE_BYTE: number;
  27737. /** SHORT */
  27738. static readonly TEXTURETYPE_SHORT: number;
  27739. /** UNSIGNED_SHORT */
  27740. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27741. /** INT */
  27742. static readonly TEXTURETYPE_INT: number;
  27743. /** UNSIGNED_INT */
  27744. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27745. /** UNSIGNED_SHORT_4_4_4_4 */
  27746. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27747. /** UNSIGNED_SHORT_5_5_5_1 */
  27748. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27749. /** UNSIGNED_SHORT_5_6_5 */
  27750. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27751. /** UNSIGNED_INT_2_10_10_10_REV */
  27752. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27753. /** UNSIGNED_INT_24_8 */
  27754. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27755. /** UNSIGNED_INT_10F_11F_11F_REV */
  27756. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27757. /** UNSIGNED_INT_5_9_9_9_REV */
  27758. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27759. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27760. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27761. /** nearest is mag = nearest and min = nearest and mip = linear */
  27762. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27763. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27764. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27765. /** Trilinear is mag = linear and min = linear and mip = linear */
  27766. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27767. /** nearest is mag = nearest and min = nearest and mip = linear */
  27768. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27769. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27770. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27771. /** Trilinear is mag = linear and min = linear and mip = linear */
  27772. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27773. /** mag = nearest and min = nearest and mip = nearest */
  27774. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27775. /** mag = nearest and min = linear and mip = nearest */
  27776. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27777. /** mag = nearest and min = linear and mip = linear */
  27778. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27779. /** mag = nearest and min = linear and mip = none */
  27780. static readonly TEXTURE_NEAREST_LINEAR: number;
  27781. /** mag = nearest and min = nearest and mip = none */
  27782. static readonly TEXTURE_NEAREST_NEAREST: number;
  27783. /** mag = linear and min = nearest and mip = nearest */
  27784. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27785. /** mag = linear and min = nearest and mip = linear */
  27786. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27787. /** mag = linear and min = linear and mip = none */
  27788. static readonly TEXTURE_LINEAR_LINEAR: number;
  27789. /** mag = linear and min = nearest and mip = none */
  27790. static readonly TEXTURE_LINEAR_NEAREST: number;
  27791. /** Explicit coordinates mode */
  27792. static readonly TEXTURE_EXPLICIT_MODE: number;
  27793. /** Spherical coordinates mode */
  27794. static readonly TEXTURE_SPHERICAL_MODE: number;
  27795. /** Planar coordinates mode */
  27796. static readonly TEXTURE_PLANAR_MODE: number;
  27797. /** Cubic coordinates mode */
  27798. static readonly TEXTURE_CUBIC_MODE: number;
  27799. /** Projection coordinates mode */
  27800. static readonly TEXTURE_PROJECTION_MODE: number;
  27801. /** Skybox coordinates mode */
  27802. static readonly TEXTURE_SKYBOX_MODE: number;
  27803. /** Inverse Cubic coordinates mode */
  27804. static readonly TEXTURE_INVCUBIC_MODE: number;
  27805. /** Equirectangular coordinates mode */
  27806. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27807. /** Equirectangular Fixed coordinates mode */
  27808. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27809. /** Equirectangular Fixed Mirrored coordinates mode */
  27810. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27811. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27812. static readonly SCALEMODE_FLOOR: number;
  27813. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27814. static readonly SCALEMODE_NEAREST: number;
  27815. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27816. static readonly SCALEMODE_CEILING: number;
  27817. /**
  27818. * Returns the current npm package of the sdk
  27819. */
  27820. static readonly NpmPackage: string;
  27821. /**
  27822. * Returns the current version of the framework
  27823. */
  27824. static readonly Version: string;
  27825. /**
  27826. * Returns a string describing the current engine
  27827. */
  27828. readonly description: string;
  27829. /**
  27830. * Gets or sets the epsilon value used by collision engine
  27831. */
  27832. static CollisionsEpsilon: number;
  27833. /**
  27834. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27835. */
  27836. static ShadersRepository: string;
  27837. /**
  27838. * Method called to create the default loading screen.
  27839. * This can be overriden in your own app.
  27840. * @param canvas The rendering canvas element
  27841. * @returns The loading screen
  27842. */
  27843. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27844. /**
  27845. * Method called to create the default rescale post process on each engine.
  27846. */
  27847. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27848. /**
  27849. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27850. */
  27851. forcePOTTextures: boolean;
  27852. /**
  27853. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27854. */
  27855. isFullscreen: boolean;
  27856. /**
  27857. * Gets a boolean indicating if the pointer is currently locked
  27858. */
  27859. isPointerLock: boolean;
  27860. /**
  27861. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27862. */
  27863. cullBackFaces: boolean;
  27864. /**
  27865. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27866. */
  27867. renderEvenInBackground: boolean;
  27868. /**
  27869. * Gets or sets a boolean indicating that cache can be kept between frames
  27870. */
  27871. preventCacheWipeBetweenFrames: boolean;
  27872. /**
  27873. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27874. **/
  27875. enableOfflineSupport: boolean;
  27876. /**
  27877. * 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)
  27878. **/
  27879. disableManifestCheck: boolean;
  27880. /**
  27881. * Gets the list of created scenes
  27882. */
  27883. scenes: Scene[];
  27884. /**
  27885. * Event raised when a new scene is created
  27886. */
  27887. onNewSceneAddedObservable: Observable<Scene>;
  27888. /**
  27889. * Gets the list of created postprocesses
  27890. */
  27891. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27892. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27893. validateShaderPrograms: boolean;
  27894. /**
  27895. * Observable event triggered each time the rendering canvas is resized
  27896. */
  27897. onResizeObservable: Observable<Engine>;
  27898. /**
  27899. * Observable event triggered each time the canvas loses focus
  27900. */
  27901. onCanvasBlurObservable: Observable<Engine>;
  27902. /**
  27903. * Observable event triggered each time the canvas gains focus
  27904. */
  27905. onCanvasFocusObservable: Observable<Engine>;
  27906. /**
  27907. * Observable event triggered each time the canvas receives pointerout event
  27908. */
  27909. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27910. /**
  27911. * Observable event triggered before each texture is initialized
  27912. */
  27913. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27914. private _vrDisplay;
  27915. private _vrSupported;
  27916. private _oldSize;
  27917. private _oldHardwareScaleFactor;
  27918. private _vrExclusivePointerMode;
  27919. private _webVRInitPromise;
  27920. /**
  27921. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27922. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27923. */
  27924. readonly isInVRExclusivePointerMode: boolean;
  27925. /**
  27926. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27927. */
  27928. disableUniformBuffers: boolean;
  27929. /** @hidden */
  27930. _uniformBuffers: UniformBuffer[];
  27931. /**
  27932. * Gets a boolean indicating that the engine supports uniform buffers
  27933. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27934. */
  27935. readonly supportsUniformBuffers: boolean;
  27936. /**
  27937. * Observable raised when the engine begins a new frame
  27938. */
  27939. onBeginFrameObservable: Observable<Engine>;
  27940. /**
  27941. * If set, will be used to request the next animation frame for the render loop
  27942. */
  27943. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27944. /**
  27945. * Observable raised when the engine ends the current frame
  27946. */
  27947. onEndFrameObservable: Observable<Engine>;
  27948. /**
  27949. * Observable raised when the engine is about to compile a shader
  27950. */
  27951. onBeforeShaderCompilationObservable: Observable<Engine>;
  27952. /**
  27953. * Observable raised when the engine has jsut compiled a shader
  27954. */
  27955. onAfterShaderCompilationObservable: Observable<Engine>;
  27956. /** @hidden */
  27957. _gl: WebGLRenderingContext;
  27958. private _renderingCanvas;
  27959. private _windowIsBackground;
  27960. private _webGLVersion;
  27961. protected _highPrecisionShadersAllowed: boolean;
  27962. /** @hidden */
  27963. readonly _shouldUseHighPrecisionShader: boolean;
  27964. /**
  27965. * Gets a boolean indicating that only power of 2 textures are supported
  27966. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27967. */
  27968. readonly needPOTTextures: boolean;
  27969. /** @hidden */
  27970. _badOS: boolean;
  27971. /** @hidden */
  27972. _badDesktopOS: boolean;
  27973. /**
  27974. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27975. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27976. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27977. */
  27978. disableTextureBindingOptimization: boolean;
  27979. /**
  27980. * Gets the audio engine
  27981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27982. * @ignorenaming
  27983. */
  27984. static audioEngine: IAudioEngine;
  27985. /**
  27986. * Default AudioEngine factory responsible of creating the Audio Engine.
  27987. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27988. */
  27989. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27990. /**
  27991. * Default offline support factory responsible of creating a tool used to store data locally.
  27992. * By default, this will create a Database object if the workload has been embedded.
  27993. */
  27994. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27995. private _onFocus;
  27996. private _onBlur;
  27997. private _onCanvasPointerOut;
  27998. private _onCanvasBlur;
  27999. private _onCanvasFocus;
  28000. private _onFullscreenChange;
  28001. private _onPointerLockChange;
  28002. private _onVRDisplayPointerRestricted;
  28003. private _onVRDisplayPointerUnrestricted;
  28004. private _onVrDisplayConnect;
  28005. private _onVrDisplayDisconnect;
  28006. private _onVrDisplayPresentChange;
  28007. /**
  28008. * Observable signaled when VR display mode changes
  28009. */
  28010. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28011. /**
  28012. * Observable signaled when VR request present is complete
  28013. */
  28014. onVRRequestPresentComplete: Observable<boolean>;
  28015. /**
  28016. * Observable signaled when VR request present starts
  28017. */
  28018. onVRRequestPresentStart: Observable<Engine>;
  28019. private _hardwareScalingLevel;
  28020. /** @hidden */
  28021. protected _caps: EngineCapabilities;
  28022. private _pointerLockRequested;
  28023. private _isStencilEnable;
  28024. private _colorWrite;
  28025. private _loadingScreen;
  28026. /** @hidden */
  28027. _drawCalls: PerfCounter;
  28028. /** @hidden */
  28029. _textureCollisions: PerfCounter;
  28030. private _glVersion;
  28031. private _glRenderer;
  28032. private _glVendor;
  28033. private _videoTextureSupported;
  28034. private _renderingQueueLaunched;
  28035. private _activeRenderLoops;
  28036. private _deterministicLockstep;
  28037. private _lockstepMaxSteps;
  28038. /**
  28039. * Observable signaled when a context lost event is raised
  28040. */
  28041. onContextLostObservable: Observable<Engine>;
  28042. /**
  28043. * Observable signaled when a context restored event is raised
  28044. */
  28045. onContextRestoredObservable: Observable<Engine>;
  28046. private _onContextLost;
  28047. private _onContextRestored;
  28048. private _contextWasLost;
  28049. private _doNotHandleContextLost;
  28050. /**
  28051. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28053. */
  28054. doNotHandleContextLost: boolean;
  28055. private _performanceMonitor;
  28056. private _fps;
  28057. private _deltaTime;
  28058. /**
  28059. * Turn this value on if you want to pause FPS computation when in background
  28060. */
  28061. disablePerformanceMonitorInBackground: boolean;
  28062. /**
  28063. * Gets the performance monitor attached to this engine
  28064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28065. */
  28066. readonly performanceMonitor: PerformanceMonitor;
  28067. /**
  28068. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28069. */
  28070. disableVertexArrayObjects: boolean;
  28071. /** @hidden */
  28072. protected _depthCullingState: _DepthCullingState;
  28073. /** @hidden */
  28074. protected _stencilState: _StencilState;
  28075. /** @hidden */
  28076. protected _alphaState: _AlphaState;
  28077. /** @hidden */
  28078. protected _alphaMode: number;
  28079. protected _internalTexturesCache: InternalTexture[];
  28080. /** @hidden */
  28081. protected _activeChannel: number;
  28082. private _currentTextureChannel;
  28083. /** @hidden */
  28084. protected _boundTexturesCache: {
  28085. [key: string]: Nullable<InternalTexture>;
  28086. };
  28087. /** @hidden */
  28088. protected _currentEffect: Nullable<Effect>;
  28089. /** @hidden */
  28090. protected _currentProgram: Nullable<WebGLProgram>;
  28091. private _compiledEffects;
  28092. private _vertexAttribArraysEnabled;
  28093. /** @hidden */
  28094. protected _cachedViewport: Nullable<Viewport>;
  28095. private _cachedVertexArrayObject;
  28096. /** @hidden */
  28097. protected _cachedVertexBuffers: any;
  28098. /** @hidden */
  28099. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28100. /** @hidden */
  28101. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28102. /** @hidden */
  28103. protected _currentRenderTarget: Nullable<InternalTexture>;
  28104. private _uintIndicesCurrentlySet;
  28105. private _currentBoundBuffer;
  28106. /** @hidden */
  28107. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28108. private _currentBufferPointers;
  28109. private _currentInstanceLocations;
  28110. private _currentInstanceBuffers;
  28111. private _textureUnits;
  28112. private _firstBoundInternalTextureTracker;
  28113. private _lastBoundInternalTextureTracker;
  28114. private _workingCanvas;
  28115. private _workingContext;
  28116. private _rescalePostProcess;
  28117. private _dummyFramebuffer;
  28118. private _externalData;
  28119. private _bindedRenderFunction;
  28120. private _vaoRecordInProgress;
  28121. private _mustWipeVertexAttributes;
  28122. private _emptyTexture;
  28123. private _emptyCubeTexture;
  28124. private _emptyTexture3D;
  28125. /** @hidden */
  28126. _frameHandler: number;
  28127. private _nextFreeTextureSlots;
  28128. private _maxSimultaneousTextures;
  28129. private _activeRequests;
  28130. private _texturesSupported;
  28131. private _textureFormatInUse;
  28132. /**
  28133. * Gets the list of texture formats supported
  28134. */
  28135. readonly texturesSupported: Array<string>;
  28136. /**
  28137. * Gets the list of texture formats in use
  28138. */
  28139. readonly textureFormatInUse: Nullable<string>;
  28140. /**
  28141. * Gets the current viewport
  28142. */
  28143. readonly currentViewport: Nullable<Viewport>;
  28144. /**
  28145. * Gets the default empty texture
  28146. */
  28147. readonly emptyTexture: InternalTexture;
  28148. /**
  28149. * Gets the default empty 3D texture
  28150. */
  28151. readonly emptyTexture3D: InternalTexture;
  28152. /**
  28153. * Gets the default empty cube texture
  28154. */
  28155. readonly emptyCubeTexture: InternalTexture;
  28156. /**
  28157. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28158. */
  28159. readonly premultipliedAlpha: boolean;
  28160. /**
  28161. * Creates a new engine
  28162. * @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
  28163. * @param antialias defines enable antialiasing (default: false)
  28164. * @param options defines further options to be sent to the getContext() function
  28165. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28166. */
  28167. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28168. private _disableTouchAction;
  28169. private _rebuildInternalTextures;
  28170. private _rebuildEffects;
  28171. /**
  28172. * Gets a boolean indicating if all created effects are ready
  28173. * @returns true if all effects are ready
  28174. */
  28175. areAllEffectsReady(): boolean;
  28176. private _rebuildBuffers;
  28177. private _initGLContext;
  28178. /**
  28179. * Gets version of the current webGL context
  28180. */
  28181. readonly webGLVersion: number;
  28182. /**
  28183. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28184. */
  28185. readonly isStencilEnable: boolean;
  28186. private _prepareWorkingCanvas;
  28187. /**
  28188. * Reset the texture cache to empty state
  28189. */
  28190. resetTextureCache(): void;
  28191. /**
  28192. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28194. * @returns true if engine is in deterministic lock step mode
  28195. */
  28196. isDeterministicLockStep(): boolean;
  28197. /**
  28198. * Gets the max steps when engine is running in deterministic lock step
  28199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28200. * @returns the max steps
  28201. */
  28202. getLockstepMaxSteps(): number;
  28203. /**
  28204. * Gets an object containing information about the current webGL context
  28205. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28206. */
  28207. getGlInfo(): {
  28208. vendor: string;
  28209. renderer: string;
  28210. version: string;
  28211. };
  28212. /**
  28213. * Gets current aspect ratio
  28214. * @param camera defines the camera to use to get the aspect ratio
  28215. * @param useScreen defines if screen size must be used (or the current render target if any)
  28216. * @returns a number defining the aspect ratio
  28217. */
  28218. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28219. /**
  28220. * Gets current screen aspect ratio
  28221. * @returns a number defining the aspect ratio
  28222. */
  28223. getScreenAspectRatio(): number;
  28224. /**
  28225. * Gets the current render width
  28226. * @param useScreen defines if screen size must be used (or the current render target if any)
  28227. * @returns a number defining the current render width
  28228. */
  28229. getRenderWidth(useScreen?: boolean): number;
  28230. /**
  28231. * Gets the current render height
  28232. * @param useScreen defines if screen size must be used (or the current render target if any)
  28233. * @returns a number defining the current render height
  28234. */
  28235. getRenderHeight(useScreen?: boolean): number;
  28236. /**
  28237. * Gets the HTML canvas attached with the current webGL context
  28238. * @returns a HTML canvas
  28239. */
  28240. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28241. /**
  28242. * Gets the client rect of the HTML canvas attached with the current webGL context
  28243. * @returns a client rectanglee
  28244. */
  28245. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28246. /**
  28247. * Defines the hardware scaling level.
  28248. * By default the hardware scaling level is computed from the window device ratio.
  28249. * 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.
  28250. * @param level defines the level to use
  28251. */
  28252. setHardwareScalingLevel(level: number): void;
  28253. /**
  28254. * Gets the current hardware scaling level.
  28255. * By default the hardware scaling level is computed from the window device ratio.
  28256. * 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.
  28257. * @returns a number indicating the current hardware scaling level
  28258. */
  28259. getHardwareScalingLevel(): number;
  28260. /**
  28261. * Gets the list of loaded textures
  28262. * @returns an array containing all loaded textures
  28263. */
  28264. getLoadedTexturesCache(): InternalTexture[];
  28265. /**
  28266. * Gets the object containing all engine capabilities
  28267. * @returns the EngineCapabilities object
  28268. */
  28269. getCaps(): EngineCapabilities;
  28270. /**
  28271. * Gets the current depth function
  28272. * @returns a number defining the depth function
  28273. */
  28274. getDepthFunction(): Nullable<number>;
  28275. /**
  28276. * Sets the current depth function
  28277. * @param depthFunc defines the function to use
  28278. */
  28279. setDepthFunction(depthFunc: number): void;
  28280. /**
  28281. * Sets the current depth function to GREATER
  28282. */
  28283. setDepthFunctionToGreater(): void;
  28284. /**
  28285. * Sets the current depth function to GEQUAL
  28286. */
  28287. setDepthFunctionToGreaterOrEqual(): void;
  28288. /**
  28289. * Sets the current depth function to LESS
  28290. */
  28291. setDepthFunctionToLess(): void;
  28292. private _cachedStencilBuffer;
  28293. private _cachedStencilFunction;
  28294. private _cachedStencilMask;
  28295. private _cachedStencilOperationPass;
  28296. private _cachedStencilOperationFail;
  28297. private _cachedStencilOperationDepthFail;
  28298. private _cachedStencilReference;
  28299. /**
  28300. * Caches the the state of the stencil buffer
  28301. */
  28302. cacheStencilState(): void;
  28303. /**
  28304. * Restores the state of the stencil buffer
  28305. */
  28306. restoreStencilState(): void;
  28307. /**
  28308. * Sets the current depth function to LEQUAL
  28309. */
  28310. setDepthFunctionToLessOrEqual(): void;
  28311. /**
  28312. * Gets a boolean indicating if stencil buffer is enabled
  28313. * @returns the current stencil buffer state
  28314. */
  28315. getStencilBuffer(): boolean;
  28316. /**
  28317. * Enable or disable the stencil buffer
  28318. * @param enable defines if the stencil buffer must be enabled or disabled
  28319. */
  28320. setStencilBuffer(enable: boolean): void;
  28321. /**
  28322. * Gets the current stencil mask
  28323. * @returns a number defining the new stencil mask to use
  28324. */
  28325. getStencilMask(): number;
  28326. /**
  28327. * Sets the current stencil mask
  28328. * @param mask defines the new stencil mask to use
  28329. */
  28330. setStencilMask(mask: number): void;
  28331. /**
  28332. * Gets the current stencil function
  28333. * @returns a number defining the stencil function to use
  28334. */
  28335. getStencilFunction(): number;
  28336. /**
  28337. * Gets the current stencil reference value
  28338. * @returns a number defining the stencil reference value to use
  28339. */
  28340. getStencilFunctionReference(): number;
  28341. /**
  28342. * Gets the current stencil mask
  28343. * @returns a number defining the stencil mask to use
  28344. */
  28345. getStencilFunctionMask(): number;
  28346. /**
  28347. * Sets the current stencil function
  28348. * @param stencilFunc defines the new stencil function to use
  28349. */
  28350. setStencilFunction(stencilFunc: number): void;
  28351. /**
  28352. * Sets the current stencil reference
  28353. * @param reference defines the new stencil reference to use
  28354. */
  28355. setStencilFunctionReference(reference: number): void;
  28356. /**
  28357. * Sets the current stencil mask
  28358. * @param mask defines the new stencil mask to use
  28359. */
  28360. setStencilFunctionMask(mask: number): void;
  28361. /**
  28362. * Gets the current stencil operation when stencil fails
  28363. * @returns a number defining stencil operation to use when stencil fails
  28364. */
  28365. getStencilOperationFail(): number;
  28366. /**
  28367. * Gets the current stencil operation when depth fails
  28368. * @returns a number defining stencil operation to use when depth fails
  28369. */
  28370. getStencilOperationDepthFail(): number;
  28371. /**
  28372. * Gets the current stencil operation when stencil passes
  28373. * @returns a number defining stencil operation to use when stencil passes
  28374. */
  28375. getStencilOperationPass(): number;
  28376. /**
  28377. * Sets the stencil operation to use when stencil fails
  28378. * @param operation defines the stencil operation to use when stencil fails
  28379. */
  28380. setStencilOperationFail(operation: number): void;
  28381. /**
  28382. * Sets the stencil operation to use when depth fails
  28383. * @param operation defines the stencil operation to use when depth fails
  28384. */
  28385. setStencilOperationDepthFail(operation: number): void;
  28386. /**
  28387. * Sets the stencil operation to use when stencil passes
  28388. * @param operation defines the stencil operation to use when stencil passes
  28389. */
  28390. setStencilOperationPass(operation: number): void;
  28391. /**
  28392. * Sets a boolean indicating if the dithering state is enabled or disabled
  28393. * @param value defines the dithering state
  28394. */
  28395. setDitheringState(value: boolean): void;
  28396. /**
  28397. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28398. * @param value defines the rasterizer state
  28399. */
  28400. setRasterizerState(value: boolean): void;
  28401. /**
  28402. * stop executing a render loop function and remove it from the execution array
  28403. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28404. */
  28405. stopRenderLoop(renderFunction?: () => void): void;
  28406. /** @hidden */
  28407. _renderLoop(): void;
  28408. /**
  28409. * Register and execute a render loop. The engine can have more than one render function
  28410. * @param renderFunction defines the function to continuously execute
  28411. */
  28412. runRenderLoop(renderFunction: () => void): void;
  28413. /**
  28414. * Toggle full screen mode
  28415. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28416. */
  28417. switchFullscreen(requestPointerLock: boolean): void;
  28418. /**
  28419. * Enters full screen mode
  28420. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28421. */
  28422. enterFullscreen(requestPointerLock: boolean): void;
  28423. /**
  28424. * Exits full screen mode
  28425. */
  28426. exitFullscreen(): void;
  28427. /**
  28428. * Clear the current render buffer or the current render target (if any is set up)
  28429. * @param color defines the color to use
  28430. * @param backBuffer defines if the back buffer must be cleared
  28431. * @param depth defines if the depth buffer must be cleared
  28432. * @param stencil defines if the stencil buffer must be cleared
  28433. */
  28434. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28435. /**
  28436. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28437. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28438. * @param y defines the y-coordinate of the corner of the clear rectangle
  28439. * @param width defines the width of the clear rectangle
  28440. * @param height defines the height of the clear rectangle
  28441. * @param clearColor defines the clear color
  28442. */
  28443. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28444. /**
  28445. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28446. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28447. * @param y defines the y-coordinate of the corner of the clear rectangle
  28448. * @param width defines the width of the clear rectangle
  28449. * @param height defines the height of the clear rectangle
  28450. */
  28451. enableScissor(x: number, y: number, width: number, height: number): void;
  28452. /**
  28453. * Disable previously set scissor test rectangle
  28454. */
  28455. disableScissor(): void;
  28456. private _viewportCached;
  28457. /** @hidden */
  28458. _viewport(x: number, y: number, width: number, height: number): void;
  28459. /**
  28460. * Set the WebGL's viewport
  28461. * @param viewport defines the viewport element to be used
  28462. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28463. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28464. */
  28465. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28466. /**
  28467. * Directly set the WebGL Viewport
  28468. * @param x defines the x coordinate of the viewport (in screen space)
  28469. * @param y defines the y coordinate of the viewport (in screen space)
  28470. * @param width defines the width of the viewport (in screen space)
  28471. * @param height defines the height of the viewport (in screen space)
  28472. * @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
  28473. */
  28474. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28475. /**
  28476. * Begin a new frame
  28477. */
  28478. beginFrame(): void;
  28479. /**
  28480. * Enf the current frame
  28481. */
  28482. endFrame(): void;
  28483. /**
  28484. * Resize the view according to the canvas' size
  28485. */
  28486. resize(): void;
  28487. /**
  28488. * Force a specific size of the canvas
  28489. * @param width defines the new canvas' width
  28490. * @param height defines the new canvas' height
  28491. */
  28492. setSize(width: number, height: number): void;
  28493. /**
  28494. * Gets a boolean indicating if a webVR device was detected
  28495. * @returns true if a webVR device was detected
  28496. */
  28497. isVRDevicePresent(): boolean;
  28498. /**
  28499. * Gets the current webVR device
  28500. * @returns the current webVR device (or null)
  28501. */
  28502. getVRDevice(): any;
  28503. /**
  28504. * Initializes a webVR display and starts listening to display change events
  28505. * The onVRDisplayChangedObservable will be notified upon these changes
  28506. * @returns The onVRDisplayChangedObservable
  28507. */
  28508. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28509. /**
  28510. * Initializes a webVR display and starts listening to display change events
  28511. * The onVRDisplayChangedObservable will be notified upon these changes
  28512. * @returns A promise containing a VRDisplay and if vr is supported
  28513. */
  28514. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28515. /**
  28516. * Call this function to switch to webVR mode
  28517. * Will do nothing if webVR is not supported or if there is no webVR device
  28518. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28519. */
  28520. enableVR(): void;
  28521. /**
  28522. * Call this function to leave webVR mode
  28523. * Will do nothing if webVR is not supported or if there is no webVR device
  28524. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28525. */
  28526. disableVR(): void;
  28527. private _onVRFullScreenTriggered;
  28528. private _getVRDisplaysAsync;
  28529. /**
  28530. * Binds the frame buffer to the specified texture.
  28531. * @param texture The texture to render to or null for the default canvas
  28532. * @param faceIndex The face of the texture to render to in case of cube texture
  28533. * @param requiredWidth The width of the target to render to
  28534. * @param requiredHeight The height of the target to render to
  28535. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28536. * @param depthStencilTexture The depth stencil texture to use to render
  28537. * @param lodLevel defines le lod level to bind to the frame buffer
  28538. */
  28539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28540. private bindUnboundFramebuffer;
  28541. /**
  28542. * Unbind the current render target texture from the webGL context
  28543. * @param texture defines the render target texture to unbind
  28544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28546. */
  28547. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28548. /**
  28549. * Unbind a list of render target textures from the webGL context
  28550. * This is used only when drawBuffer extension or webGL2 are active
  28551. * @param textures defines the render target textures to unbind
  28552. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28553. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28554. */
  28555. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28556. /**
  28557. * Force the mipmap generation for the given render target texture
  28558. * @param texture defines the render target texture to use
  28559. */
  28560. generateMipMapsForCubemap(texture: InternalTexture): void;
  28561. /**
  28562. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28563. */
  28564. flushFramebuffer(): void;
  28565. /**
  28566. * Unbind the current render target and bind the default framebuffer
  28567. */
  28568. restoreDefaultFramebuffer(): void;
  28569. /**
  28570. * Create an uniform buffer
  28571. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28572. * @param elements defines the content of the uniform buffer
  28573. * @returns the webGL uniform buffer
  28574. */
  28575. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28576. /**
  28577. * Create a dynamic uniform buffer
  28578. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28579. * @param elements defines the content of the uniform buffer
  28580. * @returns the webGL uniform buffer
  28581. */
  28582. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28583. /**
  28584. * Update an existing uniform buffer
  28585. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28586. * @param uniformBuffer defines the target uniform buffer
  28587. * @param elements defines the content to update
  28588. * @param offset defines the offset in the uniform buffer where update should start
  28589. * @param count defines the size of the data to update
  28590. */
  28591. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28592. private _resetVertexBufferBinding;
  28593. /**
  28594. * Creates a vertex buffer
  28595. * @param data the data for the vertex buffer
  28596. * @returns the new WebGL static buffer
  28597. */
  28598. createVertexBuffer(data: DataArray): WebGLBuffer;
  28599. /**
  28600. * Creates a dynamic vertex buffer
  28601. * @param data the data for the dynamic vertex buffer
  28602. * @returns the new WebGL dynamic buffer
  28603. */
  28604. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28605. /**
  28606. * Update a dynamic index buffer
  28607. * @param indexBuffer defines the target index buffer
  28608. * @param indices defines the data to update
  28609. * @param offset defines the offset in the target index buffer where update should start
  28610. */
  28611. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28612. /**
  28613. * Updates a dynamic vertex buffer.
  28614. * @param vertexBuffer the vertex buffer to update
  28615. * @param data the data used to update the vertex buffer
  28616. * @param byteOffset the byte offset of the data
  28617. * @param byteLength the byte length of the data
  28618. */
  28619. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28620. private _resetIndexBufferBinding;
  28621. /**
  28622. * Creates a new index buffer
  28623. * @param indices defines the content of the index buffer
  28624. * @param updatable defines if the index buffer must be updatable
  28625. * @returns a new webGL buffer
  28626. */
  28627. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28628. /**
  28629. * Bind a webGL buffer to the webGL context
  28630. * @param buffer defines the buffer to bind
  28631. */
  28632. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28633. /**
  28634. * Bind an uniform buffer to the current webGL context
  28635. * @param buffer defines the buffer to bind
  28636. */
  28637. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28638. /**
  28639. * Bind a buffer to the current webGL context at a given location
  28640. * @param buffer defines the buffer to bind
  28641. * @param location defines the index where to bind the buffer
  28642. */
  28643. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28644. /**
  28645. * Bind a specific block at a given index in a specific shader program
  28646. * @param shaderProgram defines the shader program
  28647. * @param blockName defines the block name
  28648. * @param index defines the index where to bind the block
  28649. */
  28650. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28651. private bindIndexBuffer;
  28652. private bindBuffer;
  28653. /**
  28654. * update the bound buffer with the given data
  28655. * @param data defines the data to update
  28656. */
  28657. updateArrayBuffer(data: Float32Array): void;
  28658. private _vertexAttribPointer;
  28659. private _bindIndexBufferWithCache;
  28660. private _bindVertexBuffersAttributes;
  28661. /**
  28662. * Records a vertex array object
  28663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28664. * @param vertexBuffers defines the list of vertex buffers to store
  28665. * @param indexBuffer defines the index buffer to store
  28666. * @param effect defines the effect to store
  28667. * @returns the new vertex array object
  28668. */
  28669. recordVertexArrayObject(vertexBuffers: {
  28670. [key: string]: VertexBuffer;
  28671. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28672. /**
  28673. * Bind a specific vertex array object
  28674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28675. * @param vertexArrayObject defines the vertex array object to bind
  28676. * @param indexBuffer defines the index buffer to bind
  28677. */
  28678. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28679. /**
  28680. * Bind webGl buffers directly to the webGL context
  28681. * @param vertexBuffer defines the vertex buffer to bind
  28682. * @param indexBuffer defines the index buffer to bind
  28683. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28684. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28685. * @param effect defines the effect associated with the vertex buffer
  28686. */
  28687. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28688. private _unbindVertexArrayObject;
  28689. /**
  28690. * Bind a list of vertex buffers to the webGL context
  28691. * @param vertexBuffers defines the list of vertex buffers to bind
  28692. * @param indexBuffer defines the index buffer to bind
  28693. * @param effect defines the effect associated with the vertex buffers
  28694. */
  28695. bindBuffers(vertexBuffers: {
  28696. [key: string]: Nullable<VertexBuffer>;
  28697. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28698. /**
  28699. * Unbind all instance attributes
  28700. */
  28701. unbindInstanceAttributes(): void;
  28702. /**
  28703. * Release and free the memory of a vertex array object
  28704. * @param vao defines the vertex array object to delete
  28705. */
  28706. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28707. /** @hidden */
  28708. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28709. /**
  28710. * Creates a webGL buffer to use with instanciation
  28711. * @param capacity defines the size of the buffer
  28712. * @returns the webGL buffer
  28713. */
  28714. createInstancesBuffer(capacity: number): WebGLBuffer;
  28715. /**
  28716. * Delete a webGL buffer used with instanciation
  28717. * @param buffer defines the webGL buffer to delete
  28718. */
  28719. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28720. /**
  28721. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28722. * @param instancesBuffer defines the webGL buffer to update and bind
  28723. * @param data defines the data to store in the buffer
  28724. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28725. */
  28726. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28727. /**
  28728. * Apply all cached states (depth, culling, stencil and alpha)
  28729. */
  28730. applyStates(): void;
  28731. /**
  28732. * Send a draw order
  28733. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28734. * @param indexStart defines the starting index
  28735. * @param indexCount defines the number of index to draw
  28736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28737. */
  28738. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28739. /**
  28740. * Draw a list of points
  28741. * @param verticesStart defines the index of first vertex to draw
  28742. * @param verticesCount defines the count of vertices to draw
  28743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28744. */
  28745. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28746. /**
  28747. * Draw a list of unindexed primitives
  28748. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28749. * @param verticesStart defines the index of first vertex to draw
  28750. * @param verticesCount defines the count of vertices to draw
  28751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28752. */
  28753. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28754. /**
  28755. * Draw a list of indexed primitives
  28756. * @param fillMode defines the primitive to use
  28757. * @param indexStart defines the starting index
  28758. * @param indexCount defines the number of index to draw
  28759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28760. */
  28761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28762. /**
  28763. * Draw a list of unindexed primitives
  28764. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28770. private _drawMode;
  28771. /** @hidden */
  28772. _releaseEffect(effect: Effect): void;
  28773. /** @hidden */
  28774. _deleteProgram(program: WebGLProgram): void;
  28775. /**
  28776. * Create a new effect (used to store vertex/fragment shaders)
  28777. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28778. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28779. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28780. * @param samplers defines an array of string used to represent textures
  28781. * @param defines defines the string containing the defines to use to compile the shaders
  28782. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28783. * @param onCompiled defines a function to call when the effect creation is successful
  28784. * @param onError defines a function to call when the effect creation has failed
  28785. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28786. * @returns the new Effect
  28787. */
  28788. 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;
  28789. private _compileShader;
  28790. private _compileRawShader;
  28791. /**
  28792. * Directly creates a webGL program
  28793. * @param vertexCode defines the vertex shader code to use
  28794. * @param fragmentCode defines the fragment shader code to use
  28795. * @param context defines the webGL context to use (if not set, the current one will be used)
  28796. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28797. * @returns the new webGL program
  28798. */
  28799. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28800. /**
  28801. * Creates a webGL program
  28802. * @param vertexCode defines the vertex shader code to use
  28803. * @param fragmentCode defines the fragment shader code to use
  28804. * @param defines defines the string containing the defines to use to compile the shaders
  28805. * @param context defines the webGL context to use (if not set, the current one will be used)
  28806. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28807. * @returns the new webGL program
  28808. */
  28809. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28810. private _createShaderProgram;
  28811. private _finalizeProgram;
  28812. /** @hidden */
  28813. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28814. /** @hidden */
  28815. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28816. /**
  28817. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28818. * @param shaderProgram defines the webGL program to use
  28819. * @param uniformsNames defines the list of uniform names
  28820. * @returns an array of webGL uniform locations
  28821. */
  28822. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28823. /**
  28824. * Gets the lsit of active attributes for a given webGL program
  28825. * @param shaderProgram defines the webGL program to use
  28826. * @param attributesNames defines the list of attribute names to get
  28827. * @returns an array of indices indicating the offset of each attribute
  28828. */
  28829. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28830. /**
  28831. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28832. * @param effect defines the effect to activate
  28833. */
  28834. enableEffect(effect: Nullable<Effect>): void;
  28835. /**
  28836. * Set the value of an uniform to an array of int32
  28837. * @param uniform defines the webGL uniform location where to store the value
  28838. * @param array defines the array of int32 to store
  28839. */
  28840. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28841. /**
  28842. * Set the value of an uniform to an array of int32 (stored as vec2)
  28843. * @param uniform defines the webGL uniform location where to store the value
  28844. * @param array defines the array of int32 to store
  28845. */
  28846. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28847. /**
  28848. * Set the value of an uniform to an array of int32 (stored as vec3)
  28849. * @param uniform defines the webGL uniform location where to store the value
  28850. * @param array defines the array of int32 to store
  28851. */
  28852. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28853. /**
  28854. * Set the value of an uniform to an array of int32 (stored as vec4)
  28855. * @param uniform defines the webGL uniform location where to store the value
  28856. * @param array defines the array of int32 to store
  28857. */
  28858. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28859. /**
  28860. * Set the value of an uniform to an array of float32
  28861. * @param uniform defines the webGL uniform location where to store the value
  28862. * @param array defines the array of float32 to store
  28863. */
  28864. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28865. /**
  28866. * Set the value of an uniform to an array of float32 (stored as vec2)
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param array defines the array of float32 to store
  28869. */
  28870. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28871. /**
  28872. * Set the value of an uniform to an array of float32 (stored as vec3)
  28873. * @param uniform defines the webGL uniform location where to store the value
  28874. * @param array defines the array of float32 to store
  28875. */
  28876. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28877. /**
  28878. * Set the value of an uniform to an array of float32 (stored as vec4)
  28879. * @param uniform defines the webGL uniform location where to store the value
  28880. * @param array defines the array of float32 to store
  28881. */
  28882. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28883. /**
  28884. * Set the value of an uniform to an array of number
  28885. * @param uniform defines the webGL uniform location where to store the value
  28886. * @param array defines the array of number to store
  28887. */
  28888. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28889. /**
  28890. * Set the value of an uniform to an array of number (stored as vec2)
  28891. * @param uniform defines the webGL uniform location where to store the value
  28892. * @param array defines the array of number to store
  28893. */
  28894. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28895. /**
  28896. * Set the value of an uniform to an array of number (stored as vec3)
  28897. * @param uniform defines the webGL uniform location where to store the value
  28898. * @param array defines the array of number to store
  28899. */
  28900. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28901. /**
  28902. * Set the value of an uniform to an array of number (stored as vec4)
  28903. * @param uniform defines the webGL uniform location where to store the value
  28904. * @param array defines the array of number to store
  28905. */
  28906. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28907. /**
  28908. * Set the value of an uniform to an array of float32 (stored as matrices)
  28909. * @param uniform defines the webGL uniform location where to store the value
  28910. * @param matrices defines the array of float32 to store
  28911. */
  28912. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28913. /**
  28914. * Set the value of an uniform to a matrix
  28915. * @param uniform defines the webGL uniform location where to store the value
  28916. * @param matrix defines the matrix to store
  28917. */
  28918. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28919. /**
  28920. * Set the value of an uniform to a matrix (3x3)
  28921. * @param uniform defines the webGL uniform location where to store the value
  28922. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28923. */
  28924. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28925. /**
  28926. * Set the value of an uniform to a matrix (2x2)
  28927. * @param uniform defines the webGL uniform location where to store the value
  28928. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28929. */
  28930. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28931. /**
  28932. * Set the value of an uniform to a number (int)
  28933. * @param uniform defines the webGL uniform location where to store the value
  28934. * @param value defines the int number to store
  28935. */
  28936. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28937. /**
  28938. * Set the value of an uniform to a number (float)
  28939. * @param uniform defines the webGL uniform location where to store the value
  28940. * @param value defines the float number to store
  28941. */
  28942. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28943. /**
  28944. * Set the value of an uniform to a vec2
  28945. * @param uniform defines the webGL uniform location where to store the value
  28946. * @param x defines the 1st component of the value
  28947. * @param y defines the 2nd component of the value
  28948. */
  28949. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28950. /**
  28951. * Set the value of an uniform to a vec3
  28952. * @param uniform defines the webGL uniform location where to store the value
  28953. * @param x defines the 1st component of the value
  28954. * @param y defines the 2nd component of the value
  28955. * @param z defines the 3rd component of the value
  28956. */
  28957. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28958. /**
  28959. * Set the value of an uniform to a boolean
  28960. * @param uniform defines the webGL uniform location where to store the value
  28961. * @param bool defines the boolean to store
  28962. */
  28963. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28964. /**
  28965. * Set the value of an uniform to a vec4
  28966. * @param uniform defines the webGL uniform location where to store the value
  28967. * @param x defines the 1st component of the value
  28968. * @param y defines the 2nd component of the value
  28969. * @param z defines the 3rd component of the value
  28970. * @param w defines the 4th component of the value
  28971. */
  28972. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28973. /**
  28974. * Set the value of an uniform to a Color3
  28975. * @param uniform defines the webGL uniform location where to store the value
  28976. * @param color3 defines the color to store
  28977. */
  28978. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28979. /**
  28980. * Set the value of an uniform to a Color3 and an alpha value
  28981. * @param uniform defines the webGL uniform location where to store the value
  28982. * @param color3 defines the color to store
  28983. * @param alpha defines the alpha component to store
  28984. */
  28985. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28986. /**
  28987. * Sets a Color4 on a uniform variable
  28988. * @param uniform defines the uniform location
  28989. * @param color4 defines the value to be set
  28990. */
  28991. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28992. /**
  28993. * Set various states to the webGL context
  28994. * @param culling defines backface culling state
  28995. * @param zOffset defines the value to apply to zOffset (0 by default)
  28996. * @param force defines if states must be applied even if cache is up to date
  28997. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28998. */
  28999. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29000. /**
  29001. * Set the z offset to apply to current rendering
  29002. * @param value defines the offset to apply
  29003. */
  29004. setZOffset(value: number): void;
  29005. /**
  29006. * Gets the current value of the zOffset
  29007. * @returns the current zOffset state
  29008. */
  29009. getZOffset(): number;
  29010. /**
  29011. * Enable or disable depth buffering
  29012. * @param enable defines the state to set
  29013. */
  29014. setDepthBuffer(enable: boolean): void;
  29015. /**
  29016. * Gets a boolean indicating if depth writing is enabled
  29017. * @returns the current depth writing state
  29018. */
  29019. getDepthWrite(): boolean;
  29020. /**
  29021. * Enable or disable depth writing
  29022. * @param enable defines the state to set
  29023. */
  29024. setDepthWrite(enable: boolean): void;
  29025. /**
  29026. * Enable or disable color writing
  29027. * @param enable defines the state to set
  29028. */
  29029. setColorWrite(enable: boolean): void;
  29030. /**
  29031. * Gets a boolean indicating if color writing is enabled
  29032. * @returns the current color writing state
  29033. */
  29034. getColorWrite(): boolean;
  29035. /**
  29036. * Sets alpha constants used by some alpha blending modes
  29037. * @param r defines the red component
  29038. * @param g defines the green component
  29039. * @param b defines the blue component
  29040. * @param a defines the alpha component
  29041. */
  29042. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29043. /**
  29044. * Sets the current alpha mode
  29045. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29046. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29048. */
  29049. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29050. /**
  29051. * Gets the current alpha mode
  29052. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29053. * @returns the current alpha mode
  29054. */
  29055. getAlphaMode(): number;
  29056. /**
  29057. * Clears the list of texture accessible through engine.
  29058. * This can help preventing texture load conflict due to name collision.
  29059. */
  29060. clearInternalTexturesCache(): void;
  29061. /**
  29062. * Force the entire cache to be cleared
  29063. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29064. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29065. */
  29066. wipeCaches(bruteForce?: boolean): void;
  29067. /**
  29068. * Set the compressed texture format to use, based on the formats you have, and the formats
  29069. * supported by the hardware / browser.
  29070. *
  29071. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29072. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29073. * to API arguments needed to compressed textures. This puts the burden on the container
  29074. * generator to house the arcane code for determining these for current & future formats.
  29075. *
  29076. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29077. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29078. *
  29079. * Note: The result of this call is not taken into account when a texture is base64.
  29080. *
  29081. * @param formatsAvailable defines the list of those format families you have created
  29082. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29083. *
  29084. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29085. * @returns The extension selected.
  29086. */
  29087. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29088. private _getSamplingParameters;
  29089. private _partialLoadImg;
  29090. private _cascadeLoadImgs;
  29091. /** @hidden */
  29092. _createTexture(): WebGLTexture;
  29093. /**
  29094. * Usually called from Texture.ts.
  29095. * Passed information to create a WebGLTexture
  29096. * @param urlArg defines a value which contains one of the following:
  29097. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29098. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29099. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29100. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29101. * @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)
  29102. * @param scene needed for loading to the correct scene
  29103. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29104. * @param onLoad optional callback to be called upon successful completion
  29105. * @param onError optional callback to be called upon failure
  29106. * @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
  29107. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29108. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29109. * @param forcedExtension defines the extension to use to pick the right loader
  29110. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29111. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29112. */
  29113. 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;
  29114. private _rescaleTexture;
  29115. /**
  29116. * Update a raw texture
  29117. * @param texture defines the texture to update
  29118. * @param data defines the data to store in the texture
  29119. * @param format defines the format of the data
  29120. * @param invertY defines if data must be stored with Y axis inverted
  29121. * @param compression defines the compression used (null by default)
  29122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29123. */
  29124. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29125. /**
  29126. * Creates a raw texture
  29127. * @param data defines the data to store in the texture
  29128. * @param width defines the width of the texture
  29129. * @param height defines the height of the texture
  29130. * @param format defines the format of the data
  29131. * @param generateMipMaps defines if the engine should generate the mip levels
  29132. * @param invertY defines if data must be stored with Y axis inverted
  29133. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29134. * @param compression defines the compression used (null by default)
  29135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29136. * @returns the raw texture inside an InternalTexture
  29137. */
  29138. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29139. private _unpackFlipYCached;
  29140. /**
  29141. * In case you are sharing the context with other applications, it might
  29142. * be interested to not cache the unpack flip y state to ensure a consistent
  29143. * value would be set.
  29144. */
  29145. enableUnpackFlipYCached: boolean;
  29146. /** @hidden */
  29147. _unpackFlipY(value: boolean): void;
  29148. /** @hidden */
  29149. _getUnpackAlignement(): number;
  29150. /**
  29151. * Creates a dynamic texture
  29152. * @param width defines the width of the texture
  29153. * @param height defines the height of the texture
  29154. * @param generateMipMaps defines if the engine should generate the mip levels
  29155. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29156. * @returns the dynamic texture inside an InternalTexture
  29157. */
  29158. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29159. /**
  29160. * Update the sampling mode of a given texture
  29161. * @param samplingMode defines the required sampling mode
  29162. * @param texture defines the texture to update
  29163. */
  29164. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29165. /**
  29166. * Update the content of a dynamic texture
  29167. * @param texture defines the texture to update
  29168. * @param canvas defines the canvas containing the source
  29169. * @param invertY defines if data must be stored with Y axis inverted
  29170. * @param premulAlpha defines if alpha is stored as premultiplied
  29171. * @param format defines the format of the data
  29172. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29173. */
  29174. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29175. /**
  29176. * Update a video texture
  29177. * @param texture defines the texture to update
  29178. * @param video defines the video element to use
  29179. * @param invertY defines if data must be stored with Y axis inverted
  29180. */
  29181. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29182. /**
  29183. * Updates a depth texture Comparison Mode and Function.
  29184. * If the comparison Function is equal to 0, the mode will be set to none.
  29185. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29186. * @param texture The texture to set the comparison function for
  29187. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29188. */
  29189. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29190. private _setupDepthStencilTexture;
  29191. /**
  29192. * Creates a depth stencil texture.
  29193. * This is only available in WebGL 2 or with the depth texture extension available.
  29194. * @param size The size of face edge in the texture.
  29195. * @param options The options defining the texture.
  29196. * @returns The texture
  29197. */
  29198. createDepthStencilTexture(size: number | {
  29199. width: number;
  29200. height: number;
  29201. }, options: DepthTextureCreationOptions): InternalTexture;
  29202. /**
  29203. * Creates a depth stencil texture.
  29204. * This is only available in WebGL 2 or with the depth texture extension available.
  29205. * @param size The size of face edge in the texture.
  29206. * @param options The options defining the texture.
  29207. * @returns The texture
  29208. */
  29209. private _createDepthStencilTexture;
  29210. /**
  29211. * Creates a depth stencil cube texture.
  29212. * This is only available in WebGL 2.
  29213. * @param size The size of face edge in the cube texture.
  29214. * @param options The options defining the cube texture.
  29215. * @returns The cube texture
  29216. */
  29217. private _createDepthStencilCubeTexture;
  29218. /**
  29219. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29220. * @param renderTarget The render target to set the frame buffer for
  29221. */
  29222. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29223. /**
  29224. * Creates a new render target texture
  29225. * @param size defines the size of the texture
  29226. * @param options defines the options used to create the texture
  29227. * @returns a new render target texture stored in an InternalTexture
  29228. */
  29229. createRenderTargetTexture(size: number | {
  29230. width: number;
  29231. height: number;
  29232. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29233. /**
  29234. * Create a multi render target texture
  29235. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29236. * @param size defines the size of the texture
  29237. * @param options defines the creation options
  29238. * @returns the cube texture as an InternalTexture
  29239. */
  29240. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29241. private _setupFramebufferDepthAttachments;
  29242. /**
  29243. * Updates the sample count of a render target texture
  29244. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29245. * @param texture defines the texture to update
  29246. * @param samples defines the sample count to set
  29247. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29248. */
  29249. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29250. /**
  29251. * Update the sample count for a given multiple render target texture
  29252. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29253. * @param textures defines the textures to update
  29254. * @param samples defines the sample count to set
  29255. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29256. */
  29257. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29258. /** @hidden */
  29259. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29260. /** @hidden */
  29261. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29262. /** @hidden */
  29263. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29264. /** @hidden */
  29265. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29266. /**
  29267. * Creates a new render target cube texture
  29268. * @param size defines the size of the texture
  29269. * @param options defines the options used to create the texture
  29270. * @returns a new render target cube texture stored in an InternalTexture
  29271. */
  29272. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29273. /**
  29274. * Creates a cube texture
  29275. * @param rootUrl defines the url where the files to load is located
  29276. * @param scene defines the current scene
  29277. * @param files defines the list of files to load (1 per face)
  29278. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29279. * @param onLoad defines an optional callback raised when the texture is loaded
  29280. * @param onError defines an optional callback raised if there is an issue to load the texture
  29281. * @param format defines the format of the data
  29282. * @param forcedExtension defines the extension to use to pick the right loader
  29283. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29284. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29285. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29286. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29287. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29288. * @returns the cube texture as an InternalTexture
  29289. */
  29290. 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;
  29291. /**
  29292. * @hidden
  29293. */
  29294. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29295. /**
  29296. * Update a raw cube texture
  29297. * @param texture defines the texture to udpdate
  29298. * @param data defines the data to store
  29299. * @param format defines the data format
  29300. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29301. * @param invertY defines if data must be stored with Y axis inverted
  29302. * @param compression defines the compression used (null by default)
  29303. * @param level defines which level of the texture to update
  29304. */
  29305. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29306. /**
  29307. * Creates a new raw cube texture
  29308. * @param data defines the array of data to use to create each face
  29309. * @param size defines the size of the textures
  29310. * @param format defines the format of the data
  29311. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29312. * @param generateMipMaps defines if the engine should generate the mip levels
  29313. * @param invertY defines if data must be stored with Y axis inverted
  29314. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29315. * @param compression defines the compression used (null by default)
  29316. * @returns the cube texture as an InternalTexture
  29317. */
  29318. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29319. /**
  29320. * Creates a new raw cube texture from a specified url
  29321. * @param url defines the url where the data is located
  29322. * @param scene defines the current scene
  29323. * @param size defines the size of the textures
  29324. * @param format defines the format of the data
  29325. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29326. * @param noMipmap defines if the engine should avoid generating the mip levels
  29327. * @param callback defines a callback used to extract texture data from loaded data
  29328. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29329. * @param onLoad defines a callback called when texture is loaded
  29330. * @param onError defines a callback called if there is an error
  29331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29332. * @param invertY defines if data must be stored with Y axis inverted
  29333. * @returns the cube texture as an InternalTexture
  29334. */
  29335. 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;
  29336. /**
  29337. * Update a raw 3D texture
  29338. * @param texture defines the texture to update
  29339. * @param data defines the data to store
  29340. * @param format defines the data format
  29341. * @param invertY defines if data must be stored with Y axis inverted
  29342. * @param compression defines the used compression (can be null)
  29343. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29344. */
  29345. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29346. /**
  29347. * Creates a new raw 3D texture
  29348. * @param data defines the data used to create the texture
  29349. * @param width defines the width of the texture
  29350. * @param height defines the height of the texture
  29351. * @param depth defines the depth of the texture
  29352. * @param format defines the format of the texture
  29353. * @param generateMipMaps defines if the engine must generate mip levels
  29354. * @param invertY defines if data must be stored with Y axis inverted
  29355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29356. * @param compression defines the compressed used (can be null)
  29357. * @param textureType defines the compressed used (can be null)
  29358. * @returns a new raw 3D texture (stored in an InternalTexture)
  29359. */
  29360. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29361. private _prepareWebGLTextureContinuation;
  29362. private _prepareWebGLTexture;
  29363. private _convertRGBtoRGBATextureData;
  29364. /** @hidden */
  29365. _releaseFramebufferObjects(texture: InternalTexture): void;
  29366. /** @hidden */
  29367. _releaseTexture(texture: InternalTexture): void;
  29368. private setProgram;
  29369. private _boundUniforms;
  29370. /**
  29371. * Binds an effect to the webGL context
  29372. * @param effect defines the effect to bind
  29373. */
  29374. bindSamplers(effect: Effect): void;
  29375. private _moveBoundTextureOnTop;
  29376. private _getCorrectTextureChannel;
  29377. private _linkTrackers;
  29378. private _removeDesignatedSlot;
  29379. private _activateCurrentTexture;
  29380. /** @hidden */
  29381. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29382. /** @hidden */
  29383. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29384. /**
  29385. * Sets a texture to the webGL context from a postprocess
  29386. * @param channel defines the channel to use
  29387. * @param postProcess defines the source postprocess
  29388. */
  29389. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29390. /**
  29391. * Binds the output of the passed in post process to the texture channel specified
  29392. * @param channel The channel the texture should be bound to
  29393. * @param postProcess The post process which's output should be bound
  29394. */
  29395. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29396. /**
  29397. * Unbind all textures from the webGL context
  29398. */
  29399. unbindAllTextures(): void;
  29400. /**
  29401. * Sets a texture to the according uniform.
  29402. * @param channel The texture channel
  29403. * @param uniform The uniform to set
  29404. * @param texture The texture to apply
  29405. */
  29406. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29407. /**
  29408. * Sets a depth stencil texture from a render target to the according uniform.
  29409. * @param channel The texture channel
  29410. * @param uniform The uniform to set
  29411. * @param texture The render target texture containing the depth stencil texture to apply
  29412. */
  29413. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29414. private _bindSamplerUniformToChannel;
  29415. private _getTextureWrapMode;
  29416. private _setTexture;
  29417. /**
  29418. * Sets an array of texture to the webGL context
  29419. * @param channel defines the channel where the texture array must be set
  29420. * @param uniform defines the associated uniform location
  29421. * @param textures defines the array of textures to bind
  29422. */
  29423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29424. /** @hidden */
  29425. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29426. private _setTextureParameterFloat;
  29427. private _setTextureParameterInteger;
  29428. /**
  29429. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29430. * @param x defines the x coordinate of the rectangle where pixels must be read
  29431. * @param y defines the y coordinate of the rectangle where pixels must be read
  29432. * @param width defines the width of the rectangle where pixels must be read
  29433. * @param height defines the height of the rectangle where pixels must be read
  29434. * @returns a Uint8Array containing RGBA colors
  29435. */
  29436. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29437. /**
  29438. * Add an externaly attached data from its key.
  29439. * This method call will fail and return false, if such key already exists.
  29440. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29441. * @param key the unique key that identifies the data
  29442. * @param data the data object to associate to the key for this Engine instance
  29443. * @return true if no such key were already present and the data was added successfully, false otherwise
  29444. */
  29445. addExternalData<T>(key: string, data: T): boolean;
  29446. /**
  29447. * Get an externaly attached data from its key
  29448. * @param key the unique key that identifies the data
  29449. * @return the associated data, if present (can be null), or undefined if not present
  29450. */
  29451. getExternalData<T>(key: string): T;
  29452. /**
  29453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29454. * @param key the unique key that identifies the data
  29455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29456. * @return the associated data, can be null if the factory returned null.
  29457. */
  29458. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29459. /**
  29460. * Remove an externaly attached data from the Engine instance
  29461. * @param key the unique key that identifies the data
  29462. * @return true if the data was successfully removed, false if it doesn't exist
  29463. */
  29464. removeExternalData(key: string): boolean;
  29465. /**
  29466. * Unbind all vertex attributes from the webGL context
  29467. */
  29468. unbindAllAttributes(): void;
  29469. /**
  29470. * 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
  29471. */
  29472. releaseEffects(): void;
  29473. /**
  29474. * Dispose and release all associated resources
  29475. */
  29476. dispose(): void;
  29477. /**
  29478. * Display the loading screen
  29479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29480. */
  29481. displayLoadingUI(): void;
  29482. /**
  29483. * Hide the loading screen
  29484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29485. */
  29486. hideLoadingUI(): void;
  29487. /**
  29488. * Gets the current loading screen object
  29489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29490. */
  29491. /**
  29492. * Sets the current loading screen object
  29493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29494. */
  29495. loadingScreen: ILoadingScreen;
  29496. /**
  29497. * Sets the current loading screen text
  29498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29499. */
  29500. loadingUIText: string;
  29501. /**
  29502. * Sets the current loading screen background color
  29503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29504. */
  29505. loadingUIBackgroundColor: string;
  29506. /**
  29507. * Attach a new callback raised when context lost event is fired
  29508. * @param callback defines the callback to call
  29509. */
  29510. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29511. /**
  29512. * Attach a new callback raised when context restored event is fired
  29513. * @param callback defines the callback to call
  29514. */
  29515. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29516. /**
  29517. * Gets the source code of the vertex shader associated with a specific webGL program
  29518. * @param program defines the program to use
  29519. * @returns a string containing the source code of the vertex shader associated with the program
  29520. */
  29521. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29522. /**
  29523. * Gets the source code of the fragment shader associated with a specific webGL program
  29524. * @param program defines the program to use
  29525. * @returns a string containing the source code of the fragment shader associated with the program
  29526. */
  29527. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29528. /**
  29529. * Get the current error code of the webGL context
  29530. * @returns the error code
  29531. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29532. */
  29533. getError(): number;
  29534. /**
  29535. * Gets the current framerate
  29536. * @returns a number representing the framerate
  29537. */
  29538. getFps(): number;
  29539. /**
  29540. * Gets the time spent between current and previous frame
  29541. * @returns a number representing the delta time in ms
  29542. */
  29543. getDeltaTime(): number;
  29544. private _measureFps;
  29545. /** @hidden */
  29546. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29547. private _canRenderToFloatFramebuffer;
  29548. private _canRenderToHalfFloatFramebuffer;
  29549. private _canRenderToFramebuffer;
  29550. /** @hidden */
  29551. _getWebGLTextureType(type: number): number;
  29552. private _getInternalFormat;
  29553. /** @hidden */
  29554. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29555. /** @hidden */
  29556. _getRGBAMultiSampleBufferFormat(type: number): number;
  29557. /** @hidden */
  29558. _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;
  29559. /** @hidden */
  29560. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29561. private _partialLoadFile;
  29562. private _cascadeLoadFiles;
  29563. /**
  29564. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29565. * @returns true if the engine can be created
  29566. * @ignorenaming
  29567. */
  29568. static isSupported(): boolean;
  29569. }
  29570. }
  29571. declare module "babylonjs/Materials/effect" {
  29572. import { Observable } from "babylonjs/Misc/observable";
  29573. import { Nullable } from "babylonjs/types";
  29574. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29575. import { Engine } from "babylonjs/Engines/engine";
  29576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29579. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29581. /**
  29582. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29583. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29584. */
  29585. export class EffectFallbacks {
  29586. private _defines;
  29587. private _currentRank;
  29588. private _maxRank;
  29589. private _mesh;
  29590. /**
  29591. * Removes the fallback from the bound mesh.
  29592. */
  29593. unBindMesh(): void;
  29594. /**
  29595. * Adds a fallback on the specified property.
  29596. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29597. * @param define The name of the define in the shader
  29598. */
  29599. addFallback(rank: number, define: string): void;
  29600. /**
  29601. * Sets the mesh to use CPU skinning when needing to fallback.
  29602. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29603. * @param mesh The mesh to use the fallbacks.
  29604. */
  29605. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29606. /**
  29607. * Checks to see if more fallbacks are still availible.
  29608. */
  29609. readonly isMoreFallbacks: boolean;
  29610. /**
  29611. * Removes the defines that shoould be removed when falling back.
  29612. * @param currentDefines defines the current define statements for the shader.
  29613. * @param effect defines the current effect we try to compile
  29614. * @returns The resulting defines with defines of the current rank removed.
  29615. */
  29616. reduce(currentDefines: string, effect: Effect): string;
  29617. }
  29618. /**
  29619. * Options to be used when creating an effect.
  29620. */
  29621. export class EffectCreationOptions {
  29622. /**
  29623. * Atrributes that will be used in the shader.
  29624. */
  29625. attributes: string[];
  29626. /**
  29627. * Uniform varible names that will be set in the shader.
  29628. */
  29629. uniformsNames: string[];
  29630. /**
  29631. * Uniform buffer varible names that will be set in the shader.
  29632. */
  29633. uniformBuffersNames: string[];
  29634. /**
  29635. * Sampler texture variable names that will be set in the shader.
  29636. */
  29637. samplers: string[];
  29638. /**
  29639. * Define statements that will be set in the shader.
  29640. */
  29641. defines: any;
  29642. /**
  29643. * Possible fallbacks for this effect to improve performance when needed.
  29644. */
  29645. fallbacks: Nullable<EffectFallbacks>;
  29646. /**
  29647. * Callback that will be called when the shader is compiled.
  29648. */
  29649. onCompiled: Nullable<(effect: Effect) => void>;
  29650. /**
  29651. * Callback that will be called if an error occurs during shader compilation.
  29652. */
  29653. onError: Nullable<(effect: Effect, errors: string) => void>;
  29654. /**
  29655. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29656. */
  29657. indexParameters: any;
  29658. /**
  29659. * Max number of lights that can be used in the shader.
  29660. */
  29661. maxSimultaneousLights: number;
  29662. /**
  29663. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29664. */
  29665. transformFeedbackVaryings: Nullable<string[]>;
  29666. }
  29667. /**
  29668. * Effect containing vertex and fragment shader that can be executed on an object.
  29669. */
  29670. export class Effect {
  29671. /**
  29672. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29673. */
  29674. static ShadersRepository: string;
  29675. /**
  29676. * Name of the effect.
  29677. */
  29678. name: any;
  29679. /**
  29680. * String container all the define statements that should be set on the shader.
  29681. */
  29682. defines: string;
  29683. /**
  29684. * Callback that will be called when the shader is compiled.
  29685. */
  29686. onCompiled: Nullable<(effect: Effect) => void>;
  29687. /**
  29688. * Callback that will be called if an error occurs during shader compilation.
  29689. */
  29690. onError: Nullable<(effect: Effect, errors: string) => void>;
  29691. /**
  29692. * Callback that will be called when effect is bound.
  29693. */
  29694. onBind: Nullable<(effect: Effect) => void>;
  29695. /**
  29696. * Unique ID of the effect.
  29697. */
  29698. uniqueId: number;
  29699. /**
  29700. * Observable that will be called when the shader is compiled.
  29701. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29702. */
  29703. onCompileObservable: Observable<Effect>;
  29704. /**
  29705. * Observable that will be called if an error occurs during shader compilation.
  29706. */
  29707. onErrorObservable: Observable<Effect>;
  29708. /** @hidden */
  29709. _onBindObservable: Nullable<Observable<Effect>>;
  29710. /**
  29711. * Observable that will be called when effect is bound.
  29712. */
  29713. readonly onBindObservable: Observable<Effect>;
  29714. /** @hidden */
  29715. _bonesComputationForcedToCPU: boolean;
  29716. private static _uniqueIdSeed;
  29717. private _engine;
  29718. private _uniformBuffersNames;
  29719. private _uniformsNames;
  29720. private _samplers;
  29721. private _isReady;
  29722. private _compilationError;
  29723. private _attributesNames;
  29724. private _attributes;
  29725. private _uniforms;
  29726. /**
  29727. * Key for the effect.
  29728. * @hidden
  29729. */
  29730. _key: string;
  29731. private _indexParameters;
  29732. private _fallbacks;
  29733. private _vertexSourceCode;
  29734. private _fragmentSourceCode;
  29735. private _vertexSourceCodeOverride;
  29736. private _fragmentSourceCodeOverride;
  29737. private _transformFeedbackVaryings;
  29738. /**
  29739. * Compiled shader to webGL program.
  29740. * @hidden
  29741. */
  29742. _program: WebGLProgram;
  29743. private _valueCache;
  29744. private static _baseCache;
  29745. /**
  29746. * Instantiates an effect.
  29747. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29748. * @param baseName Name of the effect.
  29749. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29750. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29751. * @param samplers List of sampler variables that will be passed to the shader.
  29752. * @param engine Engine to be used to render the effect
  29753. * @param defines Define statements to be added to the shader.
  29754. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29755. * @param onCompiled Callback that will be called when the shader is compiled.
  29756. * @param onError Callback that will be called if an error occurs during shader compilation.
  29757. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29758. */
  29759. 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);
  29760. /**
  29761. * Unique key for this effect
  29762. */
  29763. readonly key: string;
  29764. /**
  29765. * If the effect has been compiled and prepared.
  29766. * @returns if the effect is compiled and prepared.
  29767. */
  29768. isReady(): boolean;
  29769. /**
  29770. * The engine the effect was initialized with.
  29771. * @returns the engine.
  29772. */
  29773. getEngine(): Engine;
  29774. /**
  29775. * The compiled webGL program for the effect
  29776. * @returns the webGL program.
  29777. */
  29778. getProgram(): WebGLProgram;
  29779. /**
  29780. * The set of names of attribute variables for the shader.
  29781. * @returns An array of attribute names.
  29782. */
  29783. getAttributesNames(): string[];
  29784. /**
  29785. * Returns the attribute at the given index.
  29786. * @param index The index of the attribute.
  29787. * @returns The location of the attribute.
  29788. */
  29789. getAttributeLocation(index: number): number;
  29790. /**
  29791. * Returns the attribute based on the name of the variable.
  29792. * @param name of the attribute to look up.
  29793. * @returns the attribute location.
  29794. */
  29795. getAttributeLocationByName(name: string): number;
  29796. /**
  29797. * The number of attributes.
  29798. * @returns the numnber of attributes.
  29799. */
  29800. getAttributesCount(): number;
  29801. /**
  29802. * Gets the index of a uniform variable.
  29803. * @param uniformName of the uniform to look up.
  29804. * @returns the index.
  29805. */
  29806. getUniformIndex(uniformName: string): number;
  29807. /**
  29808. * Returns the attribute based on the name of the variable.
  29809. * @param uniformName of the uniform to look up.
  29810. * @returns the location of the uniform.
  29811. */
  29812. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29813. /**
  29814. * Returns an array of sampler variable names
  29815. * @returns The array of sampler variable neames.
  29816. */
  29817. getSamplers(): string[];
  29818. /**
  29819. * The error from the last compilation.
  29820. * @returns the error string.
  29821. */
  29822. getCompilationError(): string;
  29823. /**
  29824. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29825. * @param func The callback to be used.
  29826. */
  29827. executeWhenCompiled(func: (effect: Effect) => void): void;
  29828. private _checkIsReady;
  29829. /** @hidden */
  29830. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29831. /** @hidden */
  29832. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29833. /** @hidden */
  29834. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29835. private _processShaderConversion;
  29836. private _processIncludes;
  29837. private _processPrecision;
  29838. /**
  29839. * Recompiles the webGL program
  29840. * @param vertexSourceCode The source code for the vertex shader.
  29841. * @param fragmentSourceCode The source code for the fragment shader.
  29842. * @param onCompiled Callback called when completed.
  29843. * @param onError Callback called on error.
  29844. * @hidden
  29845. */
  29846. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29847. /**
  29848. * Gets the uniform locations of the the specified variable names
  29849. * @param names THe names of the variables to lookup.
  29850. * @returns Array of locations in the same order as variable names.
  29851. */
  29852. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29853. /**
  29854. * Prepares the effect
  29855. * @hidden
  29856. */
  29857. _prepareEffect(): void;
  29858. /**
  29859. * Checks if the effect is supported. (Must be called after compilation)
  29860. */
  29861. readonly isSupported: boolean;
  29862. /**
  29863. * Binds a texture to the engine to be used as output of the shader.
  29864. * @param channel Name of the output variable.
  29865. * @param texture Texture to bind.
  29866. * @hidden
  29867. */
  29868. _bindTexture(channel: string, texture: InternalTexture): void;
  29869. /**
  29870. * Sets a texture on the engine to be used in the shader.
  29871. * @param channel Name of the sampler variable.
  29872. * @param texture Texture to set.
  29873. */
  29874. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29875. /**
  29876. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29877. * @param channel Name of the sampler variable.
  29878. * @param texture Texture to set.
  29879. */
  29880. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29881. /**
  29882. * Sets an array of textures on the engine to be used in the shader.
  29883. * @param channel Name of the variable.
  29884. * @param textures Textures to set.
  29885. */
  29886. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29887. /**
  29888. * 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)
  29889. * @param channel Name of the sampler variable.
  29890. * @param postProcess Post process to get the input texture from.
  29891. */
  29892. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29893. /**
  29894. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29895. * 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)
  29896. * @param channel Name of the sampler variable.
  29897. * @param postProcess Post process to get the output texture from.
  29898. */
  29899. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29900. /** @hidden */
  29901. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29902. /** @hidden */
  29903. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29904. /** @hidden */
  29905. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29906. /** @hidden */
  29907. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29908. /**
  29909. * Binds a buffer to a uniform.
  29910. * @param buffer Buffer to bind.
  29911. * @param name Name of the uniform variable to bind to.
  29912. */
  29913. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29914. /**
  29915. * Binds block to a uniform.
  29916. * @param blockName Name of the block to bind.
  29917. * @param index Index to bind.
  29918. */
  29919. bindUniformBlock(blockName: string, index: number): void;
  29920. /**
  29921. * Sets an interger value on a uniform variable.
  29922. * @param uniformName Name of the variable.
  29923. * @param value Value to be set.
  29924. * @returns this effect.
  29925. */
  29926. setInt(uniformName: string, value: number): Effect;
  29927. /**
  29928. * Sets an int array on a uniform variable.
  29929. * @param uniformName Name of the variable.
  29930. * @param array array to be set.
  29931. * @returns this effect.
  29932. */
  29933. setIntArray(uniformName: string, array: Int32Array): Effect;
  29934. /**
  29935. * 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)
  29936. * @param uniformName Name of the variable.
  29937. * @param array array to be set.
  29938. * @returns this effect.
  29939. */
  29940. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29941. /**
  29942. * 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)
  29943. * @param uniformName Name of the variable.
  29944. * @param array array to be set.
  29945. * @returns this effect.
  29946. */
  29947. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29948. /**
  29949. * 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)
  29950. * @param uniformName Name of the variable.
  29951. * @param array array to be set.
  29952. * @returns this effect.
  29953. */
  29954. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29955. /**
  29956. * Sets an float array on a uniform variable.
  29957. * @param uniformName Name of the variable.
  29958. * @param array array to be set.
  29959. * @returns this effect.
  29960. */
  29961. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29962. /**
  29963. * 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)
  29964. * @param uniformName Name of the variable.
  29965. * @param array array to be set.
  29966. * @returns this effect.
  29967. */
  29968. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29969. /**
  29970. * 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)
  29971. * @param uniformName Name of the variable.
  29972. * @param array array to be set.
  29973. * @returns this effect.
  29974. */
  29975. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29976. /**
  29977. * 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)
  29978. * @param uniformName Name of the variable.
  29979. * @param array array to be set.
  29980. * @returns this effect.
  29981. */
  29982. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29983. /**
  29984. * Sets an array on a uniform variable.
  29985. * @param uniformName Name of the variable.
  29986. * @param array array to be set.
  29987. * @returns this effect.
  29988. */
  29989. setArray(uniformName: string, array: number[]): Effect;
  29990. /**
  29991. * 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)
  29992. * @param uniformName Name of the variable.
  29993. * @param array array to be set.
  29994. * @returns this effect.
  29995. */
  29996. setArray2(uniformName: string, array: number[]): Effect;
  29997. /**
  29998. * 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)
  29999. * @param uniformName Name of the variable.
  30000. * @param array array to be set.
  30001. * @returns this effect.
  30002. */
  30003. setArray3(uniformName: string, array: number[]): Effect;
  30004. /**
  30005. * 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)
  30006. * @param uniformName Name of the variable.
  30007. * @param array array to be set.
  30008. * @returns this effect.
  30009. */
  30010. setArray4(uniformName: string, array: number[]): Effect;
  30011. /**
  30012. * Sets matrices on a uniform variable.
  30013. * @param uniformName Name of the variable.
  30014. * @param matrices matrices to be set.
  30015. * @returns this effect.
  30016. */
  30017. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30018. /**
  30019. * Sets matrix on a uniform variable.
  30020. * @param uniformName Name of the variable.
  30021. * @param matrix matrix to be set.
  30022. * @returns this effect.
  30023. */
  30024. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30025. /**
  30026. * 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)
  30027. * @param uniformName Name of the variable.
  30028. * @param matrix matrix to be set.
  30029. * @returns this effect.
  30030. */
  30031. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30032. /**
  30033. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30034. * @param uniformName Name of the variable.
  30035. * @param matrix matrix to be set.
  30036. * @returns this effect.
  30037. */
  30038. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30039. /**
  30040. * Sets a float on a uniform variable.
  30041. * @param uniformName Name of the variable.
  30042. * @param value value to be set.
  30043. * @returns this effect.
  30044. */
  30045. setFloat(uniformName: string, value: number): Effect;
  30046. /**
  30047. * Sets a boolean on a uniform variable.
  30048. * @param uniformName Name of the variable.
  30049. * @param bool value to be set.
  30050. * @returns this effect.
  30051. */
  30052. setBool(uniformName: string, bool: boolean): Effect;
  30053. /**
  30054. * Sets a Vector2 on a uniform variable.
  30055. * @param uniformName Name of the variable.
  30056. * @param vector2 vector2 to be set.
  30057. * @returns this effect.
  30058. */
  30059. setVector2(uniformName: string, vector2: Vector2): Effect;
  30060. /**
  30061. * Sets a float2 on a uniform variable.
  30062. * @param uniformName Name of the variable.
  30063. * @param x First float in float2.
  30064. * @param y Second float in float2.
  30065. * @returns this effect.
  30066. */
  30067. setFloat2(uniformName: string, x: number, y: number): Effect;
  30068. /**
  30069. * Sets a Vector3 on a uniform variable.
  30070. * @param uniformName Name of the variable.
  30071. * @param vector3 Value to be set.
  30072. * @returns this effect.
  30073. */
  30074. setVector3(uniformName: string, vector3: Vector3): Effect;
  30075. /**
  30076. * Sets a float3 on a uniform variable.
  30077. * @param uniformName Name of the variable.
  30078. * @param x First float in float3.
  30079. * @param y Second float in float3.
  30080. * @param z Third float in float3.
  30081. * @returns this effect.
  30082. */
  30083. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30084. /**
  30085. * Sets a Vector4 on a uniform variable.
  30086. * @param uniformName Name of the variable.
  30087. * @param vector4 Value to be set.
  30088. * @returns this effect.
  30089. */
  30090. setVector4(uniformName: string, vector4: Vector4): Effect;
  30091. /**
  30092. * Sets a float4 on a uniform variable.
  30093. * @param uniformName Name of the variable.
  30094. * @param x First float in float4.
  30095. * @param y Second float in float4.
  30096. * @param z Third float in float4.
  30097. * @param w Fourth float in float4.
  30098. * @returns this effect.
  30099. */
  30100. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30101. /**
  30102. * Sets a Color3 on a uniform variable.
  30103. * @param uniformName Name of the variable.
  30104. * @param color3 Value to be set.
  30105. * @returns this effect.
  30106. */
  30107. setColor3(uniformName: string, color3: Color3): Effect;
  30108. /**
  30109. * Sets a Color4 on a uniform variable.
  30110. * @param uniformName Name of the variable.
  30111. * @param color3 Value to be set.
  30112. * @param alpha Alpha value to be set.
  30113. * @returns this effect.
  30114. */
  30115. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30116. /**
  30117. * Sets a Color4 on a uniform variable
  30118. * @param uniformName defines the name of the variable
  30119. * @param color4 defines the value to be set
  30120. * @returns this effect.
  30121. */
  30122. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30123. /**
  30124. * This function will add a new shader to the shader store
  30125. * @param name the name of the shader
  30126. * @param pixelShader optional pixel shader content
  30127. * @param vertexShader optional vertex shader content
  30128. */
  30129. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30130. /**
  30131. * Store of each shader (The can be looked up using effect.key)
  30132. */
  30133. static ShadersStore: {
  30134. [key: string]: string;
  30135. };
  30136. /**
  30137. * Store of each included file for a shader (The can be looked up using effect.key)
  30138. */
  30139. static IncludesShadersStore: {
  30140. [key: string]: string;
  30141. };
  30142. /**
  30143. * Resets the cache of effects.
  30144. */
  30145. static ResetCache(): void;
  30146. }
  30147. }
  30148. declare module "babylonjs/Materials/colorCurves" {
  30149. import { Effect } from "babylonjs/Materials/effect";
  30150. /**
  30151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30153. * 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;
  30154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30155. */
  30156. export class ColorCurves {
  30157. private _dirty;
  30158. private _tempColor;
  30159. private _globalCurve;
  30160. private _highlightsCurve;
  30161. private _midtonesCurve;
  30162. private _shadowsCurve;
  30163. private _positiveCurve;
  30164. private _negativeCurve;
  30165. private _globalHue;
  30166. private _globalDensity;
  30167. private _globalSaturation;
  30168. private _globalExposure;
  30169. /**
  30170. * Gets the global Hue value.
  30171. * 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).
  30172. */
  30173. /**
  30174. * Sets the global Hue value.
  30175. * 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).
  30176. */
  30177. globalHue: number;
  30178. /**
  30179. * Gets the global Density value.
  30180. * 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.
  30181. * Values less than zero provide a filter of opposite hue.
  30182. */
  30183. /**
  30184. * Sets the global Density value.
  30185. * 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.
  30186. * Values less than zero provide a filter of opposite hue.
  30187. */
  30188. globalDensity: number;
  30189. /**
  30190. * Gets the global Saturation value.
  30191. * 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.
  30192. */
  30193. /**
  30194. * Sets the global Saturation value.
  30195. * 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.
  30196. */
  30197. globalSaturation: number;
  30198. /**
  30199. * Gets the global Exposure value.
  30200. * 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.
  30201. */
  30202. /**
  30203. * Sets the global Exposure value.
  30204. * 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.
  30205. */
  30206. globalExposure: number;
  30207. private _highlightsHue;
  30208. private _highlightsDensity;
  30209. private _highlightsSaturation;
  30210. private _highlightsExposure;
  30211. /**
  30212. * Gets the highlights Hue value.
  30213. * 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).
  30214. */
  30215. /**
  30216. * Sets the highlights Hue value.
  30217. * 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).
  30218. */
  30219. highlightsHue: number;
  30220. /**
  30221. * Gets the highlights Density value.
  30222. * 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.
  30223. * Values less than zero provide a filter of opposite hue.
  30224. */
  30225. /**
  30226. * Sets the highlights Density value.
  30227. * 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.
  30228. * Values less than zero provide a filter of opposite hue.
  30229. */
  30230. highlightsDensity: number;
  30231. /**
  30232. * Gets the highlights Saturation value.
  30233. * 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.
  30234. */
  30235. /**
  30236. * Sets the highlights Saturation value.
  30237. * 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.
  30238. */
  30239. highlightsSaturation: number;
  30240. /**
  30241. * Gets the highlights Exposure value.
  30242. * 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.
  30243. */
  30244. /**
  30245. * Sets the highlights Exposure value.
  30246. * 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.
  30247. */
  30248. highlightsExposure: number;
  30249. private _midtonesHue;
  30250. private _midtonesDensity;
  30251. private _midtonesSaturation;
  30252. private _midtonesExposure;
  30253. /**
  30254. * Gets the midtones Hue value.
  30255. * 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).
  30256. */
  30257. /**
  30258. * Sets the midtones Hue value.
  30259. * 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).
  30260. */
  30261. midtonesHue: number;
  30262. /**
  30263. * Gets the midtones Density value.
  30264. * 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.
  30265. * Values less than zero provide a filter of opposite hue.
  30266. */
  30267. /**
  30268. * Sets the midtones Density value.
  30269. * 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.
  30270. * Values less than zero provide a filter of opposite hue.
  30271. */
  30272. midtonesDensity: number;
  30273. /**
  30274. * Gets the midtones Saturation value.
  30275. * 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.
  30276. */
  30277. /**
  30278. * Sets the midtones Saturation value.
  30279. * 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.
  30280. */
  30281. midtonesSaturation: number;
  30282. /**
  30283. * Gets the midtones Exposure value.
  30284. * 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.
  30285. */
  30286. /**
  30287. * Sets the midtones Exposure value.
  30288. * 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.
  30289. */
  30290. midtonesExposure: number;
  30291. private _shadowsHue;
  30292. private _shadowsDensity;
  30293. private _shadowsSaturation;
  30294. private _shadowsExposure;
  30295. /**
  30296. * Gets the shadows Hue value.
  30297. * 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).
  30298. */
  30299. /**
  30300. * Sets the shadows Hue value.
  30301. * 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).
  30302. */
  30303. shadowsHue: number;
  30304. /**
  30305. * Gets the shadows Density value.
  30306. * 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.
  30307. * Values less than zero provide a filter of opposite hue.
  30308. */
  30309. /**
  30310. * Sets the shadows Density value.
  30311. * 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.
  30312. * Values less than zero provide a filter of opposite hue.
  30313. */
  30314. shadowsDensity: number;
  30315. /**
  30316. * Gets the shadows Saturation value.
  30317. * 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.
  30318. */
  30319. /**
  30320. * Sets the shadows Saturation value.
  30321. * 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.
  30322. */
  30323. shadowsSaturation: number;
  30324. /**
  30325. * Gets the shadows Exposure value.
  30326. * 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.
  30327. */
  30328. /**
  30329. * Sets the shadows Exposure value.
  30330. * 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.
  30331. */
  30332. shadowsExposure: number;
  30333. /**
  30334. * Returns the class name
  30335. * @returns The class name
  30336. */
  30337. getClassName(): string;
  30338. /**
  30339. * Binds the color curves to the shader.
  30340. * @param colorCurves The color curve to bind
  30341. * @param effect The effect to bind to
  30342. * @param positiveUniform The positive uniform shader parameter
  30343. * @param neutralUniform The neutral uniform shader parameter
  30344. * @param negativeUniform The negative uniform shader parameter
  30345. */
  30346. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30347. /**
  30348. * Prepare the list of uniforms associated with the ColorCurves effects.
  30349. * @param uniformsList The list of uniforms used in the effect
  30350. */
  30351. static PrepareUniforms(uniformsList: string[]): void;
  30352. /**
  30353. * Returns color grading data based on a hue, density, saturation and exposure value.
  30354. * @param filterHue The hue of the color filter.
  30355. * @param filterDensity The density of the color filter.
  30356. * @param saturation The saturation.
  30357. * @param exposure The exposure.
  30358. * @param result The result data container.
  30359. */
  30360. private getColorGradingDataToRef;
  30361. /**
  30362. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30363. * @param value The input slider value in range [-100,100].
  30364. * @returns Adjusted value.
  30365. */
  30366. private static applyColorGradingSliderNonlinear;
  30367. /**
  30368. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30369. * @param hue The hue (H) input.
  30370. * @param saturation The saturation (S) input.
  30371. * @param brightness The brightness (B) input.
  30372. * @result An RGBA color represented as Vector4.
  30373. */
  30374. private static fromHSBToRef;
  30375. /**
  30376. * Returns a value clamped between min and max
  30377. * @param value The value to clamp
  30378. * @param min The minimum of value
  30379. * @param max The maximum of value
  30380. * @returns The clamped value.
  30381. */
  30382. private static clamp;
  30383. /**
  30384. * Clones the current color curve instance.
  30385. * @return The cloned curves
  30386. */
  30387. clone(): ColorCurves;
  30388. /**
  30389. * Serializes the current color curve instance to a json representation.
  30390. * @return a JSON representation
  30391. */
  30392. serialize(): any;
  30393. /**
  30394. * Parses the color curve from a json representation.
  30395. * @param source the JSON source to parse
  30396. * @return The parsed curves
  30397. */
  30398. static Parse(source: any): ColorCurves;
  30399. }
  30400. }
  30401. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30402. import { Observable } from "babylonjs/Misc/observable";
  30403. import { Nullable } from "babylonjs/types";
  30404. import { Color4 } from "babylonjs/Maths/math";
  30405. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30406. import { Effect } from "babylonjs/Materials/effect";
  30407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30408. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30409. /**
  30410. * Interface to follow in your material defines to integrate easily the
  30411. * Image proccessing functions.
  30412. * @hidden
  30413. */
  30414. export interface IImageProcessingConfigurationDefines {
  30415. IMAGEPROCESSING: boolean;
  30416. VIGNETTE: boolean;
  30417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30418. VIGNETTEBLENDMODEOPAQUE: boolean;
  30419. TONEMAPPING: boolean;
  30420. TONEMAPPING_ACES: boolean;
  30421. CONTRAST: boolean;
  30422. EXPOSURE: boolean;
  30423. COLORCURVES: boolean;
  30424. COLORGRADING: boolean;
  30425. COLORGRADING3D: boolean;
  30426. SAMPLER3DGREENDEPTH: boolean;
  30427. SAMPLER3DBGRMAP: boolean;
  30428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30429. }
  30430. /**
  30431. * @hidden
  30432. */
  30433. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30434. IMAGEPROCESSING: boolean;
  30435. VIGNETTE: boolean;
  30436. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30437. VIGNETTEBLENDMODEOPAQUE: boolean;
  30438. TONEMAPPING: boolean;
  30439. TONEMAPPING_ACES: boolean;
  30440. CONTRAST: boolean;
  30441. COLORCURVES: boolean;
  30442. COLORGRADING: boolean;
  30443. COLORGRADING3D: boolean;
  30444. SAMPLER3DGREENDEPTH: boolean;
  30445. SAMPLER3DBGRMAP: boolean;
  30446. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30447. EXPOSURE: boolean;
  30448. constructor();
  30449. }
  30450. /**
  30451. * This groups together the common properties used for image processing either in direct forward pass
  30452. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30453. * or not.
  30454. */
  30455. export class ImageProcessingConfiguration {
  30456. /**
  30457. * Default tone mapping applied in BabylonJS.
  30458. */
  30459. static readonly TONEMAPPING_STANDARD: number;
  30460. /**
  30461. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30462. * to other engines rendering to increase portability.
  30463. */
  30464. static readonly TONEMAPPING_ACES: number;
  30465. /**
  30466. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30467. */
  30468. colorCurves: Nullable<ColorCurves>;
  30469. private _colorCurvesEnabled;
  30470. /**
  30471. * Gets wether the color curves effect is enabled.
  30472. */
  30473. /**
  30474. * Sets wether the color curves effect is enabled.
  30475. */
  30476. colorCurvesEnabled: boolean;
  30477. private _colorGradingTexture;
  30478. /**
  30479. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30480. */
  30481. /**
  30482. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30483. */
  30484. colorGradingTexture: Nullable<BaseTexture>;
  30485. private _colorGradingEnabled;
  30486. /**
  30487. * Gets wether the color grading effect is enabled.
  30488. */
  30489. /**
  30490. * Sets wether the color grading effect is enabled.
  30491. */
  30492. colorGradingEnabled: boolean;
  30493. private _colorGradingWithGreenDepth;
  30494. /**
  30495. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30496. */
  30497. /**
  30498. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30499. */
  30500. colorGradingWithGreenDepth: boolean;
  30501. private _colorGradingBGR;
  30502. /**
  30503. * Gets wether the color grading texture contains BGR values.
  30504. */
  30505. /**
  30506. * Sets wether the color grading texture contains BGR values.
  30507. */
  30508. colorGradingBGR: boolean;
  30509. /** @hidden */
  30510. _exposure: number;
  30511. /**
  30512. * Gets the Exposure used in the effect.
  30513. */
  30514. /**
  30515. * Sets the Exposure used in the effect.
  30516. */
  30517. exposure: number;
  30518. private _toneMappingEnabled;
  30519. /**
  30520. * Gets wether the tone mapping effect is enabled.
  30521. */
  30522. /**
  30523. * Sets wether the tone mapping effect is enabled.
  30524. */
  30525. toneMappingEnabled: boolean;
  30526. private _toneMappingType;
  30527. /**
  30528. * Gets the type of tone mapping effect.
  30529. */
  30530. /**
  30531. * Sets the type of tone mapping effect used in BabylonJS.
  30532. */
  30533. toneMappingType: number;
  30534. protected _contrast: number;
  30535. /**
  30536. * Gets the contrast used in the effect.
  30537. */
  30538. /**
  30539. * Sets the contrast used in the effect.
  30540. */
  30541. contrast: number;
  30542. /**
  30543. * Vignette stretch size.
  30544. */
  30545. vignetteStretch: number;
  30546. /**
  30547. * Vignette centre X Offset.
  30548. */
  30549. vignetteCentreX: number;
  30550. /**
  30551. * Vignette centre Y Offset.
  30552. */
  30553. vignetteCentreY: number;
  30554. /**
  30555. * Vignette weight or intensity of the vignette effect.
  30556. */
  30557. vignetteWeight: number;
  30558. /**
  30559. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30560. * if vignetteEnabled is set to true.
  30561. */
  30562. vignetteColor: Color4;
  30563. /**
  30564. * Camera field of view used by the Vignette effect.
  30565. */
  30566. vignetteCameraFov: number;
  30567. private _vignetteBlendMode;
  30568. /**
  30569. * Gets the vignette blend mode allowing different kind of effect.
  30570. */
  30571. /**
  30572. * Sets the vignette blend mode allowing different kind of effect.
  30573. */
  30574. vignetteBlendMode: number;
  30575. private _vignetteEnabled;
  30576. /**
  30577. * Gets wether the vignette effect is enabled.
  30578. */
  30579. /**
  30580. * Sets wether the vignette effect is enabled.
  30581. */
  30582. vignetteEnabled: boolean;
  30583. private _applyByPostProcess;
  30584. /**
  30585. * Gets wether the image processing is applied through a post process or not.
  30586. */
  30587. /**
  30588. * Sets wether the image processing is applied through a post process or not.
  30589. */
  30590. applyByPostProcess: boolean;
  30591. private _isEnabled;
  30592. /**
  30593. * Gets wether the image processing is enabled or not.
  30594. */
  30595. /**
  30596. * Sets wether the image processing is enabled or not.
  30597. */
  30598. isEnabled: boolean;
  30599. /**
  30600. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30601. */
  30602. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30603. /**
  30604. * Method called each time the image processing information changes requires to recompile the effect.
  30605. */
  30606. protected _updateParameters(): void;
  30607. /**
  30608. * Gets the current class name.
  30609. * @return "ImageProcessingConfiguration"
  30610. */
  30611. getClassName(): string;
  30612. /**
  30613. * Prepare the list of uniforms associated with the Image Processing effects.
  30614. * @param uniforms The list of uniforms used in the effect
  30615. * @param defines the list of defines currently in use
  30616. */
  30617. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30618. /**
  30619. * Prepare the list of samplers associated with the Image Processing effects.
  30620. * @param samplersList The list of uniforms used in the effect
  30621. * @param defines the list of defines currently in use
  30622. */
  30623. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30624. /**
  30625. * Prepare the list of defines associated to the shader.
  30626. * @param defines the list of defines to complete
  30627. * @param forPostProcess Define if we are currently in post process mode or not
  30628. */
  30629. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30630. /**
  30631. * Returns true if all the image processing information are ready.
  30632. * @returns True if ready, otherwise, false
  30633. */
  30634. isReady(): boolean;
  30635. /**
  30636. * Binds the image processing to the shader.
  30637. * @param effect The effect to bind to
  30638. * @param aspectRatio Define the current aspect ratio of the effect
  30639. */
  30640. bind(effect: Effect, aspectRatio?: number): void;
  30641. /**
  30642. * Clones the current image processing instance.
  30643. * @return The cloned image processing
  30644. */
  30645. clone(): ImageProcessingConfiguration;
  30646. /**
  30647. * Serializes the current image processing instance to a json representation.
  30648. * @return a JSON representation
  30649. */
  30650. serialize(): any;
  30651. /**
  30652. * Parses the image processing from a json representation.
  30653. * @param source the JSON source to parse
  30654. * @return The parsed image processing
  30655. */
  30656. static Parse(source: any): ImageProcessingConfiguration;
  30657. private static _VIGNETTEMODE_MULTIPLY;
  30658. private static _VIGNETTEMODE_OPAQUE;
  30659. /**
  30660. * Used to apply the vignette as a mix with the pixel color.
  30661. */
  30662. static readonly VIGNETTEMODE_MULTIPLY: number;
  30663. /**
  30664. * Used to apply the vignette as a replacement of the pixel color.
  30665. */
  30666. static readonly VIGNETTEMODE_OPAQUE: number;
  30667. }
  30668. }
  30669. declare module "babylonjs/Materials/fresnelParameters" {
  30670. import { Color3 } from "babylonjs/Maths/math";
  30671. /**
  30672. * This represents all the required information to add a fresnel effect on a material:
  30673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30674. */
  30675. export class FresnelParameters {
  30676. private _isEnabled;
  30677. /**
  30678. * Define if the fresnel effect is enable or not.
  30679. */
  30680. isEnabled: boolean;
  30681. /**
  30682. * Define the color used on edges (grazing angle)
  30683. */
  30684. leftColor: Color3;
  30685. /**
  30686. * Define the color used on center
  30687. */
  30688. rightColor: Color3;
  30689. /**
  30690. * Define bias applied to computed fresnel term
  30691. */
  30692. bias: number;
  30693. /**
  30694. * Defined the power exponent applied to fresnel term
  30695. */
  30696. power: number;
  30697. /**
  30698. * Clones the current fresnel and its valuues
  30699. * @returns a clone fresnel configuration
  30700. */
  30701. clone(): FresnelParameters;
  30702. /**
  30703. * Serializes the current fresnel parameters to a JSON representation.
  30704. * @return the JSON serialization
  30705. */
  30706. serialize(): any;
  30707. /**
  30708. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30709. * @param parsedFresnelParameters Define the JSON representation
  30710. * @returns the parsed parameters
  30711. */
  30712. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30713. }
  30714. }
  30715. declare module "babylonjs/Misc/decorators" {
  30716. import { Nullable } from "babylonjs/types";
  30717. import { Scene } from "babylonjs/scene";
  30718. import { IAnimatable } from "babylonjs/Misc/tools";
  30719. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30720. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30721. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30722. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30723. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30724. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30725. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30726. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30727. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30728. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30729. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30730. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30731. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30732. /**
  30733. * Decorator used to define property that can be serialized as reference to a camera
  30734. * @param sourceName defines the name of the property to decorate
  30735. */
  30736. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30737. /**
  30738. * Class used to help serialization objects
  30739. */
  30740. export class SerializationHelper {
  30741. /** hidden */
  30742. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30743. /** hidden */
  30744. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30745. /** hidden */
  30746. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30747. /** hidden */
  30748. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30749. /**
  30750. * Appends the serialized animations from the source animations
  30751. * @param source Source containing the animations
  30752. * @param destination Target to store the animations
  30753. */
  30754. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30755. /**
  30756. * Static function used to serialized a specific entity
  30757. * @param entity defines the entity to serialize
  30758. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30759. * @returns a JSON compatible object representing the serialization of the entity
  30760. */
  30761. static Serialize<T>(entity: T, serializationObject?: any): any;
  30762. /**
  30763. * Creates a new entity from a serialization data object
  30764. * @param creationFunction defines a function used to instanciated the new entity
  30765. * @param source defines the source serialization data
  30766. * @param scene defines the hosting scene
  30767. * @param rootUrl defines the root url for resources
  30768. * @returns a new entity
  30769. */
  30770. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30771. /**
  30772. * Clones an object
  30773. * @param creationFunction defines the function used to instanciate the new object
  30774. * @param source defines the source object
  30775. * @returns the cloned object
  30776. */
  30777. static Clone<T>(creationFunction: () => T, source: T): T;
  30778. /**
  30779. * Instanciates a new object based on a source one (some data will be shared between both object)
  30780. * @param creationFunction defines the function used to instanciate the new object
  30781. * @param source defines the source object
  30782. * @returns the new object
  30783. */
  30784. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30785. }
  30786. }
  30787. declare module "babylonjs/Cameras/camera" {
  30788. import { SmartArray } from "babylonjs/Misc/smartArray";
  30789. import { Observable } from "babylonjs/Misc/observable";
  30790. import { Nullable } from "babylonjs/types";
  30791. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30792. import { Scene } from "babylonjs/scene";
  30793. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30794. import { Node } from "babylonjs/node";
  30795. import { Mesh } from "babylonjs/Meshes/mesh";
  30796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30798. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30801. import { Ray } from "babylonjs/Culling/ray";
  30802. /**
  30803. * This is the base class of all the camera used in the application.
  30804. * @see http://doc.babylonjs.com/features/cameras
  30805. */
  30806. export class Camera extends Node {
  30807. /** @hidden */
  30808. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30809. /**
  30810. * This is the default projection mode used by the cameras.
  30811. * It helps recreating a feeling of perspective and better appreciate depth.
  30812. * This is the best way to simulate real life cameras.
  30813. */
  30814. static readonly PERSPECTIVE_CAMERA: number;
  30815. /**
  30816. * This helps creating camera with an orthographic mode.
  30817. * 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.
  30818. */
  30819. static readonly ORTHOGRAPHIC_CAMERA: number;
  30820. /**
  30821. * This is the default FOV mode for perspective cameras.
  30822. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30823. */
  30824. static readonly FOVMODE_VERTICAL_FIXED: number;
  30825. /**
  30826. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30827. */
  30828. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30829. /**
  30830. * This specifies ther is no need for a camera rig.
  30831. * Basically only one eye is rendered corresponding to the camera.
  30832. */
  30833. static readonly RIG_MODE_NONE: number;
  30834. /**
  30835. * Simulates a camera Rig with one blue eye and one red eye.
  30836. * This can be use with 3d blue and red glasses.
  30837. */
  30838. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30839. /**
  30840. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30841. */
  30842. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30843. /**
  30844. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30845. */
  30846. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30847. /**
  30848. * Defines that both eyes of the camera will be rendered over under each other.
  30849. */
  30850. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30851. /**
  30852. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30853. */
  30854. static readonly RIG_MODE_VR: number;
  30855. /**
  30856. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30857. */
  30858. static readonly RIG_MODE_WEBVR: number;
  30859. /**
  30860. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30861. */
  30862. static readonly RIG_MODE_CUSTOM: number;
  30863. /**
  30864. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30865. */
  30866. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30867. /**
  30868. * Define the input manager associated with the camera.
  30869. */
  30870. inputs: CameraInputsManager<Camera>;
  30871. /** @hidden */
  30872. _position: Vector3;
  30873. /**
  30874. * Define the current local position of the camera in the scene
  30875. */
  30876. position: Vector3;
  30877. /**
  30878. * The vector the camera should consider as up.
  30879. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30880. */
  30881. upVector: Vector3;
  30882. /**
  30883. * Define the current limit on the left side for an orthographic camera
  30884. * In scene unit
  30885. */
  30886. orthoLeft: Nullable<number>;
  30887. /**
  30888. * Define the current limit on the right side for an orthographic camera
  30889. * In scene unit
  30890. */
  30891. orthoRight: Nullable<number>;
  30892. /**
  30893. * Define the current limit on the bottom side for an orthographic camera
  30894. * In scene unit
  30895. */
  30896. orthoBottom: Nullable<number>;
  30897. /**
  30898. * Define the current limit on the top side for an orthographic camera
  30899. * In scene unit
  30900. */
  30901. orthoTop: Nullable<number>;
  30902. /**
  30903. * Field Of View is set in Radians. (default is 0.8)
  30904. */
  30905. fov: number;
  30906. /**
  30907. * Define the minimum distance the camera can see from.
  30908. * This is important to note that the depth buffer are not infinite and the closer it starts
  30909. * the more your scene might encounter depth fighting issue.
  30910. */
  30911. minZ: number;
  30912. /**
  30913. * Define the maximum distance the camera can see to.
  30914. * This is important to note that the depth buffer are not infinite and the further it end
  30915. * the more your scene might encounter depth fighting issue.
  30916. */
  30917. maxZ: number;
  30918. /**
  30919. * Define the default inertia of the camera.
  30920. * This helps giving a smooth feeling to the camera movement.
  30921. */
  30922. inertia: number;
  30923. /**
  30924. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30925. */
  30926. mode: number;
  30927. /**
  30928. * Define wether the camera is intermediate.
  30929. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30930. */
  30931. isIntermediate: boolean;
  30932. /**
  30933. * Define the viewport of the camera.
  30934. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30935. */
  30936. viewport: Viewport;
  30937. /**
  30938. * Restricts the camera to viewing objects with the same layerMask.
  30939. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30940. */
  30941. layerMask: number;
  30942. /**
  30943. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30944. */
  30945. fovMode: number;
  30946. /**
  30947. * Rig mode of the camera.
  30948. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30949. * This is normally controlled byt the camera themselves as internal use.
  30950. */
  30951. cameraRigMode: number;
  30952. /**
  30953. * Defines the distance between both "eyes" in case of a RIG
  30954. */
  30955. interaxialDistance: number;
  30956. /**
  30957. * Defines if stereoscopic rendering is done side by side or over under.
  30958. */
  30959. isStereoscopicSideBySide: boolean;
  30960. /**
  30961. * 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
  30962. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30963. * else in the scene.
  30964. */
  30965. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30966. /**
  30967. * When set, the camera will render to this render target instead of the default canvas
  30968. */
  30969. outputRenderTarget: Nullable<RenderTargetTexture>;
  30970. /**
  30971. * Observable triggered when the camera view matrix has changed.
  30972. */
  30973. onViewMatrixChangedObservable: Observable<Camera>;
  30974. /**
  30975. * Observable triggered when the camera Projection matrix has changed.
  30976. */
  30977. onProjectionMatrixChangedObservable: Observable<Camera>;
  30978. /**
  30979. * Observable triggered when the inputs have been processed.
  30980. */
  30981. onAfterCheckInputsObservable: Observable<Camera>;
  30982. /**
  30983. * Observable triggered when reset has been called and applied to the camera.
  30984. */
  30985. onRestoreStateObservable: Observable<Camera>;
  30986. /** @hidden */
  30987. _cameraRigParams: any;
  30988. /** @hidden */
  30989. _rigCameras: Camera[];
  30990. /** @hidden */
  30991. _rigPostProcess: Nullable<PostProcess>;
  30992. protected _webvrViewMatrix: Matrix;
  30993. /** @hidden */
  30994. _skipRendering: boolean;
  30995. /** @hidden */
  30996. _projectionMatrix: Matrix;
  30997. /** @hidden */
  30998. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30999. /** @hidden */
  31000. _activeMeshes: SmartArray<AbstractMesh>;
  31001. protected _globalPosition: Vector3;
  31002. /** hidden */
  31003. _computedViewMatrix: Matrix;
  31004. private _doNotComputeProjectionMatrix;
  31005. private _transformMatrix;
  31006. private _frustumPlanes;
  31007. private _refreshFrustumPlanes;
  31008. private _storedFov;
  31009. private _stateStored;
  31010. /**
  31011. * Instantiates a new camera object.
  31012. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31013. * @see http://doc.babylonjs.com/features/cameras
  31014. * @param name Defines the name of the camera in the scene
  31015. * @param position Defines the position of the camera
  31016. * @param scene Defines the scene the camera belongs too
  31017. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31018. */
  31019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31020. /**
  31021. * Store current camera state (fov, position, etc..)
  31022. * @returns the camera
  31023. */
  31024. storeState(): Camera;
  31025. /**
  31026. * Restores the camera state values if it has been stored. You must call storeState() first
  31027. */
  31028. protected _restoreStateValues(): boolean;
  31029. /**
  31030. * Restored camera state. You must call storeState() first.
  31031. * @returns true if restored and false otherwise
  31032. */
  31033. restoreState(): boolean;
  31034. /**
  31035. * Gets the class name of the camera.
  31036. * @returns the class name
  31037. */
  31038. getClassName(): string;
  31039. /** @hidden */
  31040. readonly _isCamera: boolean;
  31041. /**
  31042. * Gets a string representation of the camera useful for debug purpose.
  31043. * @param fullDetails Defines that a more verboe level of logging is required
  31044. * @returns the string representation
  31045. */
  31046. toString(fullDetails?: boolean): string;
  31047. /**
  31048. * Gets the current world space position of the camera.
  31049. */
  31050. readonly globalPosition: Vector3;
  31051. /**
  31052. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31053. * @returns the active meshe list
  31054. */
  31055. getActiveMeshes(): SmartArray<AbstractMesh>;
  31056. /**
  31057. * Check wether a mesh is part of the current active mesh list of the camera
  31058. * @param mesh Defines the mesh to check
  31059. * @returns true if active, false otherwise
  31060. */
  31061. isActiveMesh(mesh: Mesh): boolean;
  31062. /**
  31063. * Is this camera ready to be used/rendered
  31064. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31065. * @return true if the camera is ready
  31066. */
  31067. isReady(completeCheck?: boolean): boolean;
  31068. /** @hidden */
  31069. _initCache(): void;
  31070. /** @hidden */
  31071. _updateCache(ignoreParentClass?: boolean): void;
  31072. /** @hidden */
  31073. _isSynchronized(): boolean;
  31074. /** @hidden */
  31075. _isSynchronizedViewMatrix(): boolean;
  31076. /** @hidden */
  31077. _isSynchronizedProjectionMatrix(): boolean;
  31078. /**
  31079. * Attach the input controls to a specific dom element to get the input from.
  31080. * @param element Defines the element the controls should be listened from
  31081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31082. */
  31083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31084. /**
  31085. * Detach the current controls from the specified dom element.
  31086. * @param element Defines the element to stop listening the inputs from
  31087. */
  31088. detachControl(element: HTMLElement): void;
  31089. /**
  31090. * Update the camera state according to the different inputs gathered during the frame.
  31091. */
  31092. update(): void;
  31093. /** @hidden */
  31094. _checkInputs(): void;
  31095. /** @hidden */
  31096. readonly rigCameras: Camera[];
  31097. /**
  31098. * Gets the post process used by the rig cameras
  31099. */
  31100. readonly rigPostProcess: Nullable<PostProcess>;
  31101. /**
  31102. * Internal, gets the first post proces.
  31103. * @returns the first post process to be run on this camera.
  31104. */
  31105. _getFirstPostProcess(): Nullable<PostProcess>;
  31106. private _cascadePostProcessesToRigCams;
  31107. /**
  31108. * Attach a post process to the camera.
  31109. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31110. * @param postProcess The post process to attach to the camera
  31111. * @param insertAt The position of the post process in case several of them are in use in the scene
  31112. * @returns the position the post process has been inserted at
  31113. */
  31114. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31115. /**
  31116. * Detach a post process to the camera.
  31117. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31118. * @param postProcess The post process to detach from the camera
  31119. */
  31120. detachPostProcess(postProcess: PostProcess): void;
  31121. /**
  31122. * Gets the current world matrix of the camera
  31123. */
  31124. getWorldMatrix(): Matrix;
  31125. /** @hidden */
  31126. _getViewMatrix(): Matrix;
  31127. /**
  31128. * Gets the current view matrix of the camera.
  31129. * @param force forces the camera to recompute the matrix without looking at the cached state
  31130. * @returns the view matrix
  31131. */
  31132. getViewMatrix(force?: boolean): Matrix;
  31133. /**
  31134. * Freeze the projection matrix.
  31135. * It will prevent the cache check of the camera projection compute and can speed up perf
  31136. * if no parameter of the camera are meant to change
  31137. * @param projection Defines manually a projection if necessary
  31138. */
  31139. freezeProjectionMatrix(projection?: Matrix): void;
  31140. /**
  31141. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31142. */
  31143. unfreezeProjectionMatrix(): void;
  31144. /**
  31145. * Gets the current projection matrix of the camera.
  31146. * @param force forces the camera to recompute the matrix without looking at the cached state
  31147. * @returns the projection matrix
  31148. */
  31149. getProjectionMatrix(force?: boolean): Matrix;
  31150. /**
  31151. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31152. * @returns a Matrix
  31153. */
  31154. getTransformationMatrix(): Matrix;
  31155. private _updateFrustumPlanes;
  31156. /**
  31157. * Checks if a cullable object (mesh...) is in the camera frustum
  31158. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31159. * @param target The object to check
  31160. * @returns true if the object is in frustum otherwise false
  31161. */
  31162. isInFrustum(target: ICullable): boolean;
  31163. /**
  31164. * Checks if a cullable object (mesh...) is in the camera frustum
  31165. * Unlike isInFrustum this cheks the full bounding box
  31166. * @param target The object to check
  31167. * @returns true if the object is in frustum otherwise false
  31168. */
  31169. isCompletelyInFrustum(target: ICullable): boolean;
  31170. /**
  31171. * Gets a ray in the forward direction from the camera.
  31172. * @param length Defines the length of the ray to create
  31173. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31174. * @param origin Defines the start point of the ray which defaults to the camera position
  31175. * @returns the forward ray
  31176. */
  31177. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31178. /**
  31179. * Releases resources associated with this node.
  31180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31182. */
  31183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31184. /** @hidden */
  31185. _isLeftCamera: boolean;
  31186. /**
  31187. * Gets the left camera of a rig setup in case of Rigged Camera
  31188. */
  31189. readonly isLeftCamera: boolean;
  31190. /** @hidden */
  31191. _isRightCamera: boolean;
  31192. /**
  31193. * Gets the right camera of a rig setup in case of Rigged Camera
  31194. */
  31195. readonly isRightCamera: boolean;
  31196. /**
  31197. * Gets the left camera of a rig setup in case of Rigged Camera
  31198. */
  31199. readonly leftCamera: Nullable<FreeCamera>;
  31200. /**
  31201. * Gets the right camera of a rig setup in case of Rigged Camera
  31202. */
  31203. readonly rightCamera: Nullable<FreeCamera>;
  31204. /**
  31205. * Gets the left camera target of a rig setup in case of Rigged Camera
  31206. * @returns the target position
  31207. */
  31208. getLeftTarget(): Nullable<Vector3>;
  31209. /**
  31210. * Gets the right camera target of a rig setup in case of Rigged Camera
  31211. * @returns the target position
  31212. */
  31213. getRightTarget(): Nullable<Vector3>;
  31214. /**
  31215. * @hidden
  31216. */
  31217. setCameraRigMode(mode: number, rigParams: any): void;
  31218. /** @hidden */
  31219. static _setStereoscopicRigMode(camera: Camera): void;
  31220. /** @hidden */
  31221. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31222. /** @hidden */
  31223. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31224. /** @hidden */
  31225. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31226. /** @hidden */
  31227. _getVRProjectionMatrix(): Matrix;
  31228. protected _updateCameraRotationMatrix(): void;
  31229. protected _updateWebVRCameraRotationMatrix(): void;
  31230. /**
  31231. * This function MUST be overwritten by the different WebVR cameras available.
  31232. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31233. * @hidden
  31234. */
  31235. _getWebVRProjectionMatrix(): Matrix;
  31236. /**
  31237. * This function MUST be overwritten by the different WebVR cameras available.
  31238. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31239. * @hidden
  31240. */
  31241. _getWebVRViewMatrix(): Matrix;
  31242. /** @hidden */
  31243. setCameraRigParameter(name: string, value: any): void;
  31244. /**
  31245. * needs to be overridden by children so sub has required properties to be copied
  31246. * @hidden
  31247. */
  31248. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31249. /**
  31250. * May need to be overridden by children
  31251. * @hidden
  31252. */
  31253. _updateRigCameras(): void;
  31254. /** @hidden */
  31255. _setupInputs(): void;
  31256. /**
  31257. * Serialiaze the camera setup to a json represention
  31258. * @returns the JSON representation
  31259. */
  31260. serialize(): any;
  31261. /**
  31262. * Clones the current camera.
  31263. * @param name The cloned camera name
  31264. * @returns the cloned camera
  31265. */
  31266. clone(name: string): Camera;
  31267. /**
  31268. * Gets the direction of the camera relative to a given local axis.
  31269. * @param localAxis Defines the reference axis to provide a relative direction.
  31270. * @return the direction
  31271. */
  31272. getDirection(localAxis: Vector3): Vector3;
  31273. /**
  31274. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31275. * @param localAxis Defines the reference axis to provide a relative direction.
  31276. * @param result Defines the vector to store the result in
  31277. */
  31278. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31279. /**
  31280. * Gets a camera constructor for a given camera type
  31281. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31282. * @param name The name of the camera the result will be able to instantiate
  31283. * @param scene The scene the result will construct the camera in
  31284. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31285. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31286. * @returns a factory method to construc the camera
  31287. */
  31288. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31289. /**
  31290. * Compute the world matrix of the camera.
  31291. * @returns the camera workd matrix
  31292. */
  31293. computeWorldMatrix(): Matrix;
  31294. /**
  31295. * Parse a JSON and creates the camera from the parsed information
  31296. * @param parsedCamera The JSON to parse
  31297. * @param scene The scene to instantiate the camera in
  31298. * @returns the newly constructed camera
  31299. */
  31300. static Parse(parsedCamera: any, scene: Scene): Camera;
  31301. }
  31302. }
  31303. declare module "babylonjs/Misc/tools" {
  31304. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31305. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31306. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31307. import { Observable } from "babylonjs/Misc/observable";
  31308. import { DomManagement } from "babylonjs/Misc/domManagement";
  31309. import { WebRequest } from "babylonjs/Misc/webRequest";
  31310. import { Camera } from "babylonjs/Cameras/camera";
  31311. import { Engine } from "babylonjs/Engines/engine";
  31312. import { Animation } from "babylonjs/Animations/animation";
  31313. /**
  31314. * Interface for any object that can request an animation frame
  31315. */
  31316. export interface ICustomAnimationFrameRequester {
  31317. /**
  31318. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31319. */
  31320. renderFunction?: Function;
  31321. /**
  31322. * Called to request the next frame to render to
  31323. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31324. */
  31325. requestAnimationFrame: Function;
  31326. /**
  31327. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31328. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31329. */
  31330. requestID?: number;
  31331. }
  31332. /**
  31333. * Interface containing an array of animations
  31334. */
  31335. export interface IAnimatable {
  31336. /**
  31337. * Array of animations
  31338. */
  31339. animations: Array<Animation>;
  31340. }
  31341. /** Interface used by value gradients (color, factor, ...) */
  31342. export interface IValueGradient {
  31343. /**
  31344. * Gets or sets the gradient value (between 0 and 1)
  31345. */
  31346. gradient: number;
  31347. }
  31348. /** Class used to store color4 gradient */
  31349. export class ColorGradient implements IValueGradient {
  31350. /**
  31351. * Gets or sets the gradient value (between 0 and 1)
  31352. */
  31353. gradient: number;
  31354. /**
  31355. * Gets or sets first associated color
  31356. */
  31357. color1: Color4;
  31358. /**
  31359. * Gets or sets second associated color
  31360. */
  31361. color2?: Color4;
  31362. /**
  31363. * Will get a color picked randomly between color1 and color2.
  31364. * If color2 is undefined then color1 will be used
  31365. * @param result defines the target Color4 to store the result in
  31366. */
  31367. getColorToRef(result: Color4): void;
  31368. }
  31369. /** Class used to store color 3 gradient */
  31370. export class Color3Gradient implements IValueGradient {
  31371. /**
  31372. * Gets or sets the gradient value (between 0 and 1)
  31373. */
  31374. gradient: number;
  31375. /**
  31376. * Gets or sets the associated color
  31377. */
  31378. color: Color3;
  31379. }
  31380. /** Class used to store factor gradient */
  31381. export class FactorGradient implements IValueGradient {
  31382. /**
  31383. * Gets or sets the gradient value (between 0 and 1)
  31384. */
  31385. gradient: number;
  31386. /**
  31387. * Gets or sets first associated factor
  31388. */
  31389. factor1: number;
  31390. /**
  31391. * Gets or sets second associated factor
  31392. */
  31393. factor2?: number;
  31394. /**
  31395. * Will get a number picked randomly between factor1 and factor2.
  31396. * If factor2 is undefined then factor1 will be used
  31397. * @returns the picked number
  31398. */
  31399. getFactor(): number;
  31400. }
  31401. /**
  31402. * @ignore
  31403. * Application error to support additional information when loading a file
  31404. */
  31405. export class LoadFileError extends Error {
  31406. /** defines the optional web request */
  31407. request?: WebRequest | undefined;
  31408. private static _setPrototypeOf;
  31409. /**
  31410. * Creates a new LoadFileError
  31411. * @param message defines the message of the error
  31412. * @param request defines the optional web request
  31413. */
  31414. constructor(message: string,
  31415. /** defines the optional web request */
  31416. request?: WebRequest | undefined);
  31417. }
  31418. /**
  31419. * Class used to define a retry strategy when error happens while loading assets
  31420. */
  31421. export class RetryStrategy {
  31422. /**
  31423. * Function used to defines an exponential back off strategy
  31424. * @param maxRetries defines the maximum number of retries (3 by default)
  31425. * @param baseInterval defines the interval between retries
  31426. * @returns the strategy function to use
  31427. */
  31428. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31429. }
  31430. /**
  31431. * File request interface
  31432. */
  31433. export interface IFileRequest {
  31434. /**
  31435. * Raised when the request is complete (success or error).
  31436. */
  31437. onCompleteObservable: Observable<IFileRequest>;
  31438. /**
  31439. * Aborts the request for a file.
  31440. */
  31441. abort: () => void;
  31442. }
  31443. /**
  31444. * Class containing a set of static utilities functions
  31445. */
  31446. export class Tools {
  31447. /**
  31448. * Gets or sets the base URL to use to load assets
  31449. */
  31450. static BaseUrl: string;
  31451. /**
  31452. * Enable/Disable Custom HTTP Request Headers globally.
  31453. * default = false
  31454. * @see CustomRequestHeaders
  31455. */
  31456. static UseCustomRequestHeaders: boolean;
  31457. /**
  31458. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31459. * i.e. when loading files, where the server/service expects an Authorization header
  31460. */
  31461. static CustomRequestHeaders: {
  31462. [key: string]: string;
  31463. };
  31464. /**
  31465. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31466. */
  31467. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31468. /**
  31469. * Default behaviour for cors in the application.
  31470. * It can be a string if the expected behavior is identical in the entire app.
  31471. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31472. */
  31473. static CorsBehavior: string | ((url: string | string[]) => string);
  31474. /**
  31475. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31476. * @ignorenaming
  31477. */
  31478. static UseFallbackTexture: boolean;
  31479. /**
  31480. * Use this object to register external classes like custom textures or material
  31481. * to allow the laoders to instantiate them
  31482. */
  31483. static RegisteredExternalClasses: {
  31484. [key: string]: Object;
  31485. };
  31486. /**
  31487. * Texture content used if a texture cannot loaded
  31488. * @ignorenaming
  31489. */
  31490. static fallbackTexture: string;
  31491. /**
  31492. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31493. * @param u defines the coordinate on X axis
  31494. * @param v defines the coordinate on Y axis
  31495. * @param width defines the width of the source data
  31496. * @param height defines the height of the source data
  31497. * @param pixels defines the source byte array
  31498. * @param color defines the output color
  31499. */
  31500. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31501. /**
  31502. * Interpolates between a and b via alpha
  31503. * @param a The lower value (returned when alpha = 0)
  31504. * @param b The upper value (returned when alpha = 1)
  31505. * @param alpha The interpolation-factor
  31506. * @return The mixed value
  31507. */
  31508. static Mix(a: number, b: number, alpha: number): number;
  31509. /**
  31510. * Tries to instantiate a new object from a given class name
  31511. * @param className defines the class name to instantiate
  31512. * @returns the new object or null if the system was not able to do the instantiation
  31513. */
  31514. static Instantiate(className: string): any;
  31515. /**
  31516. * Provides a slice function that will work even on IE
  31517. * @param data defines the array to slice
  31518. * @param start defines the start of the data (optional)
  31519. * @param end defines the end of the data (optional)
  31520. * @returns the new sliced array
  31521. */
  31522. static Slice<T>(data: T, start?: number, end?: number): T;
  31523. /**
  31524. * Polyfill for setImmediate
  31525. * @param action defines the action to execute after the current execution block
  31526. */
  31527. static SetImmediate(action: () => void): void;
  31528. /**
  31529. * Function indicating if a number is an exponent of 2
  31530. * @param value defines the value to test
  31531. * @returns true if the value is an exponent of 2
  31532. */
  31533. static IsExponentOfTwo(value: number): boolean;
  31534. private static _tmpFloatArray;
  31535. /**
  31536. * Returns the nearest 32-bit single precision float representation of a Number
  31537. * @param value A Number. If the parameter is of a different type, it will get converted
  31538. * to a number or to NaN if it cannot be converted
  31539. * @returns number
  31540. */
  31541. static FloatRound(value: number): number;
  31542. /**
  31543. * Find the next highest power of two.
  31544. * @param x Number to start search from.
  31545. * @return Next highest power of two.
  31546. */
  31547. static CeilingPOT(x: number): number;
  31548. /**
  31549. * Find the next lowest power of two.
  31550. * @param x Number to start search from.
  31551. * @return Next lowest power of two.
  31552. */
  31553. static FloorPOT(x: number): number;
  31554. /**
  31555. * Find the nearest power of two.
  31556. * @param x Number to start search from.
  31557. * @return Next nearest power of two.
  31558. */
  31559. static NearestPOT(x: number): number;
  31560. /**
  31561. * Get the closest exponent of two
  31562. * @param value defines the value to approximate
  31563. * @param max defines the maximum value to return
  31564. * @param mode defines how to define the closest value
  31565. * @returns closest exponent of two of the given value
  31566. */
  31567. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31568. /**
  31569. * Extracts the filename from a path
  31570. * @param path defines the path to use
  31571. * @returns the filename
  31572. */
  31573. static GetFilename(path: string): string;
  31574. /**
  31575. * Extracts the "folder" part of a path (everything before the filename).
  31576. * @param uri The URI to extract the info from
  31577. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31578. * @returns The "folder" part of the path
  31579. */
  31580. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31581. /**
  31582. * Extracts text content from a DOM element hierarchy
  31583. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31584. */
  31585. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31586. /**
  31587. * Convert an angle in radians to degrees
  31588. * @param angle defines the angle to convert
  31589. * @returns the angle in degrees
  31590. */
  31591. static ToDegrees(angle: number): number;
  31592. /**
  31593. * Convert an angle in degrees to radians
  31594. * @param angle defines the angle to convert
  31595. * @returns the angle in radians
  31596. */
  31597. static ToRadians(angle: number): number;
  31598. /**
  31599. * Encode a buffer to a base64 string
  31600. * @param buffer defines the buffer to encode
  31601. * @returns the encoded string
  31602. */
  31603. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31604. /**
  31605. * Extracts minimum and maximum values from a list of indexed positions
  31606. * @param positions defines the positions to use
  31607. * @param indices defines the indices to the positions
  31608. * @param indexStart defines the start index
  31609. * @param indexCount defines the end index
  31610. * @param bias defines bias value to add to the result
  31611. * @return minimum and maximum values
  31612. */
  31613. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31614. minimum: Vector3;
  31615. maximum: Vector3;
  31616. };
  31617. /**
  31618. * Extracts minimum and maximum values from a list of positions
  31619. * @param positions defines the positions to use
  31620. * @param start defines the start index in the positions array
  31621. * @param count defines the number of positions to handle
  31622. * @param bias defines bias value to add to the result
  31623. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31624. * @return minimum and maximum values
  31625. */
  31626. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31627. minimum: Vector3;
  31628. maximum: Vector3;
  31629. };
  31630. /**
  31631. * Returns an array if obj is not an array
  31632. * @param obj defines the object to evaluate as an array
  31633. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31634. * @returns either obj directly if obj is an array or a new array containing obj
  31635. */
  31636. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31637. /**
  31638. * Gets the pointer prefix to use
  31639. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31640. */
  31641. static GetPointerPrefix(): string;
  31642. /**
  31643. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31644. * @param func - the function to be called
  31645. * @param requester - the object that will request the next frame. Falls back to window.
  31646. * @returns frame number
  31647. */
  31648. static QueueNewFrame(func: () => void, requester?: any): number;
  31649. /**
  31650. * Ask the browser to promote the current element to fullscreen rendering mode
  31651. * @param element defines the DOM element to promote
  31652. */
  31653. static RequestFullscreen(element: HTMLElement): void;
  31654. /**
  31655. * Asks the browser to exit fullscreen mode
  31656. */
  31657. static ExitFullscreen(): void;
  31658. /**
  31659. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31660. * @param url define the url we are trying
  31661. * @param element define the dom element where to configure the cors policy
  31662. */
  31663. static SetCorsBehavior(url: string | string[], element: {
  31664. crossOrigin: string | null;
  31665. }): void;
  31666. /**
  31667. * Removes unwanted characters from an url
  31668. * @param url defines the url to clean
  31669. * @returns the cleaned url
  31670. */
  31671. static CleanUrl(url: string): string;
  31672. /**
  31673. * Gets or sets a function used to pre-process url before using them to load assets
  31674. */
  31675. static PreprocessUrl: (url: string) => string;
  31676. /**
  31677. * Loads an image as an HTMLImageElement.
  31678. * @param input url string, ArrayBuffer, or Blob to load
  31679. * @param onLoad callback called when the image successfully loads
  31680. * @param onError callback called when the image fails to load
  31681. * @param offlineProvider offline provider for caching
  31682. * @returns the HTMLImageElement of the loaded image
  31683. */
  31684. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31685. /**
  31686. * Loads a file
  31687. * @param url url string, ArrayBuffer, or Blob to load
  31688. * @param onSuccess callback called when the file successfully loads
  31689. * @param onProgress callback called while file is loading (if the server supports this mode)
  31690. * @param offlineProvider defines the offline provider for caching
  31691. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31692. * @param onError callback called when the file fails to load
  31693. * @returns a file request object
  31694. */
  31695. 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;
  31696. /**
  31697. * Load a script (identified by an url). When the url returns, the
  31698. * content of this file is added into a new script element, attached to the DOM (body element)
  31699. * @param scriptUrl defines the url of the script to laod
  31700. * @param onSuccess defines the callback called when the script is loaded
  31701. * @param onError defines the callback to call if an error occurs
  31702. * @param scriptId defines the id of the script element
  31703. */
  31704. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31705. /**
  31706. * Load an asynchronous script (identified by an url). When the url returns, the
  31707. * content of this file is added into a new script element, attached to the DOM (body element)
  31708. * @param scriptUrl defines the url of the script to laod
  31709. * @param scriptId defines the id of the script element
  31710. * @returns a promise request object
  31711. */
  31712. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31713. /**
  31714. * Loads a file from a blob
  31715. * @param fileToLoad defines the blob to use
  31716. * @param callback defines the callback to call when data is loaded
  31717. * @param progressCallback defines the callback to call during loading process
  31718. * @returns a file request object
  31719. */
  31720. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31721. /**
  31722. * Loads a file
  31723. * @param fileToLoad defines the file to load
  31724. * @param callback defines the callback to call when data is loaded
  31725. * @param progressCallBack defines the callback to call during loading process
  31726. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31727. * @returns a file request object
  31728. */
  31729. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31730. /**
  31731. * Creates a data url from a given string content
  31732. * @param content defines the content to convert
  31733. * @returns the new data url link
  31734. */
  31735. static FileAsURL(content: string): string;
  31736. /**
  31737. * Format the given number to a specific decimal format
  31738. * @param value defines the number to format
  31739. * @param decimals defines the number of decimals to use
  31740. * @returns the formatted string
  31741. */
  31742. static Format(value: number, decimals?: number): string;
  31743. /**
  31744. * Checks if a given vector is inside a specific range
  31745. * @param v defines the vector to test
  31746. * @param min defines the minimum range
  31747. * @param max defines the maximum range
  31748. */
  31749. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31750. /**
  31751. * Tries to copy an object by duplicating every property
  31752. * @param source defines the source object
  31753. * @param destination defines the target object
  31754. * @param doNotCopyList defines a list of properties to avoid
  31755. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31756. */
  31757. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31758. /**
  31759. * Gets a boolean indicating if the given object has no own property
  31760. * @param obj defines the object to test
  31761. * @returns true if object has no own property
  31762. */
  31763. static IsEmpty(obj: any): boolean;
  31764. /**
  31765. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31766. * @param str Source string
  31767. * @param suffix Suffix to search for in the source string
  31768. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31769. */
  31770. static EndsWith(str: string, suffix: string): boolean;
  31771. /**
  31772. * Function used to register events at window level
  31773. * @param events defines the events to register
  31774. */
  31775. static RegisterTopRootEvents(events: {
  31776. name: string;
  31777. handler: Nullable<(e: FocusEvent) => any>;
  31778. }[]): void;
  31779. /**
  31780. * Function used to unregister events from window level
  31781. * @param events defines the events to unregister
  31782. */
  31783. static UnregisterTopRootEvents(events: {
  31784. name: string;
  31785. handler: Nullable<(e: FocusEvent) => any>;
  31786. }[]): void;
  31787. /**
  31788. * @ignore
  31789. */
  31790. static _ScreenshotCanvas: HTMLCanvasElement;
  31791. /**
  31792. * Dumps the current bound framebuffer
  31793. * @param width defines the rendering width
  31794. * @param height defines the rendering height
  31795. * @param engine defines the hosting engine
  31796. * @param successCallback defines the callback triggered once the data are available
  31797. * @param mimeType defines the mime type of the result
  31798. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31799. */
  31800. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31801. /**
  31802. * Converts the canvas data to blob.
  31803. * This acts as a polyfill for browsers not supporting the to blob function.
  31804. * @param canvas Defines the canvas to extract the data from
  31805. * @param successCallback Defines the callback triggered once the data are available
  31806. * @param mimeType Defines the mime type of the result
  31807. */
  31808. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31809. /**
  31810. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31811. * @param successCallback defines the callback triggered once the data are available
  31812. * @param mimeType defines the mime type of the result
  31813. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31814. */
  31815. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31816. /**
  31817. * Downloads a blob in the browser
  31818. * @param blob defines the blob to download
  31819. * @param fileName defines the name of the downloaded file
  31820. */
  31821. static Download(blob: Blob, fileName: string): void;
  31822. /**
  31823. * Captures a screenshot of the current rendering
  31824. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31825. * @param engine defines the rendering engine
  31826. * @param camera defines the source camera
  31827. * @param size This parameter can be set to a single number or to an object with the
  31828. * following (optional) properties: precision, width, height. If a single number is passed,
  31829. * it will be used for both width and height. If an object is passed, the screenshot size
  31830. * will be derived from the parameters. The precision property is a multiplier allowing
  31831. * rendering at a higher or lower resolution
  31832. * @param successCallback defines the callback receives a single parameter which contains the
  31833. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31834. * src parameter of an <img> to display it
  31835. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31836. * Check your browser for supported MIME types
  31837. */
  31838. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31839. /**
  31840. * Generates an image screenshot from the specified camera.
  31841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31842. * @param engine The engine to use for rendering
  31843. * @param camera The camera to use for rendering
  31844. * @param size This parameter can be set to a single number or to an object with the
  31845. * following (optional) properties: precision, width, height. If a single number is passed,
  31846. * it will be used for both width and height. If an object is passed, the screenshot size
  31847. * will be derived from the parameters. The precision property is a multiplier allowing
  31848. * rendering at a higher or lower resolution
  31849. * @param successCallback The callback receives a single parameter which contains the
  31850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31851. * src parameter of an <img> to display it
  31852. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31853. * Check your browser for supported MIME types
  31854. * @param samples Texture samples (default: 1)
  31855. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31856. * @param fileName A name for for the downloaded file.
  31857. */
  31858. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31859. /**
  31860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31861. * Be aware Math.random() could cause collisions, but:
  31862. * "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"
  31863. * @returns a pseudo random id
  31864. */
  31865. static RandomId(): string;
  31866. /**
  31867. * Test if the given uri is a base64 string
  31868. * @param uri The uri to test
  31869. * @return True if the uri is a base64 string or false otherwise
  31870. */
  31871. static IsBase64(uri: string): boolean;
  31872. /**
  31873. * Decode the given base64 uri.
  31874. * @param uri The uri to decode
  31875. * @return The decoded base64 data.
  31876. */
  31877. static DecodeBase64(uri: string): ArrayBuffer;
  31878. /**
  31879. * No log
  31880. */
  31881. static readonly NoneLogLevel: number;
  31882. /**
  31883. * Only message logs
  31884. */
  31885. static readonly MessageLogLevel: number;
  31886. /**
  31887. * Only warning logs
  31888. */
  31889. static readonly WarningLogLevel: number;
  31890. /**
  31891. * Only error logs
  31892. */
  31893. static readonly ErrorLogLevel: number;
  31894. /**
  31895. * All logs
  31896. */
  31897. static readonly AllLogLevel: number;
  31898. /**
  31899. * Gets a value indicating the number of loading errors
  31900. * @ignorenaming
  31901. */
  31902. static readonly errorsCount: number;
  31903. /**
  31904. * Callback called when a new log is added
  31905. */
  31906. static OnNewCacheEntry: (entry: string) => void;
  31907. /**
  31908. * Log a message to the console
  31909. * @param message defines the message to log
  31910. */
  31911. static Log(message: string): void;
  31912. /**
  31913. * Write a warning message to the console
  31914. * @param message defines the message to log
  31915. */
  31916. static Warn(message: string): void;
  31917. /**
  31918. * Write an error message to the console
  31919. * @param message defines the message to log
  31920. */
  31921. static Error(message: string): void;
  31922. /**
  31923. * Gets current log cache (list of logs)
  31924. */
  31925. static readonly LogCache: string;
  31926. /**
  31927. * Clears the log cache
  31928. */
  31929. static ClearLogCache(): void;
  31930. /**
  31931. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31932. */
  31933. static LogLevels: number;
  31934. /**
  31935. * Checks if the loaded document was accessed via `file:`-Protocol.
  31936. * @returns boolean
  31937. */
  31938. static IsFileURL(): boolean;
  31939. /**
  31940. * Checks if the window object exists
  31941. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31942. */
  31943. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31944. /**
  31945. * No performance log
  31946. */
  31947. static readonly PerformanceNoneLogLevel: number;
  31948. /**
  31949. * Use user marks to log performance
  31950. */
  31951. static readonly PerformanceUserMarkLogLevel: number;
  31952. /**
  31953. * Log performance to the console
  31954. */
  31955. static readonly PerformanceConsoleLogLevel: number;
  31956. private static _performance;
  31957. /**
  31958. * Sets the current performance log level
  31959. */
  31960. static PerformanceLogLevel: number;
  31961. private static _StartPerformanceCounterDisabled;
  31962. private static _EndPerformanceCounterDisabled;
  31963. private static _StartUserMark;
  31964. private static _EndUserMark;
  31965. private static _StartPerformanceConsole;
  31966. private static _EndPerformanceConsole;
  31967. /**
  31968. * Starts a performance counter
  31969. */
  31970. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31971. /**
  31972. * Ends a specific performance coutner
  31973. */
  31974. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31975. /**
  31976. * Gets either window.performance.now() if supported or Date.now() else
  31977. */
  31978. static readonly Now: number;
  31979. /**
  31980. * This method will return the name of the class used to create the instance of the given object.
  31981. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31982. * @param object the object to get the class name from
  31983. * @param isType defines if the object is actually a type
  31984. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31985. */
  31986. static GetClassName(object: any, isType?: boolean): string;
  31987. /**
  31988. * Gets the first element of an array satisfying a given predicate
  31989. * @param array defines the array to browse
  31990. * @param predicate defines the predicate to use
  31991. * @returns null if not found or the element
  31992. */
  31993. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31994. /**
  31995. * This method will return the name of the full name of the class, including its owning module (if any).
  31996. * 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).
  31997. * @param object the object to get the class name from
  31998. * @param isType defines if the object is actually a type
  31999. * @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.
  32000. * @ignorenaming
  32001. */
  32002. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32003. /**
  32004. * Returns a promise that resolves after the given amount of time.
  32005. * @param delay Number of milliseconds to delay
  32006. * @returns Promise that resolves after the given amount of time
  32007. */
  32008. static DelayAsync(delay: number): Promise<void>;
  32009. /**
  32010. * Gets the current gradient from an array of IValueGradient
  32011. * @param ratio defines the current ratio to get
  32012. * @param gradients defines the array of IValueGradient
  32013. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32014. */
  32015. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32016. }
  32017. /**
  32018. * This class is used to track a performance counter which is number based.
  32019. * The user has access to many properties which give statistics of different nature.
  32020. *
  32021. * The implementer can track two kinds of Performance Counter: time and count.
  32022. * 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.
  32023. * 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.
  32024. */
  32025. export class PerfCounter {
  32026. /**
  32027. * Gets or sets a global boolean to turn on and off all the counters
  32028. */
  32029. static Enabled: boolean;
  32030. /**
  32031. * Returns the smallest value ever
  32032. */
  32033. readonly min: number;
  32034. /**
  32035. * Returns the biggest value ever
  32036. */
  32037. readonly max: number;
  32038. /**
  32039. * Returns the average value since the performance counter is running
  32040. */
  32041. readonly average: number;
  32042. /**
  32043. * Returns the average value of the last second the counter was monitored
  32044. */
  32045. readonly lastSecAverage: number;
  32046. /**
  32047. * Returns the current value
  32048. */
  32049. readonly current: number;
  32050. /**
  32051. * Gets the accumulated total
  32052. */
  32053. readonly total: number;
  32054. /**
  32055. * Gets the total value count
  32056. */
  32057. readonly count: number;
  32058. /**
  32059. * Creates a new counter
  32060. */
  32061. constructor();
  32062. /**
  32063. * Call this method to start monitoring a new frame.
  32064. * 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.
  32065. */
  32066. fetchNewFrame(): void;
  32067. /**
  32068. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32069. * @param newCount the count value to add to the monitored count
  32070. * @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.
  32071. */
  32072. addCount(newCount: number, fetchResult: boolean): void;
  32073. /**
  32074. * Start monitoring this performance counter
  32075. */
  32076. beginMonitoring(): void;
  32077. /**
  32078. * Compute the time lapsed since the previous beginMonitoring() call.
  32079. * @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
  32080. */
  32081. endMonitoring(newFrame?: boolean): void;
  32082. private _fetchResult;
  32083. private _startMonitoringTime;
  32084. private _min;
  32085. private _max;
  32086. private _average;
  32087. private _current;
  32088. private _totalValueCount;
  32089. private _totalAccumulated;
  32090. private _lastSecAverage;
  32091. private _lastSecAccumulated;
  32092. private _lastSecTime;
  32093. private _lastSecValueCount;
  32094. }
  32095. /**
  32096. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32097. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32098. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32099. * @param name The name of the class, case should be preserved
  32100. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32101. */
  32102. export function className(name: string, module?: string): (target: Object) => void;
  32103. /**
  32104. * An implementation of a loop for asynchronous functions.
  32105. */
  32106. export class AsyncLoop {
  32107. /**
  32108. * Defines the number of iterations for the loop
  32109. */
  32110. iterations: number;
  32111. /**
  32112. * Defines the current index of the loop.
  32113. */
  32114. index: number;
  32115. private _done;
  32116. private _fn;
  32117. private _successCallback;
  32118. /**
  32119. * Constructor.
  32120. * @param iterations the number of iterations.
  32121. * @param func the function to run each iteration
  32122. * @param successCallback the callback that will be called upon succesful execution
  32123. * @param offset starting offset.
  32124. */
  32125. constructor(
  32126. /**
  32127. * Defines the number of iterations for the loop
  32128. */
  32129. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32130. /**
  32131. * Execute the next iteration. Must be called after the last iteration was finished.
  32132. */
  32133. executeNext(): void;
  32134. /**
  32135. * Break the loop and run the success callback.
  32136. */
  32137. breakLoop(): void;
  32138. /**
  32139. * Create and run an async loop.
  32140. * @param iterations the number of iterations.
  32141. * @param fn the function to run each iteration
  32142. * @param successCallback the callback that will be called upon succesful execution
  32143. * @param offset starting offset.
  32144. * @returns the created async loop object
  32145. */
  32146. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32147. /**
  32148. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32149. * @param iterations total number of iterations
  32150. * @param syncedIterations number of synchronous iterations in each async iteration.
  32151. * @param fn the function to call each iteration.
  32152. * @param callback a success call back that will be called when iterating stops.
  32153. * @param breakFunction a break condition (optional)
  32154. * @param timeout timeout settings for the setTimeout function. default - 0.
  32155. * @returns the created async loop object
  32156. */
  32157. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32158. }
  32159. }
  32160. declare module "babylonjs/Collisions/collisionCoordinator" {
  32161. import { Nullable } from "babylonjs/types";
  32162. import { Scene } from "babylonjs/scene";
  32163. import { Vector3 } from "babylonjs/Maths/math";
  32164. import { Collider } from "babylonjs/Collisions/collider";
  32165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32166. /** @hidden */
  32167. export interface ICollisionCoordinator {
  32168. createCollider(): Collider;
  32169. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32170. init(scene: Scene): void;
  32171. }
  32172. /** @hidden */
  32173. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32174. private _scene;
  32175. private _scaledPosition;
  32176. private _scaledVelocity;
  32177. private _finalPosition;
  32178. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32179. createCollider(): Collider;
  32180. init(scene: Scene): void;
  32181. private _collideWithWorld;
  32182. }
  32183. }
  32184. declare module "babylonjs/Animations/animationGroup" {
  32185. import { Animatable } from "babylonjs/Animations/animatable";
  32186. import { Animation } from "babylonjs/Animations/animation";
  32187. import { Scene, IDisposable } from "babylonjs/scene";
  32188. import { Observable } from "babylonjs/Misc/observable";
  32189. import { Nullable } from "babylonjs/types";
  32190. /**
  32191. * This class defines the direct association between an animation and a target
  32192. */
  32193. export class TargetedAnimation {
  32194. /**
  32195. * Animation to perform
  32196. */
  32197. animation: Animation;
  32198. /**
  32199. * Target to animate
  32200. */
  32201. target: any;
  32202. }
  32203. /**
  32204. * Use this class to create coordinated animations on multiple targets
  32205. */
  32206. export class AnimationGroup implements IDisposable {
  32207. /** The name of the animation group */
  32208. name: string;
  32209. private _scene;
  32210. private _targetedAnimations;
  32211. private _animatables;
  32212. private _from;
  32213. private _to;
  32214. private _isStarted;
  32215. private _isPaused;
  32216. private _speedRatio;
  32217. /**
  32218. * Gets or sets the unique id of the node
  32219. */
  32220. uniqueId: number;
  32221. /**
  32222. * This observable will notify when one animation have ended
  32223. */
  32224. onAnimationEndObservable: Observable<TargetedAnimation>;
  32225. /**
  32226. * Observer raised when one animation loops
  32227. */
  32228. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32229. /**
  32230. * This observable will notify when all animations have ended.
  32231. */
  32232. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32233. /**
  32234. * This observable will notify when all animations have paused.
  32235. */
  32236. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32237. /**
  32238. * This observable will notify when all animations are playing.
  32239. */
  32240. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32241. /**
  32242. * Gets the first frame
  32243. */
  32244. readonly from: number;
  32245. /**
  32246. * Gets the last frame
  32247. */
  32248. readonly to: number;
  32249. /**
  32250. * Define if the animations are started
  32251. */
  32252. readonly isStarted: boolean;
  32253. /**
  32254. * Gets a value indicating that the current group is playing
  32255. */
  32256. readonly isPlaying: boolean;
  32257. /**
  32258. * Gets or sets the speed ratio to use for all animations
  32259. */
  32260. /**
  32261. * Gets or sets the speed ratio to use for all animations
  32262. */
  32263. speedRatio: number;
  32264. /**
  32265. * Gets the targeted animations for this animation group
  32266. */
  32267. readonly targetedAnimations: Array<TargetedAnimation>;
  32268. /**
  32269. * returning the list of animatables controlled by this animation group.
  32270. */
  32271. readonly animatables: Array<Animatable>;
  32272. /**
  32273. * Instantiates a new Animation Group.
  32274. * This helps managing several animations at once.
  32275. * @see http://doc.babylonjs.com/how_to/group
  32276. * @param name Defines the name of the group
  32277. * @param scene Defines the scene the group belongs to
  32278. */
  32279. constructor(
  32280. /** The name of the animation group */
  32281. name: string, scene?: Nullable<Scene>);
  32282. /**
  32283. * Add an animation (with its target) in the group
  32284. * @param animation defines the animation we want to add
  32285. * @param target defines the target of the animation
  32286. * @returns the TargetedAnimation object
  32287. */
  32288. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32289. /**
  32290. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32291. * It can add constant keys at begin or end
  32292. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32293. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32294. * @returns the animation group
  32295. */
  32296. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32297. /**
  32298. * Start all animations on given targets
  32299. * @param loop defines if animations must loop
  32300. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32301. * @param from defines the from key (optional)
  32302. * @param to defines the to key (optional)
  32303. * @returns the current animation group
  32304. */
  32305. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32306. /**
  32307. * Pause all animations
  32308. * @returns the animation group
  32309. */
  32310. pause(): AnimationGroup;
  32311. /**
  32312. * Play all animations to initial state
  32313. * This function will start() the animations if they were not started or will restart() them if they were paused
  32314. * @param loop defines if animations must loop
  32315. * @returns the animation group
  32316. */
  32317. play(loop?: boolean): AnimationGroup;
  32318. /**
  32319. * Reset all animations to initial state
  32320. * @returns the animation group
  32321. */
  32322. reset(): AnimationGroup;
  32323. /**
  32324. * Restart animations from key 0
  32325. * @returns the animation group
  32326. */
  32327. restart(): AnimationGroup;
  32328. /**
  32329. * Stop all animations
  32330. * @returns the animation group
  32331. */
  32332. stop(): AnimationGroup;
  32333. /**
  32334. * Set animation weight for all animatables
  32335. * @param weight defines the weight to use
  32336. * @return the animationGroup
  32337. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32338. */
  32339. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32340. /**
  32341. * Synchronize and normalize all animatables with a source animatable
  32342. * @param root defines the root animatable to synchronize with
  32343. * @return the animationGroup
  32344. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32345. */
  32346. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32347. /**
  32348. * Goes to a specific frame in this animation group
  32349. * @param frame the frame number to go to
  32350. * @return the animationGroup
  32351. */
  32352. goToFrame(frame: number): AnimationGroup;
  32353. /**
  32354. * Dispose all associated resources
  32355. */
  32356. dispose(): void;
  32357. private _checkAnimationGroupEnded;
  32358. /**
  32359. * Clone the current animation group and returns a copy
  32360. * @param newName defines the name of the new group
  32361. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32362. * @returns the new aniamtion group
  32363. */
  32364. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32365. /**
  32366. * Returns a new AnimationGroup object parsed from the source provided.
  32367. * @param parsedAnimationGroup defines the source
  32368. * @param scene defines the scene that will receive the animationGroup
  32369. * @returns a new AnimationGroup
  32370. */
  32371. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32372. /**
  32373. * Returns the string "AnimationGroup"
  32374. * @returns "AnimationGroup"
  32375. */
  32376. getClassName(): string;
  32377. /**
  32378. * Creates a detailled string about the object
  32379. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32380. * @returns a string representing the object
  32381. */
  32382. toString(fullDetails?: boolean): string;
  32383. }
  32384. }
  32385. declare module "babylonjs/scene" {
  32386. import { Nullable } from "babylonjs/types";
  32387. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32388. import { Observable } from "babylonjs/Misc/observable";
  32389. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32390. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32391. import { Geometry } from "babylonjs/Meshes/geometry";
  32392. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32395. import { Mesh } from "babylonjs/Meshes/mesh";
  32396. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32397. import { Bone } from "babylonjs/Bones/bone";
  32398. import { Skeleton } from "babylonjs/Bones/skeleton";
  32399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32400. import { Camera } from "babylonjs/Cameras/camera";
  32401. import { AbstractScene } from "babylonjs/abstractScene";
  32402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32404. import { Material } from "babylonjs/Materials/material";
  32405. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32406. import { Effect } from "babylonjs/Materials/effect";
  32407. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32408. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32409. import { Light } from "babylonjs/Lights/light";
  32410. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32411. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32412. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32413. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32415. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32416. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32417. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32418. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32419. import { Engine } from "babylonjs/Engines/engine";
  32420. import { Node } from "babylonjs/node";
  32421. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32423. import { WebRequest } from "babylonjs/Misc/webRequest";
  32424. import { Ray } from "babylonjs/Culling/ray";
  32425. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32426. import { Animation } from "babylonjs/Animations/animation";
  32427. import { Animatable } from "babylonjs/Animations/animatable";
  32428. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32429. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32430. import { Collider } from "babylonjs/Collisions/collider";
  32431. /**
  32432. * Define an interface for all classes that will hold resources
  32433. */
  32434. export interface IDisposable {
  32435. /**
  32436. * Releases all held resources
  32437. */
  32438. dispose(): void;
  32439. }
  32440. /** Interface defining initialization parameters for Scene class */
  32441. export interface SceneOptions {
  32442. /**
  32443. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32444. * It will improve performance when the number of geometries becomes important.
  32445. */
  32446. useGeometryUniqueIdsMap?: boolean;
  32447. /**
  32448. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32449. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32450. */
  32451. useMaterialMeshMap?: boolean;
  32452. /**
  32453. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32454. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32455. */
  32456. useClonedMeshhMap?: boolean;
  32457. }
  32458. /**
  32459. * Represents a scene to be rendered by the engine.
  32460. * @see http://doc.babylonjs.com/features/scene
  32461. */
  32462. export class Scene extends AbstractScene implements IAnimatable {
  32463. private static _uniqueIdCounter;
  32464. /** The fog is deactivated */
  32465. static readonly FOGMODE_NONE: number;
  32466. /** The fog density is following an exponential function */
  32467. static readonly FOGMODE_EXP: number;
  32468. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32469. static readonly FOGMODE_EXP2: number;
  32470. /** The fog density is following a linear function. */
  32471. static readonly FOGMODE_LINEAR: number;
  32472. /**
  32473. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32475. */
  32476. static MinDeltaTime: number;
  32477. /**
  32478. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32480. */
  32481. static MaxDeltaTime: number;
  32482. /**
  32483. * Factory used to create the default material.
  32484. * @param name The name of the material to create
  32485. * @param scene The scene to create the material for
  32486. * @returns The default material
  32487. */
  32488. static DefaultMaterialFactory(scene: Scene): Material;
  32489. /**
  32490. * Factory used to create the a collision coordinator.
  32491. * @returns The collision coordinator
  32492. */
  32493. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32494. /** @hidden */
  32495. readonly _isScene: boolean;
  32496. /**
  32497. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32498. */
  32499. autoClear: boolean;
  32500. /**
  32501. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32502. */
  32503. autoClearDepthAndStencil: boolean;
  32504. /**
  32505. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32506. */
  32507. clearColor: Color4;
  32508. /**
  32509. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32510. */
  32511. ambientColor: Color3;
  32512. /**
  32513. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32514. * It should only be one of the following (if not the default embedded one):
  32515. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32516. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32517. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32518. * The material properties need to be setup according to the type of texture in use.
  32519. */
  32520. environmentBRDFTexture: BaseTexture;
  32521. /** @hidden */
  32522. protected _environmentTexture: Nullable<BaseTexture>;
  32523. /**
  32524. * Texture used in all pbr material as the reflection texture.
  32525. * As in the majority of the scene they are the same (exception for multi room and so on),
  32526. * this is easier to reference from here than from all the materials.
  32527. */
  32528. /**
  32529. * Texture used in all pbr material as the reflection texture.
  32530. * As in the majority of the scene they are the same (exception for multi room and so on),
  32531. * this is easier to set here than in all the materials.
  32532. */
  32533. environmentTexture: Nullable<BaseTexture>;
  32534. /** @hidden */
  32535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32536. /**
  32537. * Default image processing configuration used either in the rendering
  32538. * Forward main pass or through the imageProcessingPostProcess if present.
  32539. * As in the majority of the scene they are the same (exception for multi camera),
  32540. * this is easier to reference from here than from all the materials and post process.
  32541. *
  32542. * No setter as we it is a shared configuration, you can set the values instead.
  32543. */
  32544. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32545. private _forceWireframe;
  32546. /**
  32547. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32548. */
  32549. forceWireframe: boolean;
  32550. private _forcePointsCloud;
  32551. /**
  32552. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32553. */
  32554. forcePointsCloud: boolean;
  32555. /**
  32556. * Gets or sets the active clipplane 1
  32557. */
  32558. clipPlane: Nullable<Plane>;
  32559. /**
  32560. * Gets or sets the active clipplane 2
  32561. */
  32562. clipPlane2: Nullable<Plane>;
  32563. /**
  32564. * Gets or sets the active clipplane 3
  32565. */
  32566. clipPlane3: Nullable<Plane>;
  32567. /**
  32568. * Gets or sets the active clipplane 4
  32569. */
  32570. clipPlane4: Nullable<Plane>;
  32571. /**
  32572. * Gets or sets a boolean indicating if animations are enabled
  32573. */
  32574. animationsEnabled: boolean;
  32575. private _animationPropertiesOverride;
  32576. /**
  32577. * Gets or sets the animation properties override
  32578. */
  32579. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32580. /**
  32581. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32582. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32583. */
  32584. useConstantAnimationDeltaTime: boolean;
  32585. /**
  32586. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32587. * Please note that it requires to run a ray cast through the scene on every frame
  32588. */
  32589. constantlyUpdateMeshUnderPointer: boolean;
  32590. /**
  32591. * Defines the HTML cursor to use when hovering over interactive elements
  32592. */
  32593. hoverCursor: string;
  32594. /**
  32595. * Defines the HTML default cursor to use (empty by default)
  32596. */
  32597. defaultCursor: string;
  32598. /**
  32599. * This is used to call preventDefault() on pointer down
  32600. * in order to block unwanted artifacts like system double clicks
  32601. */
  32602. preventDefaultOnPointerDown: boolean;
  32603. /**
  32604. * This is used to call preventDefault() on pointer up
  32605. * in order to block unwanted artifacts like system double clicks
  32606. */
  32607. preventDefaultOnPointerUp: boolean;
  32608. /**
  32609. * Gets or sets user defined metadata
  32610. */
  32611. metadata: any;
  32612. /**
  32613. * For internal use only. Please do not use.
  32614. */
  32615. reservedDataStore: any;
  32616. /**
  32617. * Gets the name of the plugin used to load this scene (null by default)
  32618. */
  32619. loadingPluginName: string;
  32620. /**
  32621. * Use this array to add regular expressions used to disable offline support for specific urls
  32622. */
  32623. disableOfflineSupportExceptionRules: RegExp[];
  32624. /**
  32625. * An event triggered when the scene is disposed.
  32626. */
  32627. onDisposeObservable: Observable<Scene>;
  32628. private _onDisposeObserver;
  32629. /** Sets a function to be executed when this scene is disposed. */
  32630. onDispose: () => void;
  32631. /**
  32632. * An event triggered before rendering the scene (right after animations and physics)
  32633. */
  32634. onBeforeRenderObservable: Observable<Scene>;
  32635. private _onBeforeRenderObserver;
  32636. /** Sets a function to be executed before rendering this scene */
  32637. beforeRender: Nullable<() => void>;
  32638. /**
  32639. * An event triggered after rendering the scene
  32640. */
  32641. onAfterRenderObservable: Observable<Scene>;
  32642. private _onAfterRenderObserver;
  32643. /** Sets a function to be executed after rendering this scene */
  32644. afterRender: Nullable<() => void>;
  32645. /**
  32646. * An event triggered before animating the scene
  32647. */
  32648. onBeforeAnimationsObservable: Observable<Scene>;
  32649. /**
  32650. * An event triggered after animations processing
  32651. */
  32652. onAfterAnimationsObservable: Observable<Scene>;
  32653. /**
  32654. * An event triggered before draw calls are ready to be sent
  32655. */
  32656. onBeforeDrawPhaseObservable: Observable<Scene>;
  32657. /**
  32658. * An event triggered after draw calls have been sent
  32659. */
  32660. onAfterDrawPhaseObservable: Observable<Scene>;
  32661. /**
  32662. * An event triggered when the scene is ready
  32663. */
  32664. onReadyObservable: Observable<Scene>;
  32665. /**
  32666. * An event triggered before rendering a camera
  32667. */
  32668. onBeforeCameraRenderObservable: Observable<Camera>;
  32669. private _onBeforeCameraRenderObserver;
  32670. /** Sets a function to be executed before rendering a camera*/
  32671. beforeCameraRender: () => void;
  32672. /**
  32673. * An event triggered after rendering a camera
  32674. */
  32675. onAfterCameraRenderObservable: Observable<Camera>;
  32676. private _onAfterCameraRenderObserver;
  32677. /** Sets a function to be executed after rendering a camera*/
  32678. afterCameraRender: () => void;
  32679. /**
  32680. * An event triggered when active meshes evaluation is about to start
  32681. */
  32682. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32683. /**
  32684. * An event triggered when active meshes evaluation is done
  32685. */
  32686. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32687. /**
  32688. * An event triggered when particles rendering is about to start
  32689. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32690. */
  32691. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32692. /**
  32693. * An event triggered when particles rendering is done
  32694. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32695. */
  32696. onAfterParticlesRenderingObservable: Observable<Scene>;
  32697. /**
  32698. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32699. */
  32700. onDataLoadedObservable: Observable<Scene>;
  32701. /**
  32702. * An event triggered when a camera is created
  32703. */
  32704. onNewCameraAddedObservable: Observable<Camera>;
  32705. /**
  32706. * An event triggered when a camera is removed
  32707. */
  32708. onCameraRemovedObservable: Observable<Camera>;
  32709. /**
  32710. * An event triggered when a light is created
  32711. */
  32712. onNewLightAddedObservable: Observable<Light>;
  32713. /**
  32714. * An event triggered when a light is removed
  32715. */
  32716. onLightRemovedObservable: Observable<Light>;
  32717. /**
  32718. * An event triggered when a geometry is created
  32719. */
  32720. onNewGeometryAddedObservable: Observable<Geometry>;
  32721. /**
  32722. * An event triggered when a geometry is removed
  32723. */
  32724. onGeometryRemovedObservable: Observable<Geometry>;
  32725. /**
  32726. * An event triggered when a transform node is created
  32727. */
  32728. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32729. /**
  32730. * An event triggered when a transform node is removed
  32731. */
  32732. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32733. /**
  32734. * An event triggered when a mesh is created
  32735. */
  32736. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32737. /**
  32738. * An event triggered when a mesh is removed
  32739. */
  32740. onMeshRemovedObservable: Observable<AbstractMesh>;
  32741. /**
  32742. * An event triggered when a skeleton is created
  32743. */
  32744. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32745. /**
  32746. * An event triggered when a skeleton is removed
  32747. */
  32748. onSkeletonRemovedObservable: Observable<Skeleton>;
  32749. /**
  32750. * An event triggered when a material is created
  32751. */
  32752. onNewMaterialAddedObservable: Observable<Material>;
  32753. /**
  32754. * An event triggered when a material is removed
  32755. */
  32756. onMaterialRemovedObservable: Observable<Material>;
  32757. /**
  32758. * An event triggered when a texture is created
  32759. */
  32760. onNewTextureAddedObservable: Observable<BaseTexture>;
  32761. /**
  32762. * An event triggered when a texture is removed
  32763. */
  32764. onTextureRemovedObservable: Observable<BaseTexture>;
  32765. /**
  32766. * An event triggered when render targets are about to be rendered
  32767. * Can happen multiple times per frame.
  32768. */
  32769. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32770. /**
  32771. * An event triggered when render targets were rendered.
  32772. * Can happen multiple times per frame.
  32773. */
  32774. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered before calculating deterministic simulation step
  32777. */
  32778. onBeforeStepObservable: Observable<Scene>;
  32779. /**
  32780. * An event triggered after calculating deterministic simulation step
  32781. */
  32782. onAfterStepObservable: Observable<Scene>;
  32783. /**
  32784. * An event triggered when the activeCamera property is updated
  32785. */
  32786. onActiveCameraChanged: Observable<Scene>;
  32787. /**
  32788. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32789. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32790. * 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)
  32791. */
  32792. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32793. /**
  32794. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32795. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32796. * 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)
  32797. */
  32798. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32799. /**
  32800. * This Observable will when a mesh has been imported into the scene.
  32801. */
  32802. onMeshImportedObservable: Observable<AbstractMesh>;
  32803. /**
  32804. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32805. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32806. */
  32807. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32808. /** @hidden */
  32809. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32810. /**
  32811. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32812. */
  32813. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32814. /**
  32815. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32816. */
  32817. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32818. /**
  32819. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32820. */
  32821. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32822. private _onPointerMove;
  32823. private _onPointerDown;
  32824. private _onPointerUp;
  32825. /** Callback called when a pointer move is detected */
  32826. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32827. /** Callback called when a pointer down is detected */
  32828. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32829. /** Callback called when a pointer up is detected */
  32830. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32831. /** Callback called when a pointer pick is detected */
  32832. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32833. /**
  32834. * 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).
  32835. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32836. */
  32837. onPrePointerObservable: Observable<PointerInfoPre>;
  32838. /**
  32839. * Observable event triggered each time an input event is received from the rendering canvas
  32840. */
  32841. onPointerObservable: Observable<PointerInfo>;
  32842. /**
  32843. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32844. */
  32845. readonly unTranslatedPointer: Vector2;
  32846. /** The distance in pixel that you have to move to prevent some events */
  32847. static DragMovementThreshold: number;
  32848. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32849. static LongPressDelay: number;
  32850. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32851. static DoubleClickDelay: number;
  32852. /** If you need to check double click without raising a single click at first click, enable this flag */
  32853. static ExclusiveDoubleClickMode: boolean;
  32854. private _initClickEvent;
  32855. private _initActionManager;
  32856. private _delayedSimpleClick;
  32857. private _delayedSimpleClickTimeout;
  32858. private _previousDelayedSimpleClickTimeout;
  32859. private _meshPickProceed;
  32860. private _previousButtonPressed;
  32861. private _currentPickResult;
  32862. private _previousPickResult;
  32863. private _totalPointersPressed;
  32864. private _doubleClickOccured;
  32865. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32866. cameraToUseForPointers: Nullable<Camera>;
  32867. private _pointerX;
  32868. private _pointerY;
  32869. private _unTranslatedPointerX;
  32870. private _unTranslatedPointerY;
  32871. private _startingPointerPosition;
  32872. private _previousStartingPointerPosition;
  32873. private _startingPointerTime;
  32874. private _previousStartingPointerTime;
  32875. private _pointerCaptures;
  32876. private _timeAccumulator;
  32877. private _currentStepId;
  32878. private _currentInternalStep;
  32879. /** @hidden */
  32880. _mirroredCameraPosition: Nullable<Vector3>;
  32881. /**
  32882. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32883. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32884. */
  32885. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32886. /**
  32887. * Observable event triggered each time an keyboard event is received from the hosting window
  32888. */
  32889. onKeyboardObservable: Observable<KeyboardInfo>;
  32890. private _onKeyDown;
  32891. private _onKeyUp;
  32892. private _onCanvasFocusObserver;
  32893. private _onCanvasBlurObserver;
  32894. private _useRightHandedSystem;
  32895. /**
  32896. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32897. */
  32898. useRightHandedSystem: boolean;
  32899. /**
  32900. * Sets the step Id used by deterministic lock step
  32901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32902. * @param newStepId defines the step Id
  32903. */
  32904. setStepId(newStepId: number): void;
  32905. /**
  32906. * Gets the step Id used by deterministic lock step
  32907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32908. * @returns the step Id
  32909. */
  32910. getStepId(): number;
  32911. /**
  32912. * Gets the internal step used by deterministic lock step
  32913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32914. * @returns the internal step
  32915. */
  32916. getInternalStep(): number;
  32917. private _fogEnabled;
  32918. /**
  32919. * Gets or sets a boolean indicating if fog is enabled on this scene
  32920. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32921. * (Default is true)
  32922. */
  32923. fogEnabled: boolean;
  32924. private _fogMode;
  32925. /**
  32926. * Gets or sets the fog mode to use
  32927. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32928. * | mode | value |
  32929. * | --- | --- |
  32930. * | FOGMODE_NONE | 0 |
  32931. * | FOGMODE_EXP | 1 |
  32932. * | FOGMODE_EXP2 | 2 |
  32933. * | FOGMODE_LINEAR | 3 |
  32934. */
  32935. fogMode: number;
  32936. /**
  32937. * Gets or sets the fog color to use
  32938. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32939. * (Default is Color3(0.2, 0.2, 0.3))
  32940. */
  32941. fogColor: Color3;
  32942. /**
  32943. * Gets or sets the fog density to use
  32944. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32945. * (Default is 0.1)
  32946. */
  32947. fogDensity: number;
  32948. /**
  32949. * Gets or sets the fog start distance to use
  32950. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32951. * (Default is 0)
  32952. */
  32953. fogStart: number;
  32954. /**
  32955. * Gets or sets the fog end distance to use
  32956. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32957. * (Default is 1000)
  32958. */
  32959. fogEnd: number;
  32960. private _shadowsEnabled;
  32961. /**
  32962. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32963. */
  32964. shadowsEnabled: boolean;
  32965. private _lightsEnabled;
  32966. /**
  32967. * Gets or sets a boolean indicating if lights are enabled on this scene
  32968. */
  32969. lightsEnabled: boolean;
  32970. /** All of the active cameras added to this scene. */
  32971. activeCameras: Camera[];
  32972. /** @hidden */
  32973. _activeCamera: Nullable<Camera>;
  32974. /** Gets or sets the current active camera */
  32975. activeCamera: Nullable<Camera>;
  32976. private _defaultMaterial;
  32977. /** The default material used on meshes when no material is affected */
  32978. /** The default material used on meshes when no material is affected */
  32979. defaultMaterial: Material;
  32980. private _texturesEnabled;
  32981. /**
  32982. * Gets or sets a boolean indicating if textures are enabled on this scene
  32983. */
  32984. texturesEnabled: boolean;
  32985. /**
  32986. * Gets or sets a boolean indicating if particles are enabled on this scene
  32987. */
  32988. particlesEnabled: boolean;
  32989. /**
  32990. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32991. */
  32992. spritesEnabled: boolean;
  32993. private _skeletonsEnabled;
  32994. /**
  32995. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32996. */
  32997. skeletonsEnabled: boolean;
  32998. /**
  32999. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33000. */
  33001. lensFlaresEnabled: boolean;
  33002. /**
  33003. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33005. */
  33006. collisionsEnabled: boolean;
  33007. private _collisionCoordinator;
  33008. /** @hidden */
  33009. readonly collisionCoordinator: ICollisionCoordinator;
  33010. /**
  33011. * Defines the gravity applied to this scene (used only for collisions)
  33012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33013. */
  33014. gravity: Vector3;
  33015. /**
  33016. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33017. */
  33018. postProcessesEnabled: boolean;
  33019. /**
  33020. * The list of postprocesses added to the scene
  33021. */
  33022. postProcesses: PostProcess[];
  33023. /**
  33024. * Gets the current postprocess manager
  33025. */
  33026. postProcessManager: PostProcessManager;
  33027. /**
  33028. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33029. */
  33030. renderTargetsEnabled: boolean;
  33031. /**
  33032. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33033. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33034. */
  33035. dumpNextRenderTargets: boolean;
  33036. /**
  33037. * The list of user defined render targets added to the scene
  33038. */
  33039. customRenderTargets: RenderTargetTexture[];
  33040. /**
  33041. * Defines if texture loading must be delayed
  33042. * If true, textures will only be loaded when they need to be rendered
  33043. */
  33044. useDelayedTextureLoading: boolean;
  33045. /**
  33046. * Gets the list of meshes imported to the scene through SceneLoader
  33047. */
  33048. importedMeshesFiles: String[];
  33049. /**
  33050. * Gets or sets a boolean indicating if probes are enabled on this scene
  33051. */
  33052. probesEnabled: boolean;
  33053. /**
  33054. * Gets or sets the current offline provider to use to store scene data
  33055. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33056. */
  33057. offlineProvider: IOfflineProvider;
  33058. /**
  33059. * Gets or sets the action manager associated with the scene
  33060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33061. */
  33062. actionManager: AbstractActionManager;
  33063. private _meshesForIntersections;
  33064. /**
  33065. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33066. */
  33067. proceduralTexturesEnabled: boolean;
  33068. private _engine;
  33069. private _totalVertices;
  33070. /** @hidden */
  33071. _activeIndices: PerfCounter;
  33072. /** @hidden */
  33073. _activeParticles: PerfCounter;
  33074. /** @hidden */
  33075. _activeBones: PerfCounter;
  33076. private _animationRatio;
  33077. /** @hidden */
  33078. _animationTimeLast: number;
  33079. /** @hidden */
  33080. _animationTime: number;
  33081. /**
  33082. * Gets or sets a general scale for animation speed
  33083. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33084. */
  33085. animationTimeScale: number;
  33086. /** @hidden */
  33087. _cachedMaterial: Nullable<Material>;
  33088. /** @hidden */
  33089. _cachedEffect: Nullable<Effect>;
  33090. /** @hidden */
  33091. _cachedVisibility: Nullable<number>;
  33092. private _renderId;
  33093. private _frameId;
  33094. private _executeWhenReadyTimeoutId;
  33095. private _intermediateRendering;
  33096. private _viewUpdateFlag;
  33097. private _projectionUpdateFlag;
  33098. /** @hidden */
  33099. _toBeDisposed: Nullable<IDisposable>[];
  33100. private _activeRequests;
  33101. /** @hidden */
  33102. _pendingData: any[];
  33103. private _isDisposed;
  33104. /**
  33105. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33106. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33107. */
  33108. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33109. private _activeMeshes;
  33110. private _processedMaterials;
  33111. private _renderTargets;
  33112. /** @hidden */
  33113. _activeParticleSystems: SmartArray<IParticleSystem>;
  33114. private _activeSkeletons;
  33115. private _softwareSkinnedMeshes;
  33116. private _renderingManager;
  33117. /** @hidden */
  33118. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33119. private _transformMatrix;
  33120. private _sceneUbo;
  33121. /** @hidden */
  33122. _viewMatrix: Matrix;
  33123. private _projectionMatrix;
  33124. private _wheelEventName;
  33125. /** @hidden */
  33126. _forcedViewPosition: Nullable<Vector3>;
  33127. /** @hidden */
  33128. _frustumPlanes: Plane[];
  33129. /**
  33130. * Gets the list of frustum planes (built from the active camera)
  33131. */
  33132. readonly frustumPlanes: Plane[];
  33133. /**
  33134. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33135. * This is useful if there are more lights that the maximum simulteanous authorized
  33136. */
  33137. requireLightSorting: boolean;
  33138. /** @hidden */
  33139. readonly useMaterialMeshMap: boolean;
  33140. /** @hidden */
  33141. readonly useClonedMeshhMap: boolean;
  33142. private _pointerOverMesh;
  33143. private _pickedDownMesh;
  33144. private _pickedUpMesh;
  33145. private _externalData;
  33146. private _uid;
  33147. /**
  33148. * @hidden
  33149. * Backing store of defined scene components.
  33150. */
  33151. _components: ISceneComponent[];
  33152. /**
  33153. * @hidden
  33154. * Backing store of defined scene components.
  33155. */
  33156. _serializableComponents: ISceneSerializableComponent[];
  33157. /**
  33158. * List of components to register on the next registration step.
  33159. */
  33160. private _transientComponents;
  33161. /**
  33162. * Registers the transient components if needed.
  33163. */
  33164. private _registerTransientComponents;
  33165. /**
  33166. * @hidden
  33167. * Add a component to the scene.
  33168. * Note that the ccomponent could be registered on th next frame if this is called after
  33169. * the register component stage.
  33170. * @param component Defines the component to add to the scene
  33171. */
  33172. _addComponent(component: ISceneComponent): void;
  33173. /**
  33174. * @hidden
  33175. * Gets a component from the scene.
  33176. * @param name defines the name of the component to retrieve
  33177. * @returns the component or null if not present
  33178. */
  33179. _getComponent(name: string): Nullable<ISceneComponent>;
  33180. /**
  33181. * @hidden
  33182. * Defines the actions happening before camera updates.
  33183. */
  33184. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33185. /**
  33186. * @hidden
  33187. * Defines the actions happening before clear the canvas.
  33188. */
  33189. _beforeClearStage: Stage<SimpleStageAction>;
  33190. /**
  33191. * @hidden
  33192. * Defines the actions when collecting render targets for the frame.
  33193. */
  33194. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33195. /**
  33196. * @hidden
  33197. * Defines the actions happening for one camera in the frame.
  33198. */
  33199. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33200. /**
  33201. * @hidden
  33202. * Defines the actions happening during the per mesh ready checks.
  33203. */
  33204. _isReadyForMeshStage: Stage<MeshStageAction>;
  33205. /**
  33206. * @hidden
  33207. * Defines the actions happening before evaluate active mesh checks.
  33208. */
  33209. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33210. /**
  33211. * @hidden
  33212. * Defines the actions happening during the evaluate sub mesh checks.
  33213. */
  33214. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33215. /**
  33216. * @hidden
  33217. * Defines the actions happening during the active mesh stage.
  33218. */
  33219. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33220. /**
  33221. * @hidden
  33222. * Defines the actions happening during the per camera render target step.
  33223. */
  33224. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33225. /**
  33226. * @hidden
  33227. * Defines the actions happening just before the active camera is drawing.
  33228. */
  33229. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33230. /**
  33231. * @hidden
  33232. * Defines the actions happening just before a render target is drawing.
  33233. */
  33234. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33235. /**
  33236. * @hidden
  33237. * Defines the actions happening just before a rendering group is drawing.
  33238. */
  33239. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33240. /**
  33241. * @hidden
  33242. * Defines the actions happening just before a mesh is drawing.
  33243. */
  33244. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33245. /**
  33246. * @hidden
  33247. * Defines the actions happening just after a mesh has been drawn.
  33248. */
  33249. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33250. /**
  33251. * @hidden
  33252. * Defines the actions happening just after a rendering group has been drawn.
  33253. */
  33254. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33255. /**
  33256. * @hidden
  33257. * Defines the actions happening just after the active camera has been drawn.
  33258. */
  33259. _afterCameraDrawStage: Stage<CameraStageAction>;
  33260. /**
  33261. * @hidden
  33262. * Defines the actions happening just after a render target has been drawn.
  33263. */
  33264. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33265. /**
  33266. * @hidden
  33267. * Defines the actions happening just after rendering all cameras and computing intersections.
  33268. */
  33269. _afterRenderStage: Stage<SimpleStageAction>;
  33270. /**
  33271. * @hidden
  33272. * Defines the actions happening when a pointer move event happens.
  33273. */
  33274. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33275. /**
  33276. * @hidden
  33277. * Defines the actions happening when a pointer down event happens.
  33278. */
  33279. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33280. /**
  33281. * @hidden
  33282. * Defines the actions happening when a pointer up event happens.
  33283. */
  33284. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33285. /**
  33286. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33287. */
  33288. private geometriesByUniqueId;
  33289. /**
  33290. * Creates a new Scene
  33291. * @param engine defines the engine to use to render this scene
  33292. * @param options defines the scene options
  33293. */
  33294. constructor(engine: Engine, options?: SceneOptions);
  33295. /**
  33296. * Gets a string idenfifying the name of the class
  33297. * @returns "Scene" string
  33298. */
  33299. getClassName(): string;
  33300. private _defaultMeshCandidates;
  33301. /**
  33302. * @hidden
  33303. */
  33304. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33305. private _defaultSubMeshCandidates;
  33306. /**
  33307. * @hidden
  33308. */
  33309. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33310. /**
  33311. * Sets the default candidate providers for the scene.
  33312. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33313. * and getCollidingSubMeshCandidates to their default function
  33314. */
  33315. setDefaultCandidateProviders(): void;
  33316. /**
  33317. * Gets the mesh that is currently under the pointer
  33318. */
  33319. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33320. /**
  33321. * Gets or sets the current on-screen X position of the pointer
  33322. */
  33323. pointerX: number;
  33324. /**
  33325. * Gets or sets the current on-screen Y position of the pointer
  33326. */
  33327. pointerY: number;
  33328. /**
  33329. * Gets the cached material (ie. the latest rendered one)
  33330. * @returns the cached material
  33331. */
  33332. getCachedMaterial(): Nullable<Material>;
  33333. /**
  33334. * Gets the cached effect (ie. the latest rendered one)
  33335. * @returns the cached effect
  33336. */
  33337. getCachedEffect(): Nullable<Effect>;
  33338. /**
  33339. * Gets the cached visibility state (ie. the latest rendered one)
  33340. * @returns the cached visibility state
  33341. */
  33342. getCachedVisibility(): Nullable<number>;
  33343. /**
  33344. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33345. * @param material defines the current material
  33346. * @param effect defines the current effect
  33347. * @param visibility defines the current visibility state
  33348. * @returns true if one parameter is not cached
  33349. */
  33350. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33351. /**
  33352. * Gets the engine associated with the scene
  33353. * @returns an Engine
  33354. */
  33355. getEngine(): Engine;
  33356. /**
  33357. * Gets the total number of vertices rendered per frame
  33358. * @returns the total number of vertices rendered per frame
  33359. */
  33360. getTotalVertices(): number;
  33361. /**
  33362. * Gets the performance counter for total vertices
  33363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33364. */
  33365. readonly totalVerticesPerfCounter: PerfCounter;
  33366. /**
  33367. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33368. * @returns the total number of active indices rendered per frame
  33369. */
  33370. getActiveIndices(): number;
  33371. /**
  33372. * Gets the performance counter for active indices
  33373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33374. */
  33375. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33376. /**
  33377. * Gets the total number of active particles rendered per frame
  33378. * @returns the total number of active particles rendered per frame
  33379. */
  33380. getActiveParticles(): number;
  33381. /**
  33382. * Gets the performance counter for active particles
  33383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33384. */
  33385. readonly activeParticlesPerfCounter: PerfCounter;
  33386. /**
  33387. * Gets the total number of active bones rendered per frame
  33388. * @returns the total number of active bones rendered per frame
  33389. */
  33390. getActiveBones(): number;
  33391. /**
  33392. * Gets the performance counter for active bones
  33393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33394. */
  33395. readonly activeBonesPerfCounter: PerfCounter;
  33396. /**
  33397. * Gets the array of active meshes
  33398. * @returns an array of AbstractMesh
  33399. */
  33400. getActiveMeshes(): SmartArray<AbstractMesh>;
  33401. /**
  33402. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33403. * @returns a number
  33404. */
  33405. getAnimationRatio(): number;
  33406. /**
  33407. * Gets an unique Id for the current render phase
  33408. * @returns a number
  33409. */
  33410. getRenderId(): number;
  33411. /**
  33412. * Gets an unique Id for the current frame
  33413. * @returns a number
  33414. */
  33415. getFrameId(): number;
  33416. /** Call this function if you want to manually increment the render Id*/
  33417. incrementRenderId(): void;
  33418. private _updatePointerPosition;
  33419. private _createUbo;
  33420. private _setRayOnPointerInfo;
  33421. /**
  33422. * Use this method to simulate a pointer move on a mesh
  33423. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33424. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33425. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33426. * @returns the current scene
  33427. */
  33428. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33429. private _processPointerMove;
  33430. private _checkPrePointerObservable;
  33431. /**
  33432. * Use this method to simulate a pointer down on a mesh
  33433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33436. * @returns the current scene
  33437. */
  33438. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33439. private _processPointerDown;
  33440. /**
  33441. * Use this method to simulate a pointer up on a mesh
  33442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33445. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33446. * @returns the current scene
  33447. */
  33448. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33449. private _processPointerUp;
  33450. /**
  33451. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33452. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33453. * @returns true if the pointer was captured
  33454. */
  33455. isPointerCaptured(pointerId?: number): boolean;
  33456. /** @hidden */
  33457. _isPointerSwiping(): boolean;
  33458. /**
  33459. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33460. * @param attachUp defines if you want to attach events to pointerup
  33461. * @param attachDown defines if you want to attach events to pointerdown
  33462. * @param attachMove defines if you want to attach events to pointermove
  33463. */
  33464. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33465. /** Detaches all event handlers*/
  33466. detachControl(): void;
  33467. /**
  33468. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33469. * Delay loaded resources are not taking in account
  33470. * @return true if all required resources are ready
  33471. */
  33472. isReady(): boolean;
  33473. /** Resets all cached information relative to material (including effect and visibility) */
  33474. resetCachedMaterial(): void;
  33475. /**
  33476. * Registers a function to be called before every frame render
  33477. * @param func defines the function to register
  33478. */
  33479. registerBeforeRender(func: () => void): void;
  33480. /**
  33481. * Unregisters a function called before every frame render
  33482. * @param func defines the function to unregister
  33483. */
  33484. unregisterBeforeRender(func: () => void): void;
  33485. /**
  33486. * Registers a function to be called after every frame render
  33487. * @param func defines the function to register
  33488. */
  33489. registerAfterRender(func: () => void): void;
  33490. /**
  33491. * Unregisters a function called after every frame render
  33492. * @param func defines the function to unregister
  33493. */
  33494. unregisterAfterRender(func: () => void): void;
  33495. private _executeOnceBeforeRender;
  33496. /**
  33497. * The provided function will run before render once and will be disposed afterwards.
  33498. * A timeout delay can be provided so that the function will be executed in N ms.
  33499. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33500. * @param func The function to be executed.
  33501. * @param timeout optional delay in ms
  33502. */
  33503. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33504. /** @hidden */
  33505. _addPendingData(data: any): void;
  33506. /** @hidden */
  33507. _removePendingData(data: any): void;
  33508. /**
  33509. * Returns the number of items waiting to be loaded
  33510. * @returns the number of items waiting to be loaded
  33511. */
  33512. getWaitingItemsCount(): number;
  33513. /**
  33514. * Returns a boolean indicating if the scene is still loading data
  33515. */
  33516. readonly isLoading: boolean;
  33517. /**
  33518. * Registers a function to be executed when the scene is ready
  33519. * @param {Function} func - the function to be executed
  33520. */
  33521. executeWhenReady(func: () => void): void;
  33522. /**
  33523. * Returns a promise that resolves when the scene is ready
  33524. * @returns A promise that resolves when the scene is ready
  33525. */
  33526. whenReadyAsync(): Promise<void>;
  33527. /** @hidden */
  33528. _checkIsReady(): void;
  33529. /**
  33530. * Gets all animatable attached to the scene
  33531. */
  33532. readonly animatables: Animatable[];
  33533. /**
  33534. * Resets the last animation time frame.
  33535. * Useful to override when animations start running when loading a scene for the first time.
  33536. */
  33537. resetLastAnimationTimeFrame(): void;
  33538. /**
  33539. * Gets the current view matrix
  33540. * @returns a Matrix
  33541. */
  33542. getViewMatrix(): Matrix;
  33543. /**
  33544. * Gets the current projection matrix
  33545. * @returns a Matrix
  33546. */
  33547. getProjectionMatrix(): Matrix;
  33548. /**
  33549. * Gets the current transform matrix
  33550. * @returns a Matrix made of View * Projection
  33551. */
  33552. getTransformMatrix(): Matrix;
  33553. /**
  33554. * Sets the current transform matrix
  33555. * @param viewL defines the View matrix to use
  33556. * @param projectionL defines the Projection matrix to use
  33557. * @param viewR defines the right View matrix to use (if provided)
  33558. * @param projectionR defines the right Projection matrix to use (if provided)
  33559. */
  33560. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33561. /**
  33562. * Gets the uniform buffer used to store scene data
  33563. * @returns a UniformBuffer
  33564. */
  33565. getSceneUniformBuffer(): UniformBuffer;
  33566. /**
  33567. * Gets an unique (relatively to the current scene) Id
  33568. * @returns an unique number for the scene
  33569. */
  33570. getUniqueId(): number;
  33571. /**
  33572. * Add a mesh to the list of scene's meshes
  33573. * @param newMesh defines the mesh to add
  33574. * @param recursive if all child meshes should also be added to the scene
  33575. */
  33576. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33577. /**
  33578. * Remove a mesh for the list of scene's meshes
  33579. * @param toRemove defines the mesh to remove
  33580. * @param recursive if all child meshes should also be removed from the scene
  33581. * @returns the index where the mesh was in the mesh list
  33582. */
  33583. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33584. /**
  33585. * Add a transform node to the list of scene's transform nodes
  33586. * @param newTransformNode defines the transform node to add
  33587. */
  33588. addTransformNode(newTransformNode: TransformNode): void;
  33589. /**
  33590. * Remove a transform node for the list of scene's transform nodes
  33591. * @param toRemove defines the transform node to remove
  33592. * @returns the index where the transform node was in the transform node list
  33593. */
  33594. removeTransformNode(toRemove: TransformNode): number;
  33595. /**
  33596. * Remove a skeleton for the list of scene's skeletons
  33597. * @param toRemove defines the skeleton to remove
  33598. * @returns the index where the skeleton was in the skeleton list
  33599. */
  33600. removeSkeleton(toRemove: Skeleton): number;
  33601. /**
  33602. * Remove a morph target for the list of scene's morph targets
  33603. * @param toRemove defines the morph target to remove
  33604. * @returns the index where the morph target was in the morph target list
  33605. */
  33606. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33607. /**
  33608. * Remove a light for the list of scene's lights
  33609. * @param toRemove defines the light to remove
  33610. * @returns the index where the light was in the light list
  33611. */
  33612. removeLight(toRemove: Light): number;
  33613. /**
  33614. * Remove a camera for the list of scene's cameras
  33615. * @param toRemove defines the camera to remove
  33616. * @returns the index where the camera was in the camera list
  33617. */
  33618. removeCamera(toRemove: Camera): number;
  33619. /**
  33620. * Remove a particle system for the list of scene's particle systems
  33621. * @param toRemove defines the particle system to remove
  33622. * @returns the index where the particle system was in the particle system list
  33623. */
  33624. removeParticleSystem(toRemove: IParticleSystem): number;
  33625. /**
  33626. * Remove a animation for the list of scene's animations
  33627. * @param toRemove defines the animation to remove
  33628. * @returns the index where the animation was in the animation list
  33629. */
  33630. removeAnimation(toRemove: Animation): number;
  33631. /**
  33632. * Removes the given animation group from this scene.
  33633. * @param toRemove The animation group to remove
  33634. * @returns The index of the removed animation group
  33635. */
  33636. removeAnimationGroup(toRemove: AnimationGroup): number;
  33637. /**
  33638. * Removes the given multi-material from this scene.
  33639. * @param toRemove The multi-material to remove
  33640. * @returns The index of the removed multi-material
  33641. */
  33642. removeMultiMaterial(toRemove: MultiMaterial): number;
  33643. /**
  33644. * Removes the given material from this scene.
  33645. * @param toRemove The material to remove
  33646. * @returns The index of the removed material
  33647. */
  33648. removeMaterial(toRemove: Material): number;
  33649. /**
  33650. * Removes the given action manager from this scene.
  33651. * @param toRemove The action manager to remove
  33652. * @returns The index of the removed action manager
  33653. */
  33654. removeActionManager(toRemove: AbstractActionManager): number;
  33655. /**
  33656. * Removes the given texture from this scene.
  33657. * @param toRemove The texture to remove
  33658. * @returns The index of the removed texture
  33659. */
  33660. removeTexture(toRemove: BaseTexture): number;
  33661. /**
  33662. * Adds the given light to this scene
  33663. * @param newLight The light to add
  33664. */
  33665. addLight(newLight: Light): void;
  33666. /**
  33667. * Sorts the list list based on light priorities
  33668. */
  33669. sortLightsByPriority(): void;
  33670. /**
  33671. * Adds the given camera to this scene
  33672. * @param newCamera The camera to add
  33673. */
  33674. addCamera(newCamera: Camera): void;
  33675. /**
  33676. * Adds the given skeleton to this scene
  33677. * @param newSkeleton The skeleton to add
  33678. */
  33679. addSkeleton(newSkeleton: Skeleton): void;
  33680. /**
  33681. * Adds the given particle system to this scene
  33682. * @param newParticleSystem The particle system to add
  33683. */
  33684. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33685. /**
  33686. * Adds the given animation to this scene
  33687. * @param newAnimation The animation to add
  33688. */
  33689. addAnimation(newAnimation: Animation): void;
  33690. /**
  33691. * Adds the given animation group to this scene.
  33692. * @param newAnimationGroup The animation group to add
  33693. */
  33694. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33695. /**
  33696. * Adds the given multi-material to this scene
  33697. * @param newMultiMaterial The multi-material to add
  33698. */
  33699. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33700. /**
  33701. * Adds the given material to this scene
  33702. * @param newMaterial The material to add
  33703. */
  33704. addMaterial(newMaterial: Material): void;
  33705. /**
  33706. * Adds the given morph target to this scene
  33707. * @param newMorphTargetManager The morph target to add
  33708. */
  33709. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33710. /**
  33711. * Adds the given geometry to this scene
  33712. * @param newGeometry The geometry to add
  33713. */
  33714. addGeometry(newGeometry: Geometry): void;
  33715. /**
  33716. * Adds the given action manager to this scene
  33717. * @param newActionManager The action manager to add
  33718. */
  33719. addActionManager(newActionManager: AbstractActionManager): void;
  33720. /**
  33721. * Adds the given texture to this scene.
  33722. * @param newTexture The texture to add
  33723. */
  33724. addTexture(newTexture: BaseTexture): void;
  33725. /**
  33726. * Switch active camera
  33727. * @param newCamera defines the new active camera
  33728. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33729. */
  33730. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33731. /**
  33732. * sets the active camera of the scene using its ID
  33733. * @param id defines the camera's ID
  33734. * @return the new active camera or null if none found.
  33735. */
  33736. setActiveCameraByID(id: string): Nullable<Camera>;
  33737. /**
  33738. * sets the active camera of the scene using its name
  33739. * @param name defines the camera's name
  33740. * @returns the new active camera or null if none found.
  33741. */
  33742. setActiveCameraByName(name: string): Nullable<Camera>;
  33743. /**
  33744. * get an animation group using its name
  33745. * @param name defines the material's name
  33746. * @return the animation group or null if none found.
  33747. */
  33748. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33749. /**
  33750. * Get a material using its unique id
  33751. * @param uniqueId defines the material's unique id
  33752. * @return the material or null if none found.
  33753. */
  33754. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33755. /**
  33756. * get a material using its id
  33757. * @param id defines the material's ID
  33758. * @return the material or null if none found.
  33759. */
  33760. getMaterialByID(id: string): Nullable<Material>;
  33761. /**
  33762. * Gets a material using its name
  33763. * @param name defines the material's name
  33764. * @return the material or null if none found.
  33765. */
  33766. getMaterialByName(name: string): Nullable<Material>;
  33767. /**
  33768. * Gets a camera using its id
  33769. * @param id defines the id to look for
  33770. * @returns the camera or null if not found
  33771. */
  33772. getCameraByID(id: string): Nullable<Camera>;
  33773. /**
  33774. * Gets a camera using its unique id
  33775. * @param uniqueId defines the unique id to look for
  33776. * @returns the camera or null if not found
  33777. */
  33778. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33779. /**
  33780. * Gets a camera using its name
  33781. * @param name defines the camera's name
  33782. * @return the camera or null if none found.
  33783. */
  33784. getCameraByName(name: string): Nullable<Camera>;
  33785. /**
  33786. * Gets a bone using its id
  33787. * @param id defines the bone's id
  33788. * @return the bone or null if not found
  33789. */
  33790. getBoneByID(id: string): Nullable<Bone>;
  33791. /**
  33792. * Gets a bone using its id
  33793. * @param name defines the bone's name
  33794. * @return the bone or null if not found
  33795. */
  33796. getBoneByName(name: string): Nullable<Bone>;
  33797. /**
  33798. * Gets a light node using its name
  33799. * @param name defines the the light's name
  33800. * @return the light or null if none found.
  33801. */
  33802. getLightByName(name: string): Nullable<Light>;
  33803. /**
  33804. * Gets a light node using its id
  33805. * @param id defines the light's id
  33806. * @return the light or null if none found.
  33807. */
  33808. getLightByID(id: string): Nullable<Light>;
  33809. /**
  33810. * Gets a light node using its scene-generated unique ID
  33811. * @param uniqueId defines the light's unique id
  33812. * @return the light or null if none found.
  33813. */
  33814. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33815. /**
  33816. * Gets a particle system by id
  33817. * @param id defines the particle system id
  33818. * @return the corresponding system or null if none found
  33819. */
  33820. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33821. /**
  33822. * Gets a geometry using its ID
  33823. * @param id defines the geometry's id
  33824. * @return the geometry or null if none found.
  33825. */
  33826. getGeometryByID(id: string): Nullable<Geometry>;
  33827. private _getGeometryByUniqueID;
  33828. /**
  33829. * Add a new geometry to this scene
  33830. * @param geometry defines the geometry to be added to the scene.
  33831. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33832. * @return a boolean defining if the geometry was added or not
  33833. */
  33834. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33835. /**
  33836. * Removes an existing geometry
  33837. * @param geometry defines the geometry to be removed from the scene
  33838. * @return a boolean defining if the geometry was removed or not
  33839. */
  33840. removeGeometry(geometry: Geometry): boolean;
  33841. /**
  33842. * Gets the list of geometries attached to the scene
  33843. * @returns an array of Geometry
  33844. */
  33845. getGeometries(): Geometry[];
  33846. /**
  33847. * Gets the first added mesh found of a given ID
  33848. * @param id defines the id to search for
  33849. * @return the mesh found or null if not found at all
  33850. */
  33851. getMeshByID(id: string): Nullable<AbstractMesh>;
  33852. /**
  33853. * Gets a list of meshes using their id
  33854. * @param id defines the id to search for
  33855. * @returns a list of meshes
  33856. */
  33857. getMeshesByID(id: string): Array<AbstractMesh>;
  33858. /**
  33859. * Gets the first added transform node found of a given ID
  33860. * @param id defines the id to search for
  33861. * @return the found transform node or null if not found at all.
  33862. */
  33863. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33864. /**
  33865. * Gets a transform node with its auto-generated unique id
  33866. * @param uniqueId efines the unique id to search for
  33867. * @return the found transform node or null if not found at all.
  33868. */
  33869. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33870. /**
  33871. * Gets a list of transform nodes using their id
  33872. * @param id defines the id to search for
  33873. * @returns a list of transform nodes
  33874. */
  33875. getTransformNodesByID(id: string): Array<TransformNode>;
  33876. /**
  33877. * Gets a mesh with its auto-generated unique id
  33878. * @param uniqueId defines the unique id to search for
  33879. * @return the found mesh or null if not found at all.
  33880. */
  33881. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33882. /**
  33883. * Gets a the last added mesh using a given id
  33884. * @param id defines the id to search for
  33885. * @return the found mesh or null if not found at all.
  33886. */
  33887. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33888. /**
  33889. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33890. * @param id defines the id to search for
  33891. * @return the found node or null if not found at all
  33892. */
  33893. getLastEntryByID(id: string): Nullable<Node>;
  33894. /**
  33895. * Gets a node (Mesh, Camera, Light) using a given id
  33896. * @param id defines the id to search for
  33897. * @return the found node or null if not found at all
  33898. */
  33899. getNodeByID(id: string): Nullable<Node>;
  33900. /**
  33901. * Gets a node (Mesh, Camera, Light) using a given name
  33902. * @param name defines the name to search for
  33903. * @return the found node or null if not found at all.
  33904. */
  33905. getNodeByName(name: string): Nullable<Node>;
  33906. /**
  33907. * Gets a mesh using a given name
  33908. * @param name defines the name to search for
  33909. * @return the found mesh or null if not found at all.
  33910. */
  33911. getMeshByName(name: string): Nullable<AbstractMesh>;
  33912. /**
  33913. * Gets a transform node using a given name
  33914. * @param name defines the name to search for
  33915. * @return the found transform node or null if not found at all.
  33916. */
  33917. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33918. /**
  33919. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33920. * @param id defines the id to search for
  33921. * @return the found skeleton or null if not found at all.
  33922. */
  33923. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33924. /**
  33925. * Gets a skeleton using a given auto generated unique id
  33926. * @param uniqueId defines the unique id to search for
  33927. * @return the found skeleton or null if not found at all.
  33928. */
  33929. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33930. /**
  33931. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33932. * @param id defines the id to search for
  33933. * @return the found skeleton or null if not found at all.
  33934. */
  33935. getSkeletonById(id: string): Nullable<Skeleton>;
  33936. /**
  33937. * Gets a skeleton using a given name
  33938. * @param name defines the name to search for
  33939. * @return the found skeleton or null if not found at all.
  33940. */
  33941. getSkeletonByName(name: string): Nullable<Skeleton>;
  33942. /**
  33943. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33944. * @param id defines the id to search for
  33945. * @return the found morph target manager or null if not found at all.
  33946. */
  33947. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33948. /**
  33949. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33950. * @param id defines the id to search for
  33951. * @return the found morph target or null if not found at all.
  33952. */
  33953. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33954. /**
  33955. * Gets a boolean indicating if the given mesh is active
  33956. * @param mesh defines the mesh to look for
  33957. * @returns true if the mesh is in the active list
  33958. */
  33959. isActiveMesh(mesh: AbstractMesh): boolean;
  33960. /**
  33961. * Return a unique id as a string which can serve as an identifier for the scene
  33962. */
  33963. readonly uid: string;
  33964. /**
  33965. * Add an externaly attached data from its key.
  33966. * This method call will fail and return false, if such key already exists.
  33967. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33968. * @param key the unique key that identifies the data
  33969. * @param data the data object to associate to the key for this Engine instance
  33970. * @return true if no such key were already present and the data was added successfully, false otherwise
  33971. */
  33972. addExternalData<T>(key: string, data: T): boolean;
  33973. /**
  33974. * Get an externaly attached data from its key
  33975. * @param key the unique key that identifies the data
  33976. * @return the associated data, if present (can be null), or undefined if not present
  33977. */
  33978. getExternalData<T>(key: string): Nullable<T>;
  33979. /**
  33980. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33981. * @param key the unique key that identifies the data
  33982. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33983. * @return the associated data, can be null if the factory returned null.
  33984. */
  33985. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33986. /**
  33987. * Remove an externaly attached data from the Engine instance
  33988. * @param key the unique key that identifies the data
  33989. * @return true if the data was successfully removed, false if it doesn't exist
  33990. */
  33991. removeExternalData(key: string): boolean;
  33992. private _evaluateSubMesh;
  33993. /**
  33994. * Clear the processed materials smart array preventing retention point in material dispose.
  33995. */
  33996. freeProcessedMaterials(): void;
  33997. private _preventFreeActiveMeshesAndRenderingGroups;
  33998. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33999. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34000. * when disposing several meshes in a row or a hierarchy of meshes.
  34001. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34002. */
  34003. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34004. /**
  34005. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34006. */
  34007. freeActiveMeshes(): void;
  34008. /**
  34009. * Clear the info related to rendering groups preventing retention points during dispose.
  34010. */
  34011. freeRenderingGroups(): void;
  34012. /** @hidden */
  34013. _isInIntermediateRendering(): boolean;
  34014. /**
  34015. * Lambda returning the list of potentially active meshes.
  34016. */
  34017. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34018. /**
  34019. * Lambda returning the list of potentially active sub meshes.
  34020. */
  34021. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34022. /**
  34023. * Lambda returning the list of potentially intersecting sub meshes.
  34024. */
  34025. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34026. /**
  34027. * Lambda returning the list of potentially colliding sub meshes.
  34028. */
  34029. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34030. private _activeMeshesFrozen;
  34031. /**
  34032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34033. * @returns the current scene
  34034. */
  34035. freezeActiveMeshes(): Scene;
  34036. /**
  34037. * Use this function to restart evaluating active meshes on every frame
  34038. * @returns the current scene
  34039. */
  34040. unfreezeActiveMeshes(): Scene;
  34041. private _evaluateActiveMeshes;
  34042. private _activeMesh;
  34043. /**
  34044. * Update the transform matrix to update from the current active camera
  34045. * @param force defines a boolean used to force the update even if cache is up to date
  34046. */
  34047. updateTransformMatrix(force?: boolean): void;
  34048. private _bindFrameBuffer;
  34049. /** @hidden */
  34050. _allowPostProcessClearColor: boolean;
  34051. /** @hidden */
  34052. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34053. private _processSubCameras;
  34054. private _checkIntersections;
  34055. /** @hidden */
  34056. _advancePhysicsEngineStep(step: number): void;
  34057. /**
  34058. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34059. */
  34060. getDeterministicFrameTime: () => number;
  34061. /** @hidden */
  34062. _animate(): void;
  34063. /**
  34064. * Render the scene
  34065. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34066. */
  34067. render(updateCameras?: boolean): void;
  34068. /**
  34069. * Freeze all materials
  34070. * A frozen material will not be updatable but should be faster to render
  34071. */
  34072. freezeMaterials(): void;
  34073. /**
  34074. * Unfreeze all materials
  34075. * A frozen material will not be updatable but should be faster to render
  34076. */
  34077. unfreezeMaterials(): void;
  34078. /**
  34079. * Releases all held ressources
  34080. */
  34081. dispose(): void;
  34082. /**
  34083. * Gets if the scene is already disposed
  34084. */
  34085. readonly isDisposed: boolean;
  34086. /**
  34087. * Call this function to reduce memory footprint of the scene.
  34088. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34089. */
  34090. clearCachedVertexData(): void;
  34091. /**
  34092. * This function will remove the local cached buffer data from texture.
  34093. * It will save memory but will prevent the texture from being rebuilt
  34094. */
  34095. cleanCachedTextureBuffer(): void;
  34096. /**
  34097. * Get the world extend vectors with an optional filter
  34098. *
  34099. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34100. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34101. */
  34102. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34103. min: Vector3;
  34104. max: Vector3;
  34105. };
  34106. /**
  34107. * Creates a ray that can be used to pick in the scene
  34108. * @param x defines the x coordinate of the origin (on-screen)
  34109. * @param y defines the y coordinate of the origin (on-screen)
  34110. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34111. * @param camera defines the camera to use for the picking
  34112. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34113. * @returns a Ray
  34114. */
  34115. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34116. /**
  34117. * Creates a ray that can be used to pick in the scene
  34118. * @param x defines the x coordinate of the origin (on-screen)
  34119. * @param y defines the y coordinate of the origin (on-screen)
  34120. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34121. * @param result defines the ray where to store the picking ray
  34122. * @param camera defines the camera to use for the picking
  34123. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34124. * @returns the current scene
  34125. */
  34126. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34127. /**
  34128. * Creates a ray that can be used to pick in the scene
  34129. * @param x defines the x coordinate of the origin (on-screen)
  34130. * @param y defines the y coordinate of the origin (on-screen)
  34131. * @param camera defines the camera to use for the picking
  34132. * @returns a Ray
  34133. */
  34134. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34135. /**
  34136. * Creates a ray that can be used to pick in the scene
  34137. * @param x defines the x coordinate of the origin (on-screen)
  34138. * @param y defines the y coordinate of the origin (on-screen)
  34139. * @param result defines the ray where to store the picking ray
  34140. * @param camera defines the camera to use for the picking
  34141. * @returns the current scene
  34142. */
  34143. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34144. /** Launch a ray to try to pick a mesh in the scene
  34145. * @param x position on screen
  34146. * @param y position on screen
  34147. * @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
  34148. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34149. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34150. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34151. * @returns a PickingInfo
  34152. */
  34153. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34154. /** Use the given ray to pick a mesh in the scene
  34155. * @param ray The ray to use to pick meshes
  34156. * @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
  34157. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34158. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34159. * @returns a PickingInfo
  34160. */
  34161. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34162. /**
  34163. * Launch a ray to try to pick a mesh in the scene
  34164. * @param x X position on screen
  34165. * @param y Y position on screen
  34166. * @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
  34167. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34168. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34169. * @returns an array of PickingInfo
  34170. */
  34171. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34172. /**
  34173. * Launch a ray to try to pick a mesh in the scene
  34174. * @param ray Ray to use
  34175. * @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
  34176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34177. * @returns an array of PickingInfo
  34178. */
  34179. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34180. /**
  34181. * Force the value of meshUnderPointer
  34182. * @param mesh defines the mesh to use
  34183. */
  34184. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34185. /**
  34186. * Gets the mesh under the pointer
  34187. * @returns a Mesh or null if no mesh is under the pointer
  34188. */
  34189. getPointerOverMesh(): Nullable<AbstractMesh>;
  34190. /** @hidden */
  34191. _rebuildGeometries(): void;
  34192. /** @hidden */
  34193. _rebuildTextures(): void;
  34194. private _getByTags;
  34195. /**
  34196. * Get a list of meshes by tags
  34197. * @param tagsQuery defines the tags query to use
  34198. * @param forEach defines a predicate used to filter results
  34199. * @returns an array of Mesh
  34200. */
  34201. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34202. /**
  34203. * Get a list of cameras by tags
  34204. * @param tagsQuery defines the tags query to use
  34205. * @param forEach defines a predicate used to filter results
  34206. * @returns an array of Camera
  34207. */
  34208. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34209. /**
  34210. * Get a list of lights by tags
  34211. * @param tagsQuery defines the tags query to use
  34212. * @param forEach defines a predicate used to filter results
  34213. * @returns an array of Light
  34214. */
  34215. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34216. /**
  34217. * Get a list of materials by tags
  34218. * @param tagsQuery defines the tags query to use
  34219. * @param forEach defines a predicate used to filter results
  34220. * @returns an array of Material
  34221. */
  34222. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34223. /**
  34224. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34225. * This allowed control for front to back rendering or reversly depending of the special needs.
  34226. *
  34227. * @param renderingGroupId The rendering group id corresponding to its index
  34228. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34229. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34230. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34231. */
  34232. 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;
  34233. /**
  34234. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34235. *
  34236. * @param renderingGroupId The rendering group id corresponding to its index
  34237. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34238. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34239. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34240. */
  34241. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34242. /**
  34243. * Gets the current auto clear configuration for one rendering group of the rendering
  34244. * manager.
  34245. * @param index the rendering group index to get the information for
  34246. * @returns The auto clear setup for the requested rendering group
  34247. */
  34248. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34249. private _blockMaterialDirtyMechanism;
  34250. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34251. blockMaterialDirtyMechanism: boolean;
  34252. /**
  34253. * Will flag all materials as dirty to trigger new shader compilation
  34254. * @param flag defines the flag used to specify which material part must be marked as dirty
  34255. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34256. */
  34257. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34258. /** @hidden */
  34259. _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;
  34260. /** @hidden */
  34261. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34262. }
  34263. }
  34264. declare module "babylonjs/assetContainer" {
  34265. import { AbstractScene } from "babylonjs/abstractScene";
  34266. import { Scene } from "babylonjs/scene";
  34267. import { Mesh } from "babylonjs/Meshes/mesh";
  34268. /**
  34269. * Set of assets to keep when moving a scene into an asset container.
  34270. */
  34271. export class KeepAssets extends AbstractScene {
  34272. }
  34273. /**
  34274. * Container with a set of assets that can be added or removed from a scene.
  34275. */
  34276. export class AssetContainer extends AbstractScene {
  34277. /**
  34278. * The scene the AssetContainer belongs to.
  34279. */
  34280. scene: Scene;
  34281. /**
  34282. * Instantiates an AssetContainer.
  34283. * @param scene The scene the AssetContainer belongs to.
  34284. */
  34285. constructor(scene: Scene);
  34286. /**
  34287. * Adds all the assets from the container to the scene.
  34288. */
  34289. addAllToScene(): void;
  34290. /**
  34291. * Removes all the assets in the container from the scene
  34292. */
  34293. removeAllFromScene(): void;
  34294. /**
  34295. * Disposes all the assets in the container
  34296. */
  34297. dispose(): void;
  34298. private _moveAssets;
  34299. /**
  34300. * Removes all the assets contained in the scene and adds them to the container.
  34301. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34302. */
  34303. moveAllFromScene(keepAssets?: KeepAssets): void;
  34304. /**
  34305. * 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.
  34306. * @returns the root mesh
  34307. */
  34308. createRootMesh(): Mesh;
  34309. }
  34310. }
  34311. declare module "babylonjs/abstractScene" {
  34312. import { Scene } from "babylonjs/scene";
  34313. import { Nullable } from "babylonjs/types";
  34314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34315. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34316. import { Geometry } from "babylonjs/Meshes/geometry";
  34317. import { Skeleton } from "babylonjs/Bones/skeleton";
  34318. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34319. import { AssetContainer } from "babylonjs/assetContainer";
  34320. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34321. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34323. import { Material } from "babylonjs/Materials/material";
  34324. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34325. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34326. import { Camera } from "babylonjs/Cameras/camera";
  34327. import { Light } from "babylonjs/Lights/light";
  34328. import { Node } from "babylonjs/node";
  34329. import { Animation } from "babylonjs/Animations/animation";
  34330. /**
  34331. * Defines how the parser contract is defined.
  34332. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34333. */
  34334. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34335. /**
  34336. * Defines how the individual parser contract is defined.
  34337. * These parser can parse an individual asset
  34338. */
  34339. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34340. /**
  34341. * Base class of the scene acting as a container for the different elements composing a scene.
  34342. * This class is dynamically extended by the different components of the scene increasing
  34343. * flexibility and reducing coupling
  34344. */
  34345. export abstract class AbstractScene {
  34346. /**
  34347. * Stores the list of available parsers in the application.
  34348. */
  34349. private static _BabylonFileParsers;
  34350. /**
  34351. * Stores the list of available individual parsers in the application.
  34352. */
  34353. private static _IndividualBabylonFileParsers;
  34354. /**
  34355. * Adds a parser in the list of available ones
  34356. * @param name Defines the name of the parser
  34357. * @param parser Defines the parser to add
  34358. */
  34359. static AddParser(name: string, parser: BabylonFileParser): void;
  34360. /**
  34361. * Gets a general parser from the list of avaialble ones
  34362. * @param name Defines the name of the parser
  34363. * @returns the requested parser or null
  34364. */
  34365. static GetParser(name: string): Nullable<BabylonFileParser>;
  34366. /**
  34367. * Adds n individual parser in the list of available ones
  34368. * @param name Defines the name of the parser
  34369. * @param parser Defines the parser to add
  34370. */
  34371. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34372. /**
  34373. * Gets an individual parser from the list of avaialble ones
  34374. * @param name Defines the name of the parser
  34375. * @returns the requested parser or null
  34376. */
  34377. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34378. /**
  34379. * Parser json data and populate both a scene and its associated container object
  34380. * @param jsonData Defines the data to parse
  34381. * @param scene Defines the scene to parse the data for
  34382. * @param container Defines the container attached to the parsing sequence
  34383. * @param rootUrl Defines the root url of the data
  34384. */
  34385. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34386. /**
  34387. * Gets the list of root nodes (ie. nodes with no parent)
  34388. */
  34389. rootNodes: Node[];
  34390. /** All of the cameras added to this scene
  34391. * @see http://doc.babylonjs.com/babylon101/cameras
  34392. */
  34393. cameras: Camera[];
  34394. /**
  34395. * All of the lights added to this scene
  34396. * @see http://doc.babylonjs.com/babylon101/lights
  34397. */
  34398. lights: Light[];
  34399. /**
  34400. * All of the (abstract) meshes added to this scene
  34401. */
  34402. meshes: AbstractMesh[];
  34403. /**
  34404. * The list of skeletons added to the scene
  34405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34406. */
  34407. skeletons: Skeleton[];
  34408. /**
  34409. * All of the particle systems added to this scene
  34410. * @see http://doc.babylonjs.com/babylon101/particles
  34411. */
  34412. particleSystems: IParticleSystem[];
  34413. /**
  34414. * Gets a list of Animations associated with the scene
  34415. */
  34416. animations: Animation[];
  34417. /**
  34418. * All of the animation groups added to this scene
  34419. * @see http://doc.babylonjs.com/how_to/group
  34420. */
  34421. animationGroups: AnimationGroup[];
  34422. /**
  34423. * All of the multi-materials added to this scene
  34424. * @see http://doc.babylonjs.com/how_to/multi_materials
  34425. */
  34426. multiMaterials: MultiMaterial[];
  34427. /**
  34428. * All of the materials added to this scene
  34429. * In the context of a Scene, it is not supposed to be modified manually.
  34430. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34431. * Note also that the order of the Material wihin the array is not significant and might change.
  34432. * @see http://doc.babylonjs.com/babylon101/materials
  34433. */
  34434. materials: Material[];
  34435. /**
  34436. * The list of morph target managers added to the scene
  34437. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34438. */
  34439. morphTargetManagers: MorphTargetManager[];
  34440. /**
  34441. * The list of geometries used in the scene.
  34442. */
  34443. geometries: Geometry[];
  34444. /**
  34445. * All of the tranform nodes added to this scene
  34446. * In the context of a Scene, it is not supposed to be modified manually.
  34447. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34448. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34449. * @see http://doc.babylonjs.com/how_to/transformnode
  34450. */
  34451. transformNodes: TransformNode[];
  34452. /**
  34453. * ActionManagers available on the scene.
  34454. */
  34455. actionManagers: AbstractActionManager[];
  34456. /**
  34457. * Textures to keep.
  34458. */
  34459. textures: BaseTexture[];
  34460. /**
  34461. * Environment texture for the scene
  34462. */
  34463. environmentTexture: Nullable<BaseTexture>;
  34464. }
  34465. }
  34466. declare module "babylonjs/Audio/sound" {
  34467. import { Observable } from "babylonjs/Misc/observable";
  34468. import { Vector3 } from "babylonjs/Maths/math";
  34469. import { Nullable } from "babylonjs/types";
  34470. import { Scene } from "babylonjs/scene";
  34471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34472. /**
  34473. * Defines a sound that can be played in the application.
  34474. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34476. */
  34477. export class Sound {
  34478. /**
  34479. * The name of the sound in the scene.
  34480. */
  34481. name: string;
  34482. /**
  34483. * Does the sound autoplay once loaded.
  34484. */
  34485. autoplay: boolean;
  34486. /**
  34487. * Does the sound loop after it finishes playing once.
  34488. */
  34489. loop: boolean;
  34490. /**
  34491. * Does the sound use a custom attenuation curve to simulate the falloff
  34492. * happening when the source gets further away from the camera.
  34493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34494. */
  34495. useCustomAttenuation: boolean;
  34496. /**
  34497. * The sound track id this sound belongs to.
  34498. */
  34499. soundTrackId: number;
  34500. /**
  34501. * Is this sound currently played.
  34502. */
  34503. isPlaying: boolean;
  34504. /**
  34505. * Is this sound currently paused.
  34506. */
  34507. isPaused: boolean;
  34508. /**
  34509. * Does this sound enables spatial sound.
  34510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34511. */
  34512. spatialSound: boolean;
  34513. /**
  34514. * Define the reference distance the sound should be heard perfectly.
  34515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34516. */
  34517. refDistance: number;
  34518. /**
  34519. * Define the roll off factor of spatial sounds.
  34520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34521. */
  34522. rolloffFactor: number;
  34523. /**
  34524. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34526. */
  34527. maxDistance: number;
  34528. /**
  34529. * Define the distance attenuation model the sound will follow.
  34530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34531. */
  34532. distanceModel: string;
  34533. /**
  34534. * @hidden
  34535. * Back Compat
  34536. **/
  34537. onended: () => any;
  34538. /**
  34539. * Observable event when the current playing sound finishes.
  34540. */
  34541. onEndedObservable: Observable<Sound>;
  34542. private _panningModel;
  34543. private _playbackRate;
  34544. private _streaming;
  34545. private _startTime;
  34546. private _startOffset;
  34547. private _position;
  34548. /** @hidden */
  34549. _positionInEmitterSpace: boolean;
  34550. private _localDirection;
  34551. private _volume;
  34552. private _isReadyToPlay;
  34553. private _isDirectional;
  34554. private _readyToPlayCallback;
  34555. private _audioBuffer;
  34556. private _soundSource;
  34557. private _streamingSource;
  34558. private _soundPanner;
  34559. private _soundGain;
  34560. private _inputAudioNode;
  34561. private _outputAudioNode;
  34562. private _coneInnerAngle;
  34563. private _coneOuterAngle;
  34564. private _coneOuterGain;
  34565. private _scene;
  34566. private _connectedTransformNode;
  34567. private _customAttenuationFunction;
  34568. private _registerFunc;
  34569. private _isOutputConnected;
  34570. private _htmlAudioElement;
  34571. private _urlType;
  34572. /** @hidden */
  34573. static _SceneComponentInitialization: (scene: Scene) => void;
  34574. /**
  34575. * Create a sound and attach it to a scene
  34576. * @param name Name of your sound
  34577. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34578. * @param scene defines the scene the sound belongs to
  34579. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34580. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34581. */
  34582. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34583. /**
  34584. * Release the sound and its associated resources
  34585. */
  34586. dispose(): void;
  34587. /**
  34588. * Gets if the sounds is ready to be played or not.
  34589. * @returns true if ready, otherwise false
  34590. */
  34591. isReady(): boolean;
  34592. private _soundLoaded;
  34593. /**
  34594. * Sets the data of the sound from an audiobuffer
  34595. * @param audioBuffer The audioBuffer containing the data
  34596. */
  34597. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34598. /**
  34599. * Updates the current sounds options such as maxdistance, loop...
  34600. * @param options A JSON object containing values named as the object properties
  34601. */
  34602. updateOptions(options: any): void;
  34603. private _createSpatialParameters;
  34604. private _updateSpatialParameters;
  34605. /**
  34606. * Switch the panning model to HRTF:
  34607. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34609. */
  34610. switchPanningModelToHRTF(): void;
  34611. /**
  34612. * Switch the panning model to Equal Power:
  34613. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34615. */
  34616. switchPanningModelToEqualPower(): void;
  34617. private _switchPanningModel;
  34618. /**
  34619. * Connect this sound to a sound track audio node like gain...
  34620. * @param soundTrackAudioNode the sound track audio node to connect to
  34621. */
  34622. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34623. /**
  34624. * Transform this sound into a directional source
  34625. * @param coneInnerAngle Size of the inner cone in degree
  34626. * @param coneOuterAngle Size of the outer cone in degree
  34627. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34628. */
  34629. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34630. /**
  34631. * Gets or sets the inner angle for the directional cone.
  34632. */
  34633. /**
  34634. * Gets or sets the inner angle for the directional cone.
  34635. */
  34636. directionalConeInnerAngle: number;
  34637. /**
  34638. * Gets or sets the outer angle for the directional cone.
  34639. */
  34640. /**
  34641. * Gets or sets the outer angle for the directional cone.
  34642. */
  34643. directionalConeOuterAngle: number;
  34644. /**
  34645. * Sets the position of the emitter if spatial sound is enabled
  34646. * @param newPosition Defines the new posisiton
  34647. */
  34648. setPosition(newPosition: Vector3): void;
  34649. /**
  34650. * Sets the local direction of the emitter if spatial sound is enabled
  34651. * @param newLocalDirection Defines the new local direction
  34652. */
  34653. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34654. private _updateDirection;
  34655. /** @hidden */
  34656. updateDistanceFromListener(): void;
  34657. /**
  34658. * Sets a new custom attenuation function for the sound.
  34659. * @param callback Defines the function used for the attenuation
  34660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34661. */
  34662. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34663. /**
  34664. * Play the sound
  34665. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34666. * @param offset (optional) Start the sound setting it at a specific time
  34667. */
  34668. play(time?: number, offset?: number): void;
  34669. private _onended;
  34670. /**
  34671. * Stop the sound
  34672. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34673. */
  34674. stop(time?: number): void;
  34675. /**
  34676. * Put the sound in pause
  34677. */
  34678. pause(): void;
  34679. /**
  34680. * Sets a dedicated volume for this sounds
  34681. * @param newVolume Define the new volume of the sound
  34682. * @param time Define in how long the sound should be at this value
  34683. */
  34684. setVolume(newVolume: number, time?: number): void;
  34685. /**
  34686. * Set the sound play back rate
  34687. * @param newPlaybackRate Define the playback rate the sound should be played at
  34688. */
  34689. setPlaybackRate(newPlaybackRate: number): void;
  34690. /**
  34691. * Gets the volume of the sound.
  34692. * @returns the volume of the sound
  34693. */
  34694. getVolume(): number;
  34695. /**
  34696. * Attach the sound to a dedicated mesh
  34697. * @param transformNode The transform node to connect the sound with
  34698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34699. */
  34700. attachToMesh(transformNode: TransformNode): void;
  34701. /**
  34702. * Detach the sound from the previously attached mesh
  34703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34704. */
  34705. detachFromMesh(): void;
  34706. private _onRegisterAfterWorldMatrixUpdate;
  34707. /**
  34708. * Clone the current sound in the scene.
  34709. * @returns the new sound clone
  34710. */
  34711. clone(): Nullable<Sound>;
  34712. /**
  34713. * Gets the current underlying audio buffer containing the data
  34714. * @returns the audio buffer
  34715. */
  34716. getAudioBuffer(): Nullable<AudioBuffer>;
  34717. /**
  34718. * Serializes the Sound in a JSON representation
  34719. * @returns the JSON representation of the sound
  34720. */
  34721. serialize(): any;
  34722. /**
  34723. * Parse a JSON representation of a sound to innstantiate in a given scene
  34724. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34725. * @param scene Define the scene the new parsed sound should be created in
  34726. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34727. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34728. * @returns the newly parsed sound
  34729. */
  34730. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34731. }
  34732. }
  34733. declare module "babylonjs/Actions/directAudioActions" {
  34734. import { Action } from "babylonjs/Actions/action";
  34735. import { Condition } from "babylonjs/Actions/condition";
  34736. import { Sound } from "babylonjs/Audio/sound";
  34737. /**
  34738. * This defines an action helpful to play a defined sound on a triggered action.
  34739. */
  34740. export class PlaySoundAction extends Action {
  34741. private _sound;
  34742. /**
  34743. * Instantiate the action
  34744. * @param triggerOptions defines the trigger options
  34745. * @param sound defines the sound to play
  34746. * @param condition defines the trigger related conditions
  34747. */
  34748. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34749. /** @hidden */
  34750. _prepare(): void;
  34751. /**
  34752. * Execute the action and play the sound.
  34753. */
  34754. execute(): void;
  34755. /**
  34756. * Serializes the actions and its related information.
  34757. * @param parent defines the object to serialize in
  34758. * @returns the serialized object
  34759. */
  34760. serialize(parent: any): any;
  34761. }
  34762. /**
  34763. * This defines an action helpful to stop a defined sound on a triggered action.
  34764. */
  34765. export class StopSoundAction extends Action {
  34766. private _sound;
  34767. /**
  34768. * Instantiate the action
  34769. * @param triggerOptions defines the trigger options
  34770. * @param sound defines the sound to stop
  34771. * @param condition defines the trigger related conditions
  34772. */
  34773. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34774. /** @hidden */
  34775. _prepare(): void;
  34776. /**
  34777. * Execute the action and stop the sound.
  34778. */
  34779. execute(): void;
  34780. /**
  34781. * Serializes the actions and its related information.
  34782. * @param parent defines the object to serialize in
  34783. * @returns the serialized object
  34784. */
  34785. serialize(parent: any): any;
  34786. }
  34787. }
  34788. declare module "babylonjs/Actions/interpolateValueAction" {
  34789. import { Action } from "babylonjs/Actions/action";
  34790. import { Condition } from "babylonjs/Actions/condition";
  34791. import { Observable } from "babylonjs/Misc/observable";
  34792. /**
  34793. * This defines an action responsible to change the value of a property
  34794. * by interpolating between its current value and the newly set one once triggered.
  34795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34796. */
  34797. export class InterpolateValueAction extends Action {
  34798. /**
  34799. * Defines the path of the property where the value should be interpolated
  34800. */
  34801. propertyPath: string;
  34802. /**
  34803. * Defines the target value at the end of the interpolation.
  34804. */
  34805. value: any;
  34806. /**
  34807. * Defines the time it will take for the property to interpolate to the value.
  34808. */
  34809. duration: number;
  34810. /**
  34811. * Defines if the other scene animations should be stopped when the action has been triggered
  34812. */
  34813. stopOtherAnimations?: boolean;
  34814. /**
  34815. * Defines a callback raised once the interpolation animation has been done.
  34816. */
  34817. onInterpolationDone?: () => void;
  34818. /**
  34819. * Observable triggered once the interpolation animation has been done.
  34820. */
  34821. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34822. private _target;
  34823. private _effectiveTarget;
  34824. private _property;
  34825. /**
  34826. * Instantiate the action
  34827. * @param triggerOptions defines the trigger options
  34828. * @param target defines the object containing the value to interpolate
  34829. * @param propertyPath defines the path to the property in the target object
  34830. * @param value defines the target value at the end of the interpolation
  34831. * @param duration deines the time it will take for the property to interpolate to the value.
  34832. * @param condition defines the trigger related conditions
  34833. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34834. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34835. */
  34836. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34837. /** @hidden */
  34838. _prepare(): void;
  34839. /**
  34840. * Execute the action starts the value interpolation.
  34841. */
  34842. execute(): void;
  34843. /**
  34844. * Serializes the actions and its related information.
  34845. * @param parent defines the object to serialize in
  34846. * @returns the serialized object
  34847. */
  34848. serialize(parent: any): any;
  34849. }
  34850. }
  34851. declare module "babylonjs/Actions/index" {
  34852. export * from "babylonjs/Actions/action";
  34853. export * from "babylonjs/Actions/actionEvent";
  34854. export * from "babylonjs/Actions/actionManager";
  34855. export * from "babylonjs/Actions/condition";
  34856. export * from "babylonjs/Actions/directActions";
  34857. export * from "babylonjs/Actions/directAudioActions";
  34858. export * from "babylonjs/Actions/interpolateValueAction";
  34859. }
  34860. declare module "babylonjs/Animations/index" {
  34861. export * from "babylonjs/Animations/animatable";
  34862. export * from "babylonjs/Animations/animation";
  34863. export * from "babylonjs/Animations/animationGroup";
  34864. export * from "babylonjs/Animations/animationPropertiesOverride";
  34865. export * from "babylonjs/Animations/easing";
  34866. export * from "babylonjs/Animations/runtimeAnimation";
  34867. export * from "babylonjs/Animations/animationEvent";
  34868. export * from "babylonjs/Animations/animationGroup";
  34869. export * from "babylonjs/Animations/animationKey";
  34870. export * from "babylonjs/Animations/animationRange";
  34871. }
  34872. declare module "babylonjs/Audio/soundTrack" {
  34873. import { Sound } from "babylonjs/Audio/sound";
  34874. import { Analyser } from "babylonjs/Audio/analyser";
  34875. import { Scene } from "babylonjs/scene";
  34876. /**
  34877. * Options allowed during the creation of a sound track.
  34878. */
  34879. export interface ISoundTrackOptions {
  34880. /**
  34881. * The volume the sound track should take during creation
  34882. */
  34883. volume?: number;
  34884. /**
  34885. * Define if the sound track is the main sound track of the scene
  34886. */
  34887. mainTrack?: boolean;
  34888. }
  34889. /**
  34890. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34891. * It will be also used in a future release to apply effects on a specific track.
  34892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34893. */
  34894. export class SoundTrack {
  34895. /**
  34896. * The unique identifier of the sound track in the scene.
  34897. */
  34898. id: number;
  34899. /**
  34900. * The list of sounds included in the sound track.
  34901. */
  34902. soundCollection: Array<Sound>;
  34903. private _outputAudioNode;
  34904. private _scene;
  34905. private _isMainTrack;
  34906. private _connectedAnalyser;
  34907. private _options;
  34908. private _isInitialized;
  34909. /**
  34910. * Creates a new sound track.
  34911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34912. * @param scene Define the scene the sound track belongs to
  34913. * @param options
  34914. */
  34915. constructor(scene: Scene, options?: ISoundTrackOptions);
  34916. private _initializeSoundTrackAudioGraph;
  34917. /**
  34918. * Release the sound track and its associated resources
  34919. */
  34920. dispose(): void;
  34921. /**
  34922. * Adds a sound to this sound track
  34923. * @param sound define the cound to add
  34924. * @ignoreNaming
  34925. */
  34926. AddSound(sound: Sound): void;
  34927. /**
  34928. * Removes a sound to this sound track
  34929. * @param sound define the cound to remove
  34930. * @ignoreNaming
  34931. */
  34932. RemoveSound(sound: Sound): void;
  34933. /**
  34934. * Set a global volume for the full sound track.
  34935. * @param newVolume Define the new volume of the sound track
  34936. */
  34937. setVolume(newVolume: number): void;
  34938. /**
  34939. * Switch the panning model to HRTF:
  34940. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34942. */
  34943. switchPanningModelToHRTF(): void;
  34944. /**
  34945. * Switch the panning model to Equal Power:
  34946. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34948. */
  34949. switchPanningModelToEqualPower(): void;
  34950. /**
  34951. * Connect the sound track to an audio analyser allowing some amazing
  34952. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34954. * @param analyser The analyser to connect to the engine
  34955. */
  34956. connectToAnalyser(analyser: Analyser): void;
  34957. }
  34958. }
  34959. declare module "babylonjs/Audio/audioSceneComponent" {
  34960. import { Sound } from "babylonjs/Audio/sound";
  34961. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34962. import { Nullable } from "babylonjs/types";
  34963. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34964. import { Scene } from "babylonjs/scene";
  34965. import { AbstractScene } from "babylonjs/abstractScene";
  34966. module "babylonjs/abstractScene" {
  34967. interface AbstractScene {
  34968. /**
  34969. * The list of sounds used in the scene.
  34970. */
  34971. sounds: Nullable<Array<Sound>>;
  34972. }
  34973. }
  34974. module "babylonjs/scene" {
  34975. interface Scene {
  34976. /**
  34977. * @hidden
  34978. * Backing field
  34979. */
  34980. _mainSoundTrack: SoundTrack;
  34981. /**
  34982. * The main sound track played by the scene.
  34983. * It cotains your primary collection of sounds.
  34984. */
  34985. mainSoundTrack: SoundTrack;
  34986. /**
  34987. * The list of sound tracks added to the scene
  34988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34989. */
  34990. soundTracks: Nullable<Array<SoundTrack>>;
  34991. /**
  34992. * Gets a sound using a given name
  34993. * @param name defines the name to search for
  34994. * @return the found sound or null if not found at all.
  34995. */
  34996. getSoundByName(name: string): Nullable<Sound>;
  34997. /**
  34998. * Gets or sets if audio support is enabled
  34999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35000. */
  35001. audioEnabled: boolean;
  35002. /**
  35003. * Gets or sets if audio will be output to headphones
  35004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35005. */
  35006. headphone: boolean;
  35007. }
  35008. }
  35009. /**
  35010. * Defines the sound scene component responsible to manage any sounds
  35011. * in a given scene.
  35012. */
  35013. export class AudioSceneComponent implements ISceneSerializableComponent {
  35014. /**
  35015. * The component name helpfull to identify the component in the list of scene components.
  35016. */
  35017. readonly name: string;
  35018. /**
  35019. * The scene the component belongs to.
  35020. */
  35021. scene: Scene;
  35022. private _audioEnabled;
  35023. /**
  35024. * Gets whether audio is enabled or not.
  35025. * Please use related enable/disable method to switch state.
  35026. */
  35027. readonly audioEnabled: boolean;
  35028. private _headphone;
  35029. /**
  35030. * Gets whether audio is outputing to headphone or not.
  35031. * Please use the according Switch methods to change output.
  35032. */
  35033. readonly headphone: boolean;
  35034. /**
  35035. * Creates a new instance of the component for the given scene
  35036. * @param scene Defines the scene to register the component in
  35037. */
  35038. constructor(scene: Scene);
  35039. /**
  35040. * Registers the component in a given scene
  35041. */
  35042. register(): void;
  35043. /**
  35044. * Rebuilds the elements related to this component in case of
  35045. * context lost for instance.
  35046. */
  35047. rebuild(): void;
  35048. /**
  35049. * Serializes the component data to the specified json object
  35050. * @param serializationObject The object to serialize to
  35051. */
  35052. serialize(serializationObject: any): void;
  35053. /**
  35054. * Adds all the element from the container to the scene
  35055. * @param container the container holding the elements
  35056. */
  35057. addFromContainer(container: AbstractScene): void;
  35058. /**
  35059. * Removes all the elements in the container from the scene
  35060. * @param container contains the elements to remove
  35061. * @param dispose if the removed element should be disposed (default: false)
  35062. */
  35063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35064. /**
  35065. * Disposes the component and the associated ressources.
  35066. */
  35067. dispose(): void;
  35068. /**
  35069. * Disables audio in the associated scene.
  35070. */
  35071. disableAudio(): void;
  35072. /**
  35073. * Enables audio in the associated scene.
  35074. */
  35075. enableAudio(): void;
  35076. /**
  35077. * Switch audio to headphone output.
  35078. */
  35079. switchAudioModeForHeadphones(): void;
  35080. /**
  35081. * Switch audio to normal speakers.
  35082. */
  35083. switchAudioModeForNormalSpeakers(): void;
  35084. private _afterRender;
  35085. }
  35086. }
  35087. declare module "babylonjs/Audio/weightedsound" {
  35088. import { Sound } from "babylonjs/Audio/sound";
  35089. /**
  35090. * Wraps one or more Sound objects and selects one with random weight for playback.
  35091. */
  35092. export class WeightedSound {
  35093. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35094. loop: boolean;
  35095. private _coneInnerAngle;
  35096. private _coneOuterAngle;
  35097. private _volume;
  35098. /** A Sound is currently playing. */
  35099. isPlaying: boolean;
  35100. /** A Sound is currently paused. */
  35101. isPaused: boolean;
  35102. private _sounds;
  35103. private _weights;
  35104. private _currentIndex?;
  35105. /**
  35106. * Creates a new WeightedSound from the list of sounds given.
  35107. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35108. * @param sounds Array of Sounds that will be selected from.
  35109. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35110. */
  35111. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35112. /**
  35113. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35114. */
  35115. /**
  35116. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35117. */
  35118. directionalConeInnerAngle: number;
  35119. /**
  35120. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35121. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35122. */
  35123. /**
  35124. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35125. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35126. */
  35127. directionalConeOuterAngle: number;
  35128. /**
  35129. * Playback volume.
  35130. */
  35131. /**
  35132. * Playback volume.
  35133. */
  35134. volume: number;
  35135. private _onended;
  35136. /**
  35137. * Suspend playback
  35138. */
  35139. pause(): void;
  35140. /**
  35141. * Stop playback
  35142. */
  35143. stop(): void;
  35144. /**
  35145. * Start playback.
  35146. * @param startOffset Position the clip head at a specific time in seconds.
  35147. */
  35148. play(startOffset?: number): void;
  35149. }
  35150. }
  35151. declare module "babylonjs/Audio/index" {
  35152. export * from "babylonjs/Audio/analyser";
  35153. export * from "babylonjs/Audio/audioEngine";
  35154. export * from "babylonjs/Audio/audioSceneComponent";
  35155. export * from "babylonjs/Audio/sound";
  35156. export * from "babylonjs/Audio/soundTrack";
  35157. export * from "babylonjs/Audio/weightedsound";
  35158. }
  35159. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35160. import { Behavior } from "babylonjs/Behaviors/behavior";
  35161. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35162. import { BackEase } from "babylonjs/Animations/easing";
  35163. /**
  35164. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35166. */
  35167. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35168. /**
  35169. * Gets the name of the behavior.
  35170. */
  35171. readonly name: string;
  35172. /**
  35173. * The easing function used by animations
  35174. */
  35175. static EasingFunction: BackEase;
  35176. /**
  35177. * The easing mode used by animations
  35178. */
  35179. static EasingMode: number;
  35180. /**
  35181. * The duration of the animation, in milliseconds
  35182. */
  35183. transitionDuration: number;
  35184. /**
  35185. * Length of the distance animated by the transition when lower radius is reached
  35186. */
  35187. lowerRadiusTransitionRange: number;
  35188. /**
  35189. * Length of the distance animated by the transition when upper radius is reached
  35190. */
  35191. upperRadiusTransitionRange: number;
  35192. private _autoTransitionRange;
  35193. /**
  35194. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35195. */
  35196. /**
  35197. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35198. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35199. */
  35200. autoTransitionRange: boolean;
  35201. private _attachedCamera;
  35202. private _onAfterCheckInputsObserver;
  35203. private _onMeshTargetChangedObserver;
  35204. /**
  35205. * Initializes the behavior.
  35206. */
  35207. init(): void;
  35208. /**
  35209. * Attaches the behavior to its arc rotate camera.
  35210. * @param camera Defines the camera to attach the behavior to
  35211. */
  35212. attach(camera: ArcRotateCamera): void;
  35213. /**
  35214. * Detaches the behavior from its current arc rotate camera.
  35215. */
  35216. detach(): void;
  35217. private _radiusIsAnimating;
  35218. private _radiusBounceTransition;
  35219. private _animatables;
  35220. private _cachedWheelPrecision;
  35221. /**
  35222. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35223. * @param radiusLimit The limit to check against.
  35224. * @return Bool to indicate if at limit.
  35225. */
  35226. private _isRadiusAtLimit;
  35227. /**
  35228. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35229. * @param radiusDelta The delta by which to animate to. Can be negative.
  35230. */
  35231. private _applyBoundRadiusAnimation;
  35232. /**
  35233. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35234. */
  35235. protected _clearAnimationLocks(): void;
  35236. /**
  35237. * Stops and removes all animations that have been applied to the camera
  35238. */
  35239. stopAllAnimations(): void;
  35240. }
  35241. }
  35242. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35243. import { Behavior } from "babylonjs/Behaviors/behavior";
  35244. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35245. import { ExponentialEase } from "babylonjs/Animations/easing";
  35246. import { Nullable } from "babylonjs/types";
  35247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35248. import { Vector3 } from "babylonjs/Maths/math";
  35249. /**
  35250. * 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.
  35251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35252. */
  35253. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35254. /**
  35255. * Gets the name of the behavior.
  35256. */
  35257. readonly name: string;
  35258. private _mode;
  35259. private _radiusScale;
  35260. private _positionScale;
  35261. private _defaultElevation;
  35262. private _elevationReturnTime;
  35263. private _elevationReturnWaitTime;
  35264. private _zoomStopsAnimation;
  35265. private _framingTime;
  35266. /**
  35267. * The easing function used by animations
  35268. */
  35269. static EasingFunction: ExponentialEase;
  35270. /**
  35271. * The easing mode used by animations
  35272. */
  35273. static EasingMode: number;
  35274. /**
  35275. * Sets the current mode used by the behavior
  35276. */
  35277. /**
  35278. * Gets current mode used by the behavior.
  35279. */
  35280. mode: number;
  35281. /**
  35282. * Sets the scale applied to the radius (1 by default)
  35283. */
  35284. /**
  35285. * Gets the scale applied to the radius
  35286. */
  35287. radiusScale: number;
  35288. /**
  35289. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35290. */
  35291. /**
  35292. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35293. */
  35294. positionScale: number;
  35295. /**
  35296. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35297. * behaviour is triggered, in radians.
  35298. */
  35299. /**
  35300. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35301. * behaviour is triggered, in radians.
  35302. */
  35303. defaultElevation: number;
  35304. /**
  35305. * Sets the time (in milliseconds) taken to return to the default beta position.
  35306. * Negative value indicates camera should not return to default.
  35307. */
  35308. /**
  35309. * Gets the time (in milliseconds) taken to return to the default beta position.
  35310. * Negative value indicates camera should not return to default.
  35311. */
  35312. elevationReturnTime: number;
  35313. /**
  35314. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35315. */
  35316. /**
  35317. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35318. */
  35319. elevationReturnWaitTime: number;
  35320. /**
  35321. * Sets the flag that indicates if user zooming should stop animation.
  35322. */
  35323. /**
  35324. * Gets the flag that indicates if user zooming should stop animation.
  35325. */
  35326. zoomStopsAnimation: boolean;
  35327. /**
  35328. * Sets the transition time when framing the mesh, in milliseconds
  35329. */
  35330. /**
  35331. * Gets the transition time when framing the mesh, in milliseconds
  35332. */
  35333. framingTime: number;
  35334. /**
  35335. * Define if the behavior should automatically change the configured
  35336. * camera limits and sensibilities.
  35337. */
  35338. autoCorrectCameraLimitsAndSensibility: boolean;
  35339. private _onPrePointerObservableObserver;
  35340. private _onAfterCheckInputsObserver;
  35341. private _onMeshTargetChangedObserver;
  35342. private _attachedCamera;
  35343. private _isPointerDown;
  35344. private _lastInteractionTime;
  35345. /**
  35346. * Initializes the behavior.
  35347. */
  35348. init(): void;
  35349. /**
  35350. * Attaches the behavior to its arc rotate camera.
  35351. * @param camera Defines the camera to attach the behavior to
  35352. */
  35353. attach(camera: ArcRotateCamera): void;
  35354. /**
  35355. * Detaches the behavior from its current arc rotate camera.
  35356. */
  35357. detach(): void;
  35358. private _animatables;
  35359. private _betaIsAnimating;
  35360. private _betaTransition;
  35361. private _radiusTransition;
  35362. private _vectorTransition;
  35363. /**
  35364. * Targets the given mesh and updates zoom level accordingly.
  35365. * @param mesh The mesh to target.
  35366. * @param radius Optional. If a cached radius position already exists, overrides default.
  35367. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35370. */
  35371. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35372. /**
  35373. * Targets the given mesh with its children and updates zoom level accordingly.
  35374. * @param mesh The mesh to target.
  35375. * @param radius Optional. If a cached radius position already exists, overrides default.
  35376. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35377. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35378. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35379. */
  35380. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35381. /**
  35382. * Targets the given meshes with their children and updates zoom level accordingly.
  35383. * @param meshes The mesh to target.
  35384. * @param radius Optional. If a cached radius position already exists, overrides default.
  35385. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35386. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35387. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35388. */
  35389. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35390. /**
  35391. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35392. * @param minimumWorld Determines the smaller position of the bounding box extend
  35393. * @param maximumWorld Determines the bigger position of the bounding box extend
  35394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35396. */
  35397. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35398. /**
  35399. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35400. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35401. * frustum width.
  35402. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35403. * to fully enclose the mesh in the viewing frustum.
  35404. */
  35405. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35406. /**
  35407. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35408. * is automatically returned to its default position (expected to be above ground plane).
  35409. */
  35410. private _maintainCameraAboveGround;
  35411. /**
  35412. * Returns the frustum slope based on the canvas ratio and camera FOV
  35413. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35414. */
  35415. private _getFrustumSlope;
  35416. /**
  35417. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35418. */
  35419. private _clearAnimationLocks;
  35420. /**
  35421. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35422. */
  35423. private _applyUserInteraction;
  35424. /**
  35425. * Stops and removes all animations that have been applied to the camera
  35426. */
  35427. stopAllAnimations(): void;
  35428. /**
  35429. * Gets a value indicating if the user is moving the camera
  35430. */
  35431. readonly isUserIsMoving: boolean;
  35432. /**
  35433. * The camera can move all the way towards the mesh.
  35434. */
  35435. static IgnoreBoundsSizeMode: number;
  35436. /**
  35437. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35438. */
  35439. static FitFrustumSidesMode: number;
  35440. }
  35441. }
  35442. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35443. import { Nullable } from "babylonjs/types";
  35444. import { Camera } from "babylonjs/Cameras/camera";
  35445. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35446. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35447. /**
  35448. * Base class for Camera Pointer Inputs.
  35449. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35450. * for example usage.
  35451. */
  35452. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35453. /**
  35454. * Defines the camera the input is attached to.
  35455. */
  35456. abstract camera: Camera;
  35457. /**
  35458. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35459. */
  35460. protected _altKey: boolean;
  35461. protected _ctrlKey: boolean;
  35462. protected _metaKey: boolean;
  35463. protected _shiftKey: boolean;
  35464. /**
  35465. * Which mouse buttons were pressed at time of last mouse event.
  35466. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35467. */
  35468. protected _buttonsPressed: number;
  35469. /**
  35470. * Defines the buttons associated with the input to handle camera move.
  35471. */
  35472. buttons: number[];
  35473. /**
  35474. * Attach the input controls to a specific dom element to get the input from.
  35475. * @param element Defines the element the controls should be listened from
  35476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35477. */
  35478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35479. /**
  35480. * Detach the current controls from the specified dom element.
  35481. * @param element Defines the element to stop listening the inputs from
  35482. */
  35483. detachControl(element: Nullable<HTMLElement>): void;
  35484. /**
  35485. * Gets the class name of the current input.
  35486. * @returns the class name
  35487. */
  35488. getClassName(): string;
  35489. /**
  35490. * Get the friendly name associated with the input class.
  35491. * @returns the input friendly name
  35492. */
  35493. getSimpleName(): string;
  35494. /**
  35495. * Called on pointer POINTERDOUBLETAP event.
  35496. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35497. */
  35498. protected onDoubleTap(type: string): void;
  35499. /**
  35500. * Called on pointer POINTERMOVE event if only a single touch is active.
  35501. * Override this method to provide functionality.
  35502. */
  35503. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35504. /**
  35505. * Called on pointer POINTERMOVE event if multiple touches are active.
  35506. * Override this method to provide functionality.
  35507. */
  35508. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35509. /**
  35510. * Called on JS contextmenu event.
  35511. * Override this method to provide functionality.
  35512. */
  35513. protected onContextMenu(evt: PointerEvent): void;
  35514. /**
  35515. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35516. * press.
  35517. * Override this method to provide functionality.
  35518. */
  35519. protected onButtonDown(evt: PointerEvent): void;
  35520. /**
  35521. * Called each time a new POINTERUP event occurs. Ie, for each button
  35522. * release.
  35523. * Override this method to provide functionality.
  35524. */
  35525. protected onButtonUp(evt: PointerEvent): void;
  35526. /**
  35527. * Called when window becomes inactive.
  35528. * Override this method to provide functionality.
  35529. */
  35530. protected onLostFocus(): void;
  35531. private _pointerInput;
  35532. private _observer;
  35533. private _onLostFocus;
  35534. private pointA;
  35535. private pointB;
  35536. }
  35537. }
  35538. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35539. import { Nullable } from "babylonjs/types";
  35540. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35541. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35542. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35543. /**
  35544. * Manage the pointers inputs to control an arc rotate camera.
  35545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35546. */
  35547. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35548. /**
  35549. * Defines the camera the input is attached to.
  35550. */
  35551. camera: ArcRotateCamera;
  35552. /**
  35553. * Gets the class name of the current input.
  35554. * @returns the class name
  35555. */
  35556. getClassName(): string;
  35557. /**
  35558. * Defines the buttons associated with the input to handle camera move.
  35559. */
  35560. buttons: number[];
  35561. /**
  35562. * Defines the pointer angular sensibility along the X axis or how fast is
  35563. * the camera rotating.
  35564. */
  35565. angularSensibilityX: number;
  35566. /**
  35567. * Defines the pointer angular sensibility along the Y axis or how fast is
  35568. * the camera rotating.
  35569. */
  35570. angularSensibilityY: number;
  35571. /**
  35572. * Defines the pointer pinch precision or how fast is the camera zooming.
  35573. */
  35574. pinchPrecision: number;
  35575. /**
  35576. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35577. * from 0.
  35578. * It defines the percentage of current camera.radius to use as delta when
  35579. * pinch zoom is used.
  35580. */
  35581. pinchDeltaPercentage: number;
  35582. /**
  35583. * Defines the pointer panning sensibility or how fast is the camera moving.
  35584. */
  35585. panningSensibility: number;
  35586. /**
  35587. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35588. */
  35589. multiTouchPanning: boolean;
  35590. /**
  35591. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35592. * zoom (pinch) through multitouch.
  35593. */
  35594. multiTouchPanAndZoom: boolean;
  35595. /**
  35596. * Revers pinch action direction.
  35597. */
  35598. pinchInwards: boolean;
  35599. private _isPanClick;
  35600. private _twoFingerActivityCount;
  35601. private _isPinching;
  35602. /**
  35603. * Called on pointer POINTERMOVE event if only a single touch is active.
  35604. */
  35605. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35606. /**
  35607. * Called on pointer POINTERDOUBLETAP event.
  35608. */
  35609. protected onDoubleTap(type: string): void;
  35610. /**
  35611. * Called on pointer POINTERMOVE event if multiple touches are active.
  35612. */
  35613. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35614. /**
  35615. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35616. * press.
  35617. */
  35618. protected onButtonDown(evt: PointerEvent): void;
  35619. /**
  35620. * Called each time a new POINTERUP event occurs. Ie, for each button
  35621. * release.
  35622. */
  35623. protected onButtonUp(evt: PointerEvent): void;
  35624. /**
  35625. * Called when window becomes inactive.
  35626. */
  35627. protected onLostFocus(): void;
  35628. }
  35629. }
  35630. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35631. import { Nullable } from "babylonjs/types";
  35632. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35633. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35634. /**
  35635. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35637. */
  35638. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35639. /**
  35640. * Defines the camera the input is attached to.
  35641. */
  35642. camera: ArcRotateCamera;
  35643. /**
  35644. * Defines the list of key codes associated with the up action (increase alpha)
  35645. */
  35646. keysUp: number[];
  35647. /**
  35648. * Defines the list of key codes associated with the down action (decrease alpha)
  35649. */
  35650. keysDown: number[];
  35651. /**
  35652. * Defines the list of key codes associated with the left action (increase beta)
  35653. */
  35654. keysLeft: number[];
  35655. /**
  35656. * Defines the list of key codes associated with the right action (decrease beta)
  35657. */
  35658. keysRight: number[];
  35659. /**
  35660. * Defines the list of key codes associated with the reset action.
  35661. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35662. */
  35663. keysReset: number[];
  35664. /**
  35665. * Defines the panning sensibility of the inputs.
  35666. * (How fast is the camera paning)
  35667. */
  35668. panningSensibility: number;
  35669. /**
  35670. * Defines the zooming sensibility of the inputs.
  35671. * (How fast is the camera zooming)
  35672. */
  35673. zoomingSensibility: number;
  35674. /**
  35675. * Defines wether maintaining the alt key down switch the movement mode from
  35676. * orientation to zoom.
  35677. */
  35678. useAltToZoom: boolean;
  35679. /**
  35680. * Rotation speed of the camera
  35681. */
  35682. angularSpeed: number;
  35683. private _keys;
  35684. private _ctrlPressed;
  35685. private _altPressed;
  35686. private _onCanvasBlurObserver;
  35687. private _onKeyboardObserver;
  35688. private _engine;
  35689. private _scene;
  35690. /**
  35691. * Attach the input controls to a specific dom element to get the input from.
  35692. * @param element Defines the element the controls should be listened from
  35693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35694. */
  35695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35696. /**
  35697. * Detach the current controls from the specified dom element.
  35698. * @param element Defines the element to stop listening the inputs from
  35699. */
  35700. detachControl(element: Nullable<HTMLElement>): void;
  35701. /**
  35702. * Update the current camera state depending on the inputs that have been used this frame.
  35703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35704. */
  35705. checkInputs(): void;
  35706. /**
  35707. * Gets the class name of the current intput.
  35708. * @returns the class name
  35709. */
  35710. getClassName(): string;
  35711. /**
  35712. * Get the friendly name associated with the input class.
  35713. * @returns the input friendly name
  35714. */
  35715. getSimpleName(): string;
  35716. }
  35717. }
  35718. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35719. import { Nullable } from "babylonjs/types";
  35720. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35721. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35722. /**
  35723. * Manage the mouse wheel inputs to control an arc rotate camera.
  35724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35725. */
  35726. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35727. /**
  35728. * Defines the camera the input is attached to.
  35729. */
  35730. camera: ArcRotateCamera;
  35731. /**
  35732. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35733. */
  35734. wheelPrecision: number;
  35735. /**
  35736. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35737. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35738. */
  35739. wheelDeltaPercentage: number;
  35740. private _wheel;
  35741. private _observer;
  35742. /**
  35743. * Attach the input controls to a specific dom element to get the input from.
  35744. * @param element Defines the element the controls should be listened from
  35745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35746. */
  35747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35748. /**
  35749. * Detach the current controls from the specified dom element.
  35750. * @param element Defines the element to stop listening the inputs from
  35751. */
  35752. detachControl(element: Nullable<HTMLElement>): void;
  35753. /**
  35754. * Gets the class name of the current intput.
  35755. * @returns the class name
  35756. */
  35757. getClassName(): string;
  35758. /**
  35759. * Get the friendly name associated with the input class.
  35760. * @returns the input friendly name
  35761. */
  35762. getSimpleName(): string;
  35763. }
  35764. }
  35765. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35766. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35767. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35768. /**
  35769. * Default Inputs manager for the ArcRotateCamera.
  35770. * It groups all the default supported inputs for ease of use.
  35771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35772. */
  35773. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35774. /**
  35775. * Instantiates a new ArcRotateCameraInputsManager.
  35776. * @param camera Defines the camera the inputs belong to
  35777. */
  35778. constructor(camera: ArcRotateCamera);
  35779. /**
  35780. * Add mouse wheel input support to the input manager.
  35781. * @returns the current input manager
  35782. */
  35783. addMouseWheel(): ArcRotateCameraInputsManager;
  35784. /**
  35785. * Add pointers input support to the input manager.
  35786. * @returns the current input manager
  35787. */
  35788. addPointers(): ArcRotateCameraInputsManager;
  35789. /**
  35790. * Add keyboard input support to the input manager.
  35791. * @returns the current input manager
  35792. */
  35793. addKeyboard(): ArcRotateCameraInputsManager;
  35794. }
  35795. }
  35796. declare module "babylonjs/Cameras/arcRotateCamera" {
  35797. import { Observable } from "babylonjs/Misc/observable";
  35798. import { Nullable } from "babylonjs/types";
  35799. import { Scene } from "babylonjs/scene";
  35800. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35802. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35803. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35804. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35805. import { Camera } from "babylonjs/Cameras/camera";
  35806. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35807. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35808. import { Collider } from "babylonjs/Collisions/collider";
  35809. /**
  35810. * This represents an orbital type of camera.
  35811. *
  35812. * 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.
  35813. * 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.
  35814. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35815. */
  35816. export class ArcRotateCamera extends TargetCamera {
  35817. /**
  35818. * Defines the rotation angle of the camera along the longitudinal axis.
  35819. */
  35820. alpha: number;
  35821. /**
  35822. * Defines the rotation angle of the camera along the latitudinal axis.
  35823. */
  35824. beta: number;
  35825. /**
  35826. * Defines the radius of the camera from it s target point.
  35827. */
  35828. radius: number;
  35829. protected _target: Vector3;
  35830. protected _targetHost: Nullable<AbstractMesh>;
  35831. /**
  35832. * Defines the target point of the camera.
  35833. * The camera looks towards it form the radius distance.
  35834. */
  35835. target: Vector3;
  35836. /**
  35837. * Define the current local position of the camera in the scene
  35838. */
  35839. position: Vector3;
  35840. /**
  35841. * Current inertia value on the longitudinal axis.
  35842. * The bigger this number the longer it will take for the camera to stop.
  35843. */
  35844. inertialAlphaOffset: number;
  35845. /**
  35846. * Current inertia value on the latitudinal axis.
  35847. * The bigger this number the longer it will take for the camera to stop.
  35848. */
  35849. inertialBetaOffset: number;
  35850. /**
  35851. * Current inertia value on the radius axis.
  35852. * The bigger this number the longer it will take for the camera to stop.
  35853. */
  35854. inertialRadiusOffset: number;
  35855. /**
  35856. * Minimum allowed angle on the longitudinal axis.
  35857. * This can help limiting how the Camera is able to move in the scene.
  35858. */
  35859. lowerAlphaLimit: Nullable<number>;
  35860. /**
  35861. * Maximum allowed angle on the longitudinal axis.
  35862. * This can help limiting how the Camera is able to move in the scene.
  35863. */
  35864. upperAlphaLimit: Nullable<number>;
  35865. /**
  35866. * Minimum allowed angle on the latitudinal axis.
  35867. * This can help limiting how the Camera is able to move in the scene.
  35868. */
  35869. lowerBetaLimit: number;
  35870. /**
  35871. * Maximum allowed angle on the latitudinal axis.
  35872. * This can help limiting how the Camera is able to move in the scene.
  35873. */
  35874. upperBetaLimit: number;
  35875. /**
  35876. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35877. * This can help limiting how the Camera is able to move in the scene.
  35878. */
  35879. lowerRadiusLimit: Nullable<number>;
  35880. /**
  35881. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35882. * This can help limiting how the Camera is able to move in the scene.
  35883. */
  35884. upperRadiusLimit: Nullable<number>;
  35885. /**
  35886. * Defines the current inertia value used during panning of the camera along the X axis.
  35887. */
  35888. inertialPanningX: number;
  35889. /**
  35890. * Defines the current inertia value used during panning of the camera along the Y axis.
  35891. */
  35892. inertialPanningY: number;
  35893. /**
  35894. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35895. * Basically if your fingers moves away from more than this distance you will be considered
  35896. * in pinch mode.
  35897. */
  35898. pinchToPanMaxDistance: number;
  35899. /**
  35900. * Defines the maximum distance the camera can pan.
  35901. * This could help keeping the cammera always in your scene.
  35902. */
  35903. panningDistanceLimit: Nullable<number>;
  35904. /**
  35905. * Defines the target of the camera before paning.
  35906. */
  35907. panningOriginTarget: Vector3;
  35908. /**
  35909. * Defines the value of the inertia used during panning.
  35910. * 0 would mean stop inertia and one would mean no decelleration at all.
  35911. */
  35912. panningInertia: number;
  35913. /**
  35914. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35915. */
  35916. angularSensibilityX: number;
  35917. /**
  35918. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35919. */
  35920. angularSensibilityY: number;
  35921. /**
  35922. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35923. */
  35924. pinchPrecision: number;
  35925. /**
  35926. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35927. * It will be used instead of pinchDeltaPrecision if different from 0.
  35928. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35929. */
  35930. pinchDeltaPercentage: number;
  35931. /**
  35932. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35933. */
  35934. panningSensibility: number;
  35935. /**
  35936. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35937. */
  35938. keysUp: number[];
  35939. /**
  35940. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35941. */
  35942. keysDown: number[];
  35943. /**
  35944. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35945. */
  35946. keysLeft: number[];
  35947. /**
  35948. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35949. */
  35950. keysRight: number[];
  35951. /**
  35952. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35953. */
  35954. wheelPrecision: number;
  35955. /**
  35956. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35957. * It will be used instead of pinchDeltaPrecision if different from 0.
  35958. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35959. */
  35960. wheelDeltaPercentage: number;
  35961. /**
  35962. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35963. */
  35964. zoomOnFactor: number;
  35965. /**
  35966. * Defines a screen offset for the camera position.
  35967. */
  35968. targetScreenOffset: Vector2;
  35969. /**
  35970. * Allows the camera to be completely reversed.
  35971. * If false the camera can not arrive upside down.
  35972. */
  35973. allowUpsideDown: boolean;
  35974. /**
  35975. * Define if double tap/click is used to restore the previously saved state of the camera.
  35976. */
  35977. useInputToRestoreState: boolean;
  35978. /** @hidden */
  35979. _viewMatrix: Matrix;
  35980. /** @hidden */
  35981. _useCtrlForPanning: boolean;
  35982. /** @hidden */
  35983. _panningMouseButton: number;
  35984. /**
  35985. * Defines the input associated to the camera.
  35986. */
  35987. inputs: ArcRotateCameraInputsManager;
  35988. /** @hidden */
  35989. _reset: () => void;
  35990. /**
  35991. * Defines the allowed panning axis.
  35992. */
  35993. panningAxis: Vector3;
  35994. protected _localDirection: Vector3;
  35995. protected _transformedDirection: Vector3;
  35996. private _bouncingBehavior;
  35997. /**
  35998. * Gets the bouncing behavior of the camera if it has been enabled.
  35999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36000. */
  36001. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36002. /**
  36003. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36004. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36005. */
  36006. useBouncingBehavior: boolean;
  36007. private _framingBehavior;
  36008. /**
  36009. * Gets the framing behavior of the camera if it has been enabled.
  36010. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36011. */
  36012. readonly framingBehavior: Nullable<FramingBehavior>;
  36013. /**
  36014. * Defines if the framing behavior of the camera is enabled on the camera.
  36015. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36016. */
  36017. useFramingBehavior: boolean;
  36018. private _autoRotationBehavior;
  36019. /**
  36020. * Gets the auto rotation behavior of the camera if it has been enabled.
  36021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36022. */
  36023. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36024. /**
  36025. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36027. */
  36028. useAutoRotationBehavior: boolean;
  36029. /**
  36030. * Observable triggered when the mesh target has been changed on the camera.
  36031. */
  36032. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36033. /**
  36034. * Event raised when the camera is colliding with a mesh.
  36035. */
  36036. onCollide: (collidedMesh: AbstractMesh) => void;
  36037. /**
  36038. * Defines whether the camera should check collision with the objects oh the scene.
  36039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36040. */
  36041. checkCollisions: boolean;
  36042. /**
  36043. * Defines the collision radius of the camera.
  36044. * This simulates a sphere around the camera.
  36045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36046. */
  36047. collisionRadius: Vector3;
  36048. protected _collider: Collider;
  36049. protected _previousPosition: Vector3;
  36050. protected _collisionVelocity: Vector3;
  36051. protected _newPosition: Vector3;
  36052. protected _previousAlpha: number;
  36053. protected _previousBeta: number;
  36054. protected _previousRadius: number;
  36055. protected _collisionTriggered: boolean;
  36056. protected _targetBoundingCenter: Nullable<Vector3>;
  36057. private _computationVector;
  36058. private _tempAxisVector;
  36059. private _tempAxisRotationMatrix;
  36060. /**
  36061. * Instantiates a new ArcRotateCamera in a given scene
  36062. * @param name Defines the name of the camera
  36063. * @param alpha Defines the camera rotation along the logitudinal axis
  36064. * @param beta Defines the camera rotation along the latitudinal axis
  36065. * @param radius Defines the camera distance from its target
  36066. * @param target Defines the camera target
  36067. * @param scene Defines the scene the camera belongs to
  36068. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36069. */
  36070. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36071. /** @hidden */
  36072. _initCache(): void;
  36073. /** @hidden */
  36074. _updateCache(ignoreParentClass?: boolean): void;
  36075. protected _getTargetPosition(): Vector3;
  36076. private _storedAlpha;
  36077. private _storedBeta;
  36078. private _storedRadius;
  36079. private _storedTarget;
  36080. /**
  36081. * Stores the current state of the camera (alpha, beta, radius and target)
  36082. * @returns the camera itself
  36083. */
  36084. storeState(): Camera;
  36085. /**
  36086. * @hidden
  36087. * Restored camera state. You must call storeState() first
  36088. */
  36089. _restoreStateValues(): boolean;
  36090. /** @hidden */
  36091. _isSynchronizedViewMatrix(): boolean;
  36092. /**
  36093. * Attached controls to the current camera.
  36094. * @param element Defines the element the controls should be listened from
  36095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36096. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36097. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36098. */
  36099. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36100. /**
  36101. * Detach the current controls from the camera.
  36102. * The camera will stop reacting to inputs.
  36103. * @param element Defines the element to stop listening the inputs from
  36104. */
  36105. detachControl(element: HTMLElement): void;
  36106. /** @hidden */
  36107. _checkInputs(): void;
  36108. protected _checkLimits(): void;
  36109. /**
  36110. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36111. */
  36112. rebuildAnglesAndRadius(): void;
  36113. /**
  36114. * Use a position to define the current camera related information like aplha, beta and radius
  36115. * @param position Defines the position to set the camera at
  36116. */
  36117. setPosition(position: Vector3): void;
  36118. /**
  36119. * Defines the target the camera should look at.
  36120. * This will automatically adapt alpha beta and radius to fit within the new target.
  36121. * @param target Defines the new target as a Vector or a mesh
  36122. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36123. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36124. */
  36125. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36126. /** @hidden */
  36127. _getViewMatrix(): Matrix;
  36128. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36129. /**
  36130. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36131. * @param meshes Defines the mesh to zoom on
  36132. * @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)
  36133. */
  36134. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36135. /**
  36136. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36137. * The target will be changed but the radius
  36138. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36139. * @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)
  36140. */
  36141. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36142. min: Vector3;
  36143. max: Vector3;
  36144. distance: number;
  36145. }, doNotUpdateMaxZ?: boolean): void;
  36146. /**
  36147. * @override
  36148. * Override Camera.createRigCamera
  36149. */
  36150. createRigCamera(name: string, cameraIndex: number): Camera;
  36151. /**
  36152. * @hidden
  36153. * @override
  36154. * Override Camera._updateRigCameras
  36155. */
  36156. _updateRigCameras(): void;
  36157. /**
  36158. * Destroy the camera and release the current resources hold by it.
  36159. */
  36160. dispose(): void;
  36161. /**
  36162. * Gets the current object class name.
  36163. * @return the class name
  36164. */
  36165. getClassName(): string;
  36166. }
  36167. }
  36168. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36169. import { Behavior } from "babylonjs/Behaviors/behavior";
  36170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36171. /**
  36172. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36174. */
  36175. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36176. /**
  36177. * Gets the name of the behavior.
  36178. */
  36179. readonly name: string;
  36180. private _zoomStopsAnimation;
  36181. private _idleRotationSpeed;
  36182. private _idleRotationWaitTime;
  36183. private _idleRotationSpinupTime;
  36184. /**
  36185. * Sets the flag that indicates if user zooming should stop animation.
  36186. */
  36187. /**
  36188. * Gets the flag that indicates if user zooming should stop animation.
  36189. */
  36190. zoomStopsAnimation: boolean;
  36191. /**
  36192. * Sets the default speed at which the camera rotates around the model.
  36193. */
  36194. /**
  36195. * Gets the default speed at which the camera rotates around the model.
  36196. */
  36197. idleRotationSpeed: number;
  36198. /**
  36199. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36200. */
  36201. /**
  36202. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36203. */
  36204. idleRotationWaitTime: number;
  36205. /**
  36206. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36207. */
  36208. /**
  36209. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36210. */
  36211. idleRotationSpinupTime: number;
  36212. /**
  36213. * Gets a value indicating if the camera is currently rotating because of this behavior
  36214. */
  36215. readonly rotationInProgress: boolean;
  36216. private _onPrePointerObservableObserver;
  36217. private _onAfterCheckInputsObserver;
  36218. private _attachedCamera;
  36219. private _isPointerDown;
  36220. private _lastFrameTime;
  36221. private _lastInteractionTime;
  36222. private _cameraRotationSpeed;
  36223. /**
  36224. * Initializes the behavior.
  36225. */
  36226. init(): void;
  36227. /**
  36228. * Attaches the behavior to its arc rotate camera.
  36229. * @param camera Defines the camera to attach the behavior to
  36230. */
  36231. attach(camera: ArcRotateCamera): void;
  36232. /**
  36233. * Detaches the behavior from its current arc rotate camera.
  36234. */
  36235. detach(): void;
  36236. /**
  36237. * Returns true if user is scrolling.
  36238. * @return true if user is scrolling.
  36239. */
  36240. private _userIsZooming;
  36241. private _lastFrameRadius;
  36242. private _shouldAnimationStopForInteraction;
  36243. /**
  36244. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36245. */
  36246. private _applyUserInteraction;
  36247. private _userIsMoving;
  36248. }
  36249. }
  36250. declare module "babylonjs/Behaviors/Cameras/index" {
  36251. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36252. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36253. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36254. }
  36255. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36256. import { Mesh } from "babylonjs/Meshes/mesh";
  36257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36258. import { Behavior } from "babylonjs/Behaviors/behavior";
  36259. /**
  36260. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36261. */
  36262. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36263. private ui;
  36264. /**
  36265. * The name of the behavior
  36266. */
  36267. name: string;
  36268. /**
  36269. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36270. */
  36271. distanceAwayFromFace: number;
  36272. /**
  36273. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36274. */
  36275. distanceAwayFromBottomOfFace: number;
  36276. private _faceVectors;
  36277. private _target;
  36278. private _scene;
  36279. private _onRenderObserver;
  36280. private _tmpMatrix;
  36281. private _tmpVector;
  36282. /**
  36283. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36284. * @param ui The transform node that should be attched to the mesh
  36285. */
  36286. constructor(ui: TransformNode);
  36287. /**
  36288. * Initializes the behavior
  36289. */
  36290. init(): void;
  36291. private _closestFace;
  36292. private _zeroVector;
  36293. private _lookAtTmpMatrix;
  36294. private _lookAtToRef;
  36295. /**
  36296. * Attaches the AttachToBoxBehavior to the passed in mesh
  36297. * @param target The mesh that the specified node will be attached to
  36298. */
  36299. attach(target: Mesh): void;
  36300. /**
  36301. * Detaches the behavior from the mesh
  36302. */
  36303. detach(): void;
  36304. }
  36305. }
  36306. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36307. import { Behavior } from "babylonjs/Behaviors/behavior";
  36308. import { Mesh } from "babylonjs/Meshes/mesh";
  36309. /**
  36310. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36311. */
  36312. export class FadeInOutBehavior implements Behavior<Mesh> {
  36313. /**
  36314. * Time in milliseconds to delay before fading in (Default: 0)
  36315. */
  36316. delay: number;
  36317. /**
  36318. * Time in milliseconds for the mesh to fade in (Default: 300)
  36319. */
  36320. fadeInTime: number;
  36321. private _millisecondsPerFrame;
  36322. private _hovered;
  36323. private _hoverValue;
  36324. private _ownerNode;
  36325. /**
  36326. * Instatiates the FadeInOutBehavior
  36327. */
  36328. constructor();
  36329. /**
  36330. * The name of the behavior
  36331. */
  36332. readonly name: string;
  36333. /**
  36334. * Initializes the behavior
  36335. */
  36336. init(): void;
  36337. /**
  36338. * Attaches the fade behavior on the passed in mesh
  36339. * @param ownerNode The mesh that will be faded in/out once attached
  36340. */
  36341. attach(ownerNode: Mesh): void;
  36342. /**
  36343. * Detaches the behavior from the mesh
  36344. */
  36345. detach(): void;
  36346. /**
  36347. * Triggers the mesh to begin fading in or out
  36348. * @param value if the object should fade in or out (true to fade in)
  36349. */
  36350. fadeIn(value: boolean): void;
  36351. private _update;
  36352. private _setAllVisibility;
  36353. }
  36354. }
  36355. declare module "babylonjs/Misc/pivotTools" {
  36356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36357. /**
  36358. * Class containing a set of static utilities functions for managing Pivots
  36359. * @hidden
  36360. */
  36361. export class PivotTools {
  36362. private static _PivotCached;
  36363. private static _OldPivotPoint;
  36364. private static _PivotTranslation;
  36365. private static _PivotTmpVector;
  36366. /** @hidden */
  36367. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36368. /** @hidden */
  36369. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36370. }
  36371. }
  36372. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36373. import { Scene } from "babylonjs/scene";
  36374. import { Vector4, Plane } from "babylonjs/Maths/math";
  36375. import { Mesh } from "babylonjs/Meshes/mesh";
  36376. import { Nullable } from "babylonjs/types";
  36377. /**
  36378. * Class containing static functions to help procedurally build meshes
  36379. */
  36380. export class PlaneBuilder {
  36381. /**
  36382. * Creates a plane mesh
  36383. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36384. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36385. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36389. * @param name defines the name of the mesh
  36390. * @param options defines the options used to create the mesh
  36391. * @param scene defines the hosting scene
  36392. * @returns the plane mesh
  36393. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36394. */
  36395. static CreatePlane(name: string, options: {
  36396. size?: number;
  36397. width?: number;
  36398. height?: number;
  36399. sideOrientation?: number;
  36400. frontUVs?: Vector4;
  36401. backUVs?: Vector4;
  36402. updatable?: boolean;
  36403. sourcePlane?: Plane;
  36404. }, scene?: Nullable<Scene>): Mesh;
  36405. }
  36406. }
  36407. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36408. import { Behavior } from "babylonjs/Behaviors/behavior";
  36409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36410. import { Observable } from "babylonjs/Misc/observable";
  36411. import { Vector3 } from "babylonjs/Maths/math";
  36412. import { Ray } from "babylonjs/Culling/ray";
  36413. import "babylonjs/Meshes/Builders/planeBuilder";
  36414. /**
  36415. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36416. */
  36417. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36418. private static _AnyMouseID;
  36419. private _attachedNode;
  36420. private _dragPlane;
  36421. private _scene;
  36422. private _pointerObserver;
  36423. private _beforeRenderObserver;
  36424. private static _planeScene;
  36425. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36426. /**
  36427. * 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)
  36428. */
  36429. maxDragAngle: number;
  36430. /**
  36431. * @hidden
  36432. */
  36433. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36434. /**
  36435. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36436. */
  36437. currentDraggingPointerID: number;
  36438. /**
  36439. * The last position where the pointer hit the drag plane in world space
  36440. */
  36441. lastDragPosition: Vector3;
  36442. /**
  36443. * If the behavior is currently in a dragging state
  36444. */
  36445. dragging: boolean;
  36446. /**
  36447. * 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)
  36448. */
  36449. dragDeltaRatio: number;
  36450. /**
  36451. * If the drag plane orientation should be updated during the dragging (Default: true)
  36452. */
  36453. updateDragPlane: boolean;
  36454. private _debugMode;
  36455. private _moving;
  36456. /**
  36457. * Fires each time the attached mesh is dragged with the pointer
  36458. * * delta between last drag position and current drag position in world space
  36459. * * dragDistance along the drag axis
  36460. * * dragPlaneNormal normal of the current drag plane used during the drag
  36461. * * dragPlanePoint in world space where the drag intersects the drag plane
  36462. */
  36463. onDragObservable: Observable<{
  36464. delta: Vector3;
  36465. dragPlanePoint: Vector3;
  36466. dragPlaneNormal: Vector3;
  36467. dragDistance: number;
  36468. pointerId: number;
  36469. }>;
  36470. /**
  36471. * Fires each time a drag begins (eg. mouse down on mesh)
  36472. */
  36473. onDragStartObservable: Observable<{
  36474. dragPlanePoint: Vector3;
  36475. pointerId: number;
  36476. }>;
  36477. /**
  36478. * Fires each time a drag ends (eg. mouse release after drag)
  36479. */
  36480. onDragEndObservable: Observable<{
  36481. dragPlanePoint: Vector3;
  36482. pointerId: number;
  36483. }>;
  36484. /**
  36485. * If the attached mesh should be moved when dragged
  36486. */
  36487. moveAttached: boolean;
  36488. /**
  36489. * If the drag behavior will react to drag events (Default: true)
  36490. */
  36491. enabled: boolean;
  36492. /**
  36493. * If camera controls should be detached during the drag
  36494. */
  36495. detachCameraControls: boolean;
  36496. /**
  36497. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36498. */
  36499. useObjectOrienationForDragging: boolean;
  36500. private _options;
  36501. /**
  36502. * Creates a pointer drag behavior that can be attached to a mesh
  36503. * @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)
  36504. */
  36505. constructor(options?: {
  36506. dragAxis?: Vector3;
  36507. dragPlaneNormal?: Vector3;
  36508. });
  36509. /**
  36510. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36511. */
  36512. validateDrag: (targetPosition: Vector3) => boolean;
  36513. /**
  36514. * The name of the behavior
  36515. */
  36516. readonly name: string;
  36517. /**
  36518. * Initializes the behavior
  36519. */
  36520. init(): void;
  36521. private _tmpVector;
  36522. private _alternatePickedPoint;
  36523. private _worldDragAxis;
  36524. private _targetPosition;
  36525. private _attachedElement;
  36526. /**
  36527. * Attaches the drag behavior the passed in mesh
  36528. * @param ownerNode The mesh that will be dragged around once attached
  36529. */
  36530. attach(ownerNode: AbstractMesh): void;
  36531. /**
  36532. * Force relase the drag action by code.
  36533. */
  36534. releaseDrag(): void;
  36535. private _startDragRay;
  36536. private _lastPointerRay;
  36537. /**
  36538. * Simulates the start of a pointer drag event on the behavior
  36539. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36540. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36541. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36542. */
  36543. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36544. private _startDrag;
  36545. private _dragDelta;
  36546. private _moveDrag;
  36547. private _pickWithRayOnDragPlane;
  36548. private _pointA;
  36549. private _pointB;
  36550. private _pointC;
  36551. private _lineA;
  36552. private _lineB;
  36553. private _localAxis;
  36554. private _lookAt;
  36555. private _updateDragPlanePosition;
  36556. /**
  36557. * Detaches the behavior from the mesh
  36558. */
  36559. detach(): void;
  36560. }
  36561. }
  36562. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36563. import { Mesh } from "babylonjs/Meshes/mesh";
  36564. import { Behavior } from "babylonjs/Behaviors/behavior";
  36565. /**
  36566. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36567. */
  36568. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36569. private _dragBehaviorA;
  36570. private _dragBehaviorB;
  36571. private _startDistance;
  36572. private _initialScale;
  36573. private _targetScale;
  36574. private _ownerNode;
  36575. private _sceneRenderObserver;
  36576. /**
  36577. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36578. */
  36579. constructor();
  36580. /**
  36581. * The name of the behavior
  36582. */
  36583. readonly name: string;
  36584. /**
  36585. * Initializes the behavior
  36586. */
  36587. init(): void;
  36588. private _getCurrentDistance;
  36589. /**
  36590. * Attaches the scale behavior the passed in mesh
  36591. * @param ownerNode The mesh that will be scaled around once attached
  36592. */
  36593. attach(ownerNode: Mesh): void;
  36594. /**
  36595. * Detaches the behavior from the mesh
  36596. */
  36597. detach(): void;
  36598. }
  36599. }
  36600. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36601. import { Behavior } from "babylonjs/Behaviors/behavior";
  36602. import { Mesh } from "babylonjs/Meshes/mesh";
  36603. import { Observable } from "babylonjs/Misc/observable";
  36604. /**
  36605. * 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
  36606. */
  36607. export class SixDofDragBehavior implements Behavior<Mesh> {
  36608. private static _virtualScene;
  36609. private _ownerNode;
  36610. private _sceneRenderObserver;
  36611. private _scene;
  36612. private _targetPosition;
  36613. private _virtualOriginMesh;
  36614. private _virtualDragMesh;
  36615. private _pointerObserver;
  36616. private _moving;
  36617. private _startingOrientation;
  36618. /**
  36619. * 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)
  36620. */
  36621. private zDragFactor;
  36622. /**
  36623. * If the object should rotate to face the drag origin
  36624. */
  36625. rotateDraggedObject: boolean;
  36626. /**
  36627. * If the behavior is currently in a dragging state
  36628. */
  36629. dragging: boolean;
  36630. /**
  36631. * 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)
  36632. */
  36633. dragDeltaRatio: number;
  36634. /**
  36635. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36636. */
  36637. currentDraggingPointerID: number;
  36638. /**
  36639. * If camera controls should be detached during the drag
  36640. */
  36641. detachCameraControls: boolean;
  36642. /**
  36643. * Fires each time a drag starts
  36644. */
  36645. onDragStartObservable: Observable<{}>;
  36646. /**
  36647. * Fires each time a drag ends (eg. mouse release after drag)
  36648. */
  36649. onDragEndObservable: Observable<{}>;
  36650. /**
  36651. * 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
  36652. */
  36653. constructor();
  36654. /**
  36655. * The name of the behavior
  36656. */
  36657. readonly name: string;
  36658. /**
  36659. * Initializes the behavior
  36660. */
  36661. init(): void;
  36662. /**
  36663. * Attaches the scale behavior the passed in mesh
  36664. * @param ownerNode The mesh that will be scaled around once attached
  36665. */
  36666. attach(ownerNode: Mesh): void;
  36667. /**
  36668. * Detaches the behavior from the mesh
  36669. */
  36670. detach(): void;
  36671. }
  36672. }
  36673. declare module "babylonjs/Behaviors/Meshes/index" {
  36674. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36675. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36676. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36677. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36678. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36679. }
  36680. declare module "babylonjs/Behaviors/index" {
  36681. export * from "babylonjs/Behaviors/behavior";
  36682. export * from "babylonjs/Behaviors/Cameras/index";
  36683. export * from "babylonjs/Behaviors/Meshes/index";
  36684. }
  36685. declare module "babylonjs/Bones/boneIKController" {
  36686. import { Bone } from "babylonjs/Bones/bone";
  36687. import { Vector3 } from "babylonjs/Maths/math";
  36688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36689. import { Nullable } from "babylonjs/types";
  36690. /**
  36691. * Class used to apply inverse kinematics to bones
  36692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36693. */
  36694. export class BoneIKController {
  36695. private static _tmpVecs;
  36696. private static _tmpQuat;
  36697. private static _tmpMats;
  36698. /**
  36699. * Gets or sets the target mesh
  36700. */
  36701. targetMesh: AbstractMesh;
  36702. /** Gets or sets the mesh used as pole */
  36703. poleTargetMesh: AbstractMesh;
  36704. /**
  36705. * Gets or sets the bone used as pole
  36706. */
  36707. poleTargetBone: Nullable<Bone>;
  36708. /**
  36709. * Gets or sets the target position
  36710. */
  36711. targetPosition: Vector3;
  36712. /**
  36713. * Gets or sets the pole target position
  36714. */
  36715. poleTargetPosition: Vector3;
  36716. /**
  36717. * Gets or sets the pole target local offset
  36718. */
  36719. poleTargetLocalOffset: Vector3;
  36720. /**
  36721. * Gets or sets the pole angle
  36722. */
  36723. poleAngle: number;
  36724. /**
  36725. * Gets or sets the mesh associated with the controller
  36726. */
  36727. mesh: AbstractMesh;
  36728. /**
  36729. * 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)
  36730. */
  36731. slerpAmount: number;
  36732. private _bone1Quat;
  36733. private _bone1Mat;
  36734. private _bone2Ang;
  36735. private _bone1;
  36736. private _bone2;
  36737. private _bone1Length;
  36738. private _bone2Length;
  36739. private _maxAngle;
  36740. private _maxReach;
  36741. private _rightHandedSystem;
  36742. private _bendAxis;
  36743. private _slerping;
  36744. private _adjustRoll;
  36745. /**
  36746. * Gets or sets maximum allowed angle
  36747. */
  36748. maxAngle: number;
  36749. /**
  36750. * Creates a new BoneIKController
  36751. * @param mesh defines the mesh to control
  36752. * @param bone defines the bone to control
  36753. * @param options defines options to set up the controller
  36754. */
  36755. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36756. targetMesh?: AbstractMesh;
  36757. poleTargetMesh?: AbstractMesh;
  36758. poleTargetBone?: Bone;
  36759. poleTargetLocalOffset?: Vector3;
  36760. poleAngle?: number;
  36761. bendAxis?: Vector3;
  36762. maxAngle?: number;
  36763. slerpAmount?: number;
  36764. });
  36765. private _setMaxAngle;
  36766. /**
  36767. * Force the controller to update the bones
  36768. */
  36769. update(): void;
  36770. }
  36771. }
  36772. declare module "babylonjs/Bones/boneLookController" {
  36773. import { Vector3, Space } from "babylonjs/Maths/math";
  36774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36775. import { Bone } from "babylonjs/Bones/bone";
  36776. /**
  36777. * Class used to make a bone look toward a point in space
  36778. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36779. */
  36780. export class BoneLookController {
  36781. private static _tmpVecs;
  36782. private static _tmpQuat;
  36783. private static _tmpMats;
  36784. /**
  36785. * The target Vector3 that the bone will look at
  36786. */
  36787. target: Vector3;
  36788. /**
  36789. * The mesh that the bone is attached to
  36790. */
  36791. mesh: AbstractMesh;
  36792. /**
  36793. * The bone that will be looking to the target
  36794. */
  36795. bone: Bone;
  36796. /**
  36797. * The up axis of the coordinate system that is used when the bone is rotated
  36798. */
  36799. upAxis: Vector3;
  36800. /**
  36801. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36802. */
  36803. upAxisSpace: Space;
  36804. /**
  36805. * Used to make an adjustment to the yaw of the bone
  36806. */
  36807. adjustYaw: number;
  36808. /**
  36809. * Used to make an adjustment to the pitch of the bone
  36810. */
  36811. adjustPitch: number;
  36812. /**
  36813. * Used to make an adjustment to the roll of the bone
  36814. */
  36815. adjustRoll: number;
  36816. /**
  36817. * 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)
  36818. */
  36819. slerpAmount: number;
  36820. private _minYaw;
  36821. private _maxYaw;
  36822. private _minPitch;
  36823. private _maxPitch;
  36824. private _minYawSin;
  36825. private _minYawCos;
  36826. private _maxYawSin;
  36827. private _maxYawCos;
  36828. private _midYawConstraint;
  36829. private _minPitchTan;
  36830. private _maxPitchTan;
  36831. private _boneQuat;
  36832. private _slerping;
  36833. private _transformYawPitch;
  36834. private _transformYawPitchInv;
  36835. private _firstFrameSkipped;
  36836. private _yawRange;
  36837. private _fowardAxis;
  36838. /**
  36839. * Gets or sets the minimum yaw angle that the bone can look to
  36840. */
  36841. minYaw: number;
  36842. /**
  36843. * Gets or sets the maximum yaw angle that the bone can look to
  36844. */
  36845. maxYaw: number;
  36846. /**
  36847. * Gets or sets the minimum pitch angle that the bone can look to
  36848. */
  36849. minPitch: number;
  36850. /**
  36851. * Gets or sets the maximum pitch angle that the bone can look to
  36852. */
  36853. maxPitch: number;
  36854. /**
  36855. * Create a BoneLookController
  36856. * @param mesh the mesh that the bone belongs to
  36857. * @param bone the bone that will be looking to the target
  36858. * @param target the target Vector3 to look at
  36859. * @param options optional settings:
  36860. * * maxYaw: the maximum angle the bone will yaw to
  36861. * * minYaw: the minimum angle the bone will yaw to
  36862. * * maxPitch: the maximum angle the bone will pitch to
  36863. * * minPitch: the minimum angle the bone will yaw to
  36864. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36865. * * upAxis: the up axis of the coordinate system
  36866. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36867. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36868. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36869. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36870. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36871. * * adjustRoll: used to make an adjustment to the roll of the bone
  36872. **/
  36873. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36874. maxYaw?: number;
  36875. minYaw?: number;
  36876. maxPitch?: number;
  36877. minPitch?: number;
  36878. slerpAmount?: number;
  36879. upAxis?: Vector3;
  36880. upAxisSpace?: Space;
  36881. yawAxis?: Vector3;
  36882. pitchAxis?: Vector3;
  36883. adjustYaw?: number;
  36884. adjustPitch?: number;
  36885. adjustRoll?: number;
  36886. });
  36887. /**
  36888. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36889. */
  36890. update(): void;
  36891. private _getAngleDiff;
  36892. private _getAngleBetween;
  36893. private _isAngleBetween;
  36894. }
  36895. }
  36896. declare module "babylonjs/Bones/index" {
  36897. export * from "babylonjs/Bones/bone";
  36898. export * from "babylonjs/Bones/boneIKController";
  36899. export * from "babylonjs/Bones/boneLookController";
  36900. export * from "babylonjs/Bones/skeleton";
  36901. }
  36902. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36903. import { Nullable } from "babylonjs/types";
  36904. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36906. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36907. /**
  36908. * Manage the gamepad inputs to control an arc rotate camera.
  36909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36910. */
  36911. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36912. /**
  36913. * Defines the camera the input is attached to.
  36914. */
  36915. camera: ArcRotateCamera;
  36916. /**
  36917. * Defines the gamepad the input is gathering event from.
  36918. */
  36919. gamepad: Nullable<Gamepad>;
  36920. /**
  36921. * Defines the gamepad rotation sensiblity.
  36922. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36923. */
  36924. gamepadRotationSensibility: number;
  36925. /**
  36926. * Defines the gamepad move sensiblity.
  36927. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36928. */
  36929. gamepadMoveSensibility: number;
  36930. private _onGamepadConnectedObserver;
  36931. private _onGamepadDisconnectedObserver;
  36932. /**
  36933. * Attach the input controls to a specific dom element to get the input from.
  36934. * @param element Defines the element the controls should be listened from
  36935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36936. */
  36937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36938. /**
  36939. * Detach the current controls from the specified dom element.
  36940. * @param element Defines the element to stop listening the inputs from
  36941. */
  36942. detachControl(element: Nullable<HTMLElement>): void;
  36943. /**
  36944. * Update the current camera state depending on the inputs that have been used this frame.
  36945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36946. */
  36947. checkInputs(): void;
  36948. /**
  36949. * Gets the class name of the current intput.
  36950. * @returns the class name
  36951. */
  36952. getClassName(): string;
  36953. /**
  36954. * Get the friendly name associated with the input class.
  36955. * @returns the input friendly name
  36956. */
  36957. getSimpleName(): string;
  36958. }
  36959. }
  36960. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36961. import { Nullable } from "babylonjs/types";
  36962. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36964. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36965. interface ArcRotateCameraInputsManager {
  36966. /**
  36967. * Add orientation input support to the input manager.
  36968. * @returns the current input manager
  36969. */
  36970. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36971. }
  36972. }
  36973. /**
  36974. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36976. */
  36977. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36978. /**
  36979. * Defines the camera the input is attached to.
  36980. */
  36981. camera: ArcRotateCamera;
  36982. /**
  36983. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36984. */
  36985. alphaCorrection: number;
  36986. /**
  36987. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36988. */
  36989. gammaCorrection: number;
  36990. private _alpha;
  36991. private _gamma;
  36992. private _dirty;
  36993. private _deviceOrientationHandler;
  36994. /**
  36995. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36996. */
  36997. constructor();
  36998. /**
  36999. * Attach the input controls to a specific dom element to get the input from.
  37000. * @param element Defines the element the controls should be listened from
  37001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37002. */
  37003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37004. /** @hidden */
  37005. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37006. /**
  37007. * Update the current camera state depending on the inputs that have been used this frame.
  37008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37009. */
  37010. checkInputs(): void;
  37011. /**
  37012. * Detach the current controls from the specified dom element.
  37013. * @param element Defines the element to stop listening the inputs from
  37014. */
  37015. detachControl(element: Nullable<HTMLElement>): void;
  37016. /**
  37017. * Gets the class name of the current intput.
  37018. * @returns the class name
  37019. */
  37020. getClassName(): string;
  37021. /**
  37022. * Get the friendly name associated with the input class.
  37023. * @returns the input friendly name
  37024. */
  37025. getSimpleName(): string;
  37026. }
  37027. }
  37028. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37029. import { Nullable } from "babylonjs/types";
  37030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37031. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37032. /**
  37033. * Listen to mouse events to control the camera.
  37034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37035. */
  37036. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37037. /**
  37038. * Defines the camera the input is attached to.
  37039. */
  37040. camera: FlyCamera;
  37041. /**
  37042. * Defines if touch is enabled. (Default is true.)
  37043. */
  37044. touchEnabled: boolean;
  37045. /**
  37046. * Defines the buttons associated with the input to handle camera rotation.
  37047. */
  37048. buttons: number[];
  37049. /**
  37050. * Assign buttons for Yaw control.
  37051. */
  37052. buttonsYaw: number[];
  37053. /**
  37054. * Assign buttons for Pitch control.
  37055. */
  37056. buttonsPitch: number[];
  37057. /**
  37058. * Assign buttons for Roll control.
  37059. */
  37060. buttonsRoll: number[];
  37061. /**
  37062. * Detect if any button is being pressed while mouse is moved.
  37063. * -1 = Mouse locked.
  37064. * 0 = Left button.
  37065. * 1 = Middle Button.
  37066. * 2 = Right Button.
  37067. */
  37068. activeButton: number;
  37069. /**
  37070. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37071. * Higher values reduce its sensitivity.
  37072. */
  37073. angularSensibility: number;
  37074. private _mousemoveCallback;
  37075. private _observer;
  37076. private _rollObserver;
  37077. private previousPosition;
  37078. private noPreventDefault;
  37079. private element;
  37080. /**
  37081. * Listen to mouse events to control the camera.
  37082. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37084. */
  37085. constructor(touchEnabled?: boolean);
  37086. /**
  37087. * Attach the mouse control to the HTML DOM element.
  37088. * @param element Defines the element that listens to the input events.
  37089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37090. */
  37091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37092. /**
  37093. * Detach the current controls from the specified dom element.
  37094. * @param element Defines the element to stop listening the inputs from
  37095. */
  37096. detachControl(element: Nullable<HTMLElement>): void;
  37097. /**
  37098. * Gets the class name of the current input.
  37099. * @returns the class name.
  37100. */
  37101. getClassName(): string;
  37102. /**
  37103. * Get the friendly name associated with the input class.
  37104. * @returns the input's friendly name.
  37105. */
  37106. getSimpleName(): string;
  37107. private _pointerInput;
  37108. private _onMouseMove;
  37109. /**
  37110. * Rotate camera by mouse offset.
  37111. */
  37112. private rotateCamera;
  37113. }
  37114. }
  37115. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37116. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37117. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37118. /**
  37119. * Default Inputs manager for the FlyCamera.
  37120. * It groups all the default supported inputs for ease of use.
  37121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37122. */
  37123. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37124. /**
  37125. * Instantiates a new FlyCameraInputsManager.
  37126. * @param camera Defines the camera the inputs belong to.
  37127. */
  37128. constructor(camera: FlyCamera);
  37129. /**
  37130. * Add keyboard input support to the input manager.
  37131. * @returns the new FlyCameraKeyboardMoveInput().
  37132. */
  37133. addKeyboard(): FlyCameraInputsManager;
  37134. /**
  37135. * Add mouse input support to the input manager.
  37136. * @param touchEnabled Enable touch screen support.
  37137. * @returns the new FlyCameraMouseInput().
  37138. */
  37139. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37140. }
  37141. }
  37142. declare module "babylonjs/Cameras/flyCamera" {
  37143. import { Scene } from "babylonjs/scene";
  37144. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37147. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37148. /**
  37149. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37150. * such as in a 3D Space Shooter or a Flight Simulator.
  37151. */
  37152. export class FlyCamera extends TargetCamera {
  37153. /**
  37154. * Define the collision ellipsoid of the camera.
  37155. * This is helpful for simulating a camera body, like a player's body.
  37156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37157. */
  37158. ellipsoid: Vector3;
  37159. /**
  37160. * Define an offset for the position of the ellipsoid around the camera.
  37161. * This can be helpful if the camera is attached away from the player's body center,
  37162. * such as at its head.
  37163. */
  37164. ellipsoidOffset: Vector3;
  37165. /**
  37166. * Enable or disable collisions of the camera with the rest of the scene objects.
  37167. */
  37168. checkCollisions: boolean;
  37169. /**
  37170. * Enable or disable gravity on the camera.
  37171. */
  37172. applyGravity: boolean;
  37173. /**
  37174. * Define the current direction the camera is moving to.
  37175. */
  37176. cameraDirection: Vector3;
  37177. /**
  37178. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37179. * This overrides and empties cameraRotation.
  37180. */
  37181. rotationQuaternion: Quaternion;
  37182. /**
  37183. * Track Roll to maintain the wanted Rolling when looking around.
  37184. */
  37185. _trackRoll: number;
  37186. /**
  37187. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37188. */
  37189. rollCorrect: number;
  37190. /**
  37191. * Mimic a banked turn, Rolling the camera when Yawing.
  37192. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37193. */
  37194. bankedTurn: boolean;
  37195. /**
  37196. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37197. */
  37198. bankedTurnLimit: number;
  37199. /**
  37200. * Value of 0 disables the banked Roll.
  37201. * Value of 1 is equal to the Yaw angle in radians.
  37202. */
  37203. bankedTurnMultiplier: number;
  37204. /**
  37205. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37206. */
  37207. inputs: FlyCameraInputsManager;
  37208. /**
  37209. * Gets the input sensibility for mouse input.
  37210. * Higher values reduce sensitivity.
  37211. */
  37212. /**
  37213. * Sets the input sensibility for a mouse input.
  37214. * Higher values reduce sensitivity.
  37215. */
  37216. angularSensibility: number;
  37217. /**
  37218. * Get the keys for camera movement forward.
  37219. */
  37220. /**
  37221. * Set the keys for camera movement forward.
  37222. */
  37223. keysForward: number[];
  37224. /**
  37225. * Get the keys for camera movement backward.
  37226. */
  37227. keysBackward: number[];
  37228. /**
  37229. * Get the keys for camera movement up.
  37230. */
  37231. /**
  37232. * Set the keys for camera movement up.
  37233. */
  37234. keysUp: number[];
  37235. /**
  37236. * Get the keys for camera movement down.
  37237. */
  37238. /**
  37239. * Set the keys for camera movement down.
  37240. */
  37241. keysDown: number[];
  37242. /**
  37243. * Get the keys for camera movement left.
  37244. */
  37245. /**
  37246. * Set the keys for camera movement left.
  37247. */
  37248. keysLeft: number[];
  37249. /**
  37250. * Set the keys for camera movement right.
  37251. */
  37252. /**
  37253. * Set the keys for camera movement right.
  37254. */
  37255. keysRight: number[];
  37256. /**
  37257. * Event raised when the camera collides with a mesh in the scene.
  37258. */
  37259. onCollide: (collidedMesh: AbstractMesh) => void;
  37260. private _collider;
  37261. private _needMoveForGravity;
  37262. private _oldPosition;
  37263. private _diffPosition;
  37264. private _newPosition;
  37265. /** @hidden */
  37266. _localDirection: Vector3;
  37267. /** @hidden */
  37268. _transformedDirection: Vector3;
  37269. /**
  37270. * Instantiates a FlyCamera.
  37271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37272. * such as in a 3D Space Shooter or a Flight Simulator.
  37273. * @param name Define the name of the camera in the scene.
  37274. * @param position Define the starting position of the camera in the scene.
  37275. * @param scene Define the scene the camera belongs to.
  37276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37277. */
  37278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37279. /**
  37280. * Attach a control to the HTML DOM element.
  37281. * @param element Defines the element that listens to the input events.
  37282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37283. */
  37284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37285. /**
  37286. * Detach a control from the HTML DOM element.
  37287. * The camera will stop reacting to that input.
  37288. * @param element Defines the element that listens to the input events.
  37289. */
  37290. detachControl(element: HTMLElement): void;
  37291. private _collisionMask;
  37292. /**
  37293. * Get the mask that the camera ignores in collision events.
  37294. */
  37295. /**
  37296. * Set the mask that the camera ignores in collision events.
  37297. */
  37298. collisionMask: number;
  37299. /** @hidden */
  37300. _collideWithWorld(displacement: Vector3): void;
  37301. /** @hidden */
  37302. private _onCollisionPositionChange;
  37303. /** @hidden */
  37304. _checkInputs(): void;
  37305. /** @hidden */
  37306. _decideIfNeedsToMove(): boolean;
  37307. /** @hidden */
  37308. _updatePosition(): void;
  37309. /**
  37310. * Restore the Roll to its target value at the rate specified.
  37311. * @param rate - Higher means slower restoring.
  37312. * @hidden
  37313. */
  37314. restoreRoll(rate: number): void;
  37315. /**
  37316. * Destroy the camera and release the current resources held by it.
  37317. */
  37318. dispose(): void;
  37319. /**
  37320. * Get the current object class name.
  37321. * @returns the class name.
  37322. */
  37323. getClassName(): string;
  37324. }
  37325. }
  37326. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37327. import { Nullable } from "babylonjs/types";
  37328. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37329. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37330. /**
  37331. * Listen to keyboard events to control the camera.
  37332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37333. */
  37334. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37335. /**
  37336. * Defines the camera the input is attached to.
  37337. */
  37338. camera: FlyCamera;
  37339. /**
  37340. * The list of keyboard keys used to control the forward move of the camera.
  37341. */
  37342. keysForward: number[];
  37343. /**
  37344. * The list of keyboard keys used to control the backward move of the camera.
  37345. */
  37346. keysBackward: number[];
  37347. /**
  37348. * The list of keyboard keys used to control the forward move of the camera.
  37349. */
  37350. keysUp: number[];
  37351. /**
  37352. * The list of keyboard keys used to control the backward move of the camera.
  37353. */
  37354. keysDown: number[];
  37355. /**
  37356. * The list of keyboard keys used to control the right strafe move of the camera.
  37357. */
  37358. keysRight: number[];
  37359. /**
  37360. * The list of keyboard keys used to control the left strafe move of the camera.
  37361. */
  37362. keysLeft: number[];
  37363. private _keys;
  37364. private _onCanvasBlurObserver;
  37365. private _onKeyboardObserver;
  37366. private _engine;
  37367. private _scene;
  37368. /**
  37369. * Attach the input controls to a specific dom element to get the input from.
  37370. * @param element Defines the element the controls should be listened from
  37371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37372. */
  37373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37374. /**
  37375. * Detach the current controls from the specified dom element.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: Nullable<HTMLElement>): void;
  37379. /**
  37380. * Gets the class name of the current intput.
  37381. * @returns the class name
  37382. */
  37383. getClassName(): string;
  37384. /** @hidden */
  37385. _onLostFocus(e: FocusEvent): void;
  37386. /**
  37387. * Get the friendly name associated with the input class.
  37388. * @returns the input friendly name
  37389. */
  37390. getSimpleName(): string;
  37391. /**
  37392. * Update the current camera state depending on the inputs that have been used this frame.
  37393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37394. */
  37395. checkInputs(): void;
  37396. }
  37397. }
  37398. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37399. import { Nullable } from "babylonjs/types";
  37400. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37402. /**
  37403. * Manage the mouse wheel inputs to control a follow camera.
  37404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37405. */
  37406. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37407. /**
  37408. * Defines the camera the input is attached to.
  37409. */
  37410. camera: FollowCamera;
  37411. /**
  37412. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37413. */
  37414. axisControlRadius: boolean;
  37415. /**
  37416. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37417. */
  37418. axisControlHeight: boolean;
  37419. /**
  37420. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37421. */
  37422. axisControlRotation: boolean;
  37423. /**
  37424. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37425. * relation to mouseWheel events.
  37426. */
  37427. wheelPrecision: number;
  37428. /**
  37429. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37430. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37431. */
  37432. wheelDeltaPercentage: number;
  37433. private _wheel;
  37434. private _observer;
  37435. /**
  37436. * Attach the input controls to a specific dom element to get the input from.
  37437. * @param element Defines the element the controls should be listened from
  37438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37439. */
  37440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37441. /**
  37442. * Detach the current controls from the specified dom element.
  37443. * @param element Defines the element to stop listening the inputs from
  37444. */
  37445. detachControl(element: Nullable<HTMLElement>): void;
  37446. /**
  37447. * Gets the class name of the current intput.
  37448. * @returns the class name
  37449. */
  37450. getClassName(): string;
  37451. /**
  37452. * Get the friendly name associated with the input class.
  37453. * @returns the input friendly name
  37454. */
  37455. getSimpleName(): string;
  37456. }
  37457. }
  37458. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37459. import { Nullable } from "babylonjs/types";
  37460. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37461. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37462. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37463. /**
  37464. * Manage the pointers inputs to control an follow camera.
  37465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37466. */
  37467. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37468. /**
  37469. * Defines the camera the input is attached to.
  37470. */
  37471. camera: FollowCamera;
  37472. /**
  37473. * Gets the class name of the current input.
  37474. * @returns the class name
  37475. */
  37476. getClassName(): string;
  37477. /**
  37478. * Defines the pointer angular sensibility along the X axis or how fast is
  37479. * the camera rotating.
  37480. * A negative number will reverse the axis direction.
  37481. */
  37482. angularSensibilityX: number;
  37483. /**
  37484. * Defines the pointer angular sensibility along the Y axis or how fast is
  37485. * the camera rotating.
  37486. * A negative number will reverse the axis direction.
  37487. */
  37488. angularSensibilityY: number;
  37489. /**
  37490. * Defines the pointer pinch precision or how fast is the camera zooming.
  37491. * A negative number will reverse the axis direction.
  37492. */
  37493. pinchPrecision: number;
  37494. /**
  37495. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37496. * from 0.
  37497. * It defines the percentage of current camera.radius to use as delta when
  37498. * pinch zoom is used.
  37499. */
  37500. pinchDeltaPercentage: number;
  37501. /**
  37502. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37503. */
  37504. axisXControlRadius: boolean;
  37505. /**
  37506. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37507. */
  37508. axisXControlHeight: boolean;
  37509. /**
  37510. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37511. */
  37512. axisXControlRotation: boolean;
  37513. /**
  37514. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37515. */
  37516. axisYControlRadius: boolean;
  37517. /**
  37518. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37519. */
  37520. axisYControlHeight: boolean;
  37521. /**
  37522. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37523. */
  37524. axisYControlRotation: boolean;
  37525. /**
  37526. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37527. */
  37528. axisPinchControlRadius: boolean;
  37529. /**
  37530. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37531. */
  37532. axisPinchControlHeight: boolean;
  37533. /**
  37534. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37535. */
  37536. axisPinchControlRotation: boolean;
  37537. /**
  37538. * Log error messages if basic misconfiguration has occurred.
  37539. */
  37540. warningEnable: boolean;
  37541. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37542. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37543. private _warningCounter;
  37544. private _warning;
  37545. }
  37546. }
  37547. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37548. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37549. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37550. /**
  37551. * Default Inputs manager for the FollowCamera.
  37552. * It groups all the default supported inputs for ease of use.
  37553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37554. */
  37555. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37556. /**
  37557. * Instantiates a new FollowCameraInputsManager.
  37558. * @param camera Defines the camera the inputs belong to
  37559. */
  37560. constructor(camera: FollowCamera);
  37561. /**
  37562. * Add keyboard input support to the input manager.
  37563. * @returns the current input manager
  37564. */
  37565. addKeyboard(): FollowCameraInputsManager;
  37566. /**
  37567. * Add mouse wheel input support to the input manager.
  37568. * @returns the current input manager
  37569. */
  37570. addMouseWheel(): FollowCameraInputsManager;
  37571. /**
  37572. * Add pointers input support to the input manager.
  37573. * @returns the current input manager
  37574. */
  37575. addPointers(): FollowCameraInputsManager;
  37576. /**
  37577. * Add orientation input support to the input manager.
  37578. * @returns the current input manager
  37579. */
  37580. addVRDeviceOrientation(): FollowCameraInputsManager;
  37581. }
  37582. }
  37583. declare module "babylonjs/Cameras/followCamera" {
  37584. import { Nullable } from "babylonjs/types";
  37585. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37586. import { Scene } from "babylonjs/scene";
  37587. import { Vector3 } from "babylonjs/Maths/math";
  37588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37589. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37590. /**
  37591. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37592. * an arc rotate version arcFollowCamera are available.
  37593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37594. */
  37595. export class FollowCamera extends TargetCamera {
  37596. /**
  37597. * Distance the follow camera should follow an object at
  37598. */
  37599. radius: number;
  37600. /**
  37601. * Minimum allowed distance of the camera to the axis of rotation
  37602. * (The camera can not get closer).
  37603. * This can help limiting how the Camera is able to move in the scene.
  37604. */
  37605. lowerRadiusLimit: Nullable<number>;
  37606. /**
  37607. * Maximum allowed distance of the camera to the axis of rotation
  37608. * (The camera can not get further).
  37609. * This can help limiting how the Camera is able to move in the scene.
  37610. */
  37611. upperRadiusLimit: Nullable<number>;
  37612. /**
  37613. * Define a rotation offset between the camera and the object it follows
  37614. */
  37615. rotationOffset: number;
  37616. /**
  37617. * Minimum allowed angle to camera position relative to target object.
  37618. * This can help limiting how the Camera is able to move in the scene.
  37619. */
  37620. lowerRotationOffsetLimit: Nullable<number>;
  37621. /**
  37622. * Maximum allowed angle to camera position relative to target object.
  37623. * This can help limiting how the Camera is able to move in the scene.
  37624. */
  37625. upperRotationOffsetLimit: Nullable<number>;
  37626. /**
  37627. * Define a height offset between the camera and the object it follows.
  37628. * It can help following an object from the top (like a car chaing a plane)
  37629. */
  37630. heightOffset: number;
  37631. /**
  37632. * Minimum allowed height of camera position relative to target object.
  37633. * This can help limiting how the Camera is able to move in the scene.
  37634. */
  37635. lowerHeightOffsetLimit: Nullable<number>;
  37636. /**
  37637. * Maximum allowed height of camera position relative to target object.
  37638. * This can help limiting how the Camera is able to move in the scene.
  37639. */
  37640. upperHeightOffsetLimit: Nullable<number>;
  37641. /**
  37642. * Define how fast the camera can accelerate to follow it s target.
  37643. */
  37644. cameraAcceleration: number;
  37645. /**
  37646. * Define the speed limit of the camera following an object.
  37647. */
  37648. maxCameraSpeed: number;
  37649. /**
  37650. * Define the target of the camera.
  37651. */
  37652. lockedTarget: Nullable<AbstractMesh>;
  37653. /**
  37654. * Defines the input associated with the camera.
  37655. */
  37656. inputs: FollowCameraInputsManager;
  37657. /**
  37658. * Instantiates the follow camera.
  37659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37660. * @param name Define the name of the camera in the scene
  37661. * @param position Define the position of the camera
  37662. * @param scene Define the scene the camera belong to
  37663. * @param lockedTarget Define the target of the camera
  37664. */
  37665. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37666. private _follow;
  37667. /**
  37668. * Attached controls to the current camera.
  37669. * @param element Defines the element the controls should be listened from
  37670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37671. */
  37672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37673. /**
  37674. * Detach the current controls from the camera.
  37675. * The camera will stop reacting to inputs.
  37676. * @param element Defines the element to stop listening the inputs from
  37677. */
  37678. detachControl(element: HTMLElement): void;
  37679. /** @hidden */
  37680. _checkInputs(): void;
  37681. private _checkLimits;
  37682. /**
  37683. * Gets the camera class name.
  37684. * @returns the class name
  37685. */
  37686. getClassName(): string;
  37687. }
  37688. /**
  37689. * Arc Rotate version of the follow camera.
  37690. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37692. */
  37693. export class ArcFollowCamera extends TargetCamera {
  37694. /** The longitudinal angle of the camera */
  37695. alpha: number;
  37696. /** The latitudinal angle of the camera */
  37697. beta: number;
  37698. /** The radius of the camera from its target */
  37699. radius: number;
  37700. /** Define the camera target (the messh it should follow) */
  37701. target: Nullable<AbstractMesh>;
  37702. private _cartesianCoordinates;
  37703. /**
  37704. * Instantiates a new ArcFollowCamera
  37705. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37706. * @param name Define the name of the camera
  37707. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37708. * @param beta Define the rotation angle of the camera around the elevation axis
  37709. * @param radius Define the radius of the camera from its target point
  37710. * @param target Define the target of the camera
  37711. * @param scene Define the scene the camera belongs to
  37712. */
  37713. constructor(name: string,
  37714. /** The longitudinal angle of the camera */
  37715. alpha: number,
  37716. /** The latitudinal angle of the camera */
  37717. beta: number,
  37718. /** The radius of the camera from its target */
  37719. radius: number,
  37720. /** Define the camera target (the messh it should follow) */
  37721. target: Nullable<AbstractMesh>, scene: Scene);
  37722. private _follow;
  37723. /** @hidden */
  37724. _checkInputs(): void;
  37725. /**
  37726. * Returns the class name of the object.
  37727. * It is mostly used internally for serialization purposes.
  37728. */
  37729. getClassName(): string;
  37730. }
  37731. }
  37732. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37733. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37734. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37735. import { Nullable } from "babylonjs/types";
  37736. /**
  37737. * Manage the keyboard inputs to control the movement of a follow camera.
  37738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37739. */
  37740. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37741. /**
  37742. * Defines the camera the input is attached to.
  37743. */
  37744. camera: FollowCamera;
  37745. /**
  37746. * Defines the list of key codes associated with the up action (increase heightOffset)
  37747. */
  37748. keysHeightOffsetIncr: number[];
  37749. /**
  37750. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37751. */
  37752. keysHeightOffsetDecr: number[];
  37753. /**
  37754. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37755. */
  37756. keysHeightOffsetModifierAlt: boolean;
  37757. /**
  37758. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37759. */
  37760. keysHeightOffsetModifierCtrl: boolean;
  37761. /**
  37762. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37763. */
  37764. keysHeightOffsetModifierShift: boolean;
  37765. /**
  37766. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37767. */
  37768. keysRotationOffsetIncr: number[];
  37769. /**
  37770. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37771. */
  37772. keysRotationOffsetDecr: number[];
  37773. /**
  37774. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37775. */
  37776. keysRotationOffsetModifierAlt: boolean;
  37777. /**
  37778. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37779. */
  37780. keysRotationOffsetModifierCtrl: boolean;
  37781. /**
  37782. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37783. */
  37784. keysRotationOffsetModifierShift: boolean;
  37785. /**
  37786. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37787. */
  37788. keysRadiusIncr: number[];
  37789. /**
  37790. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37791. */
  37792. keysRadiusDecr: number[];
  37793. /**
  37794. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37795. */
  37796. keysRadiusModifierAlt: boolean;
  37797. /**
  37798. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37799. */
  37800. keysRadiusModifierCtrl: boolean;
  37801. /**
  37802. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37803. */
  37804. keysRadiusModifierShift: boolean;
  37805. /**
  37806. * Defines the rate of change of heightOffset.
  37807. */
  37808. heightSensibility: number;
  37809. /**
  37810. * Defines the rate of change of rotationOffset.
  37811. */
  37812. rotationSensibility: number;
  37813. /**
  37814. * Defines the rate of change of radius.
  37815. */
  37816. radiusSensibility: number;
  37817. private _keys;
  37818. private _ctrlPressed;
  37819. private _altPressed;
  37820. private _shiftPressed;
  37821. private _onCanvasBlurObserver;
  37822. private _onKeyboardObserver;
  37823. private _engine;
  37824. private _scene;
  37825. /**
  37826. * Attach the input controls to a specific dom element to get the input from.
  37827. * @param element Defines the element the controls should be listened from
  37828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37829. */
  37830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37831. /**
  37832. * Detach the current controls from the specified dom element.
  37833. * @param element Defines the element to stop listening the inputs from
  37834. */
  37835. detachControl(element: Nullable<HTMLElement>): void;
  37836. /**
  37837. * Update the current camera state depending on the inputs that have been used this frame.
  37838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37839. */
  37840. checkInputs(): void;
  37841. /**
  37842. * Gets the class name of the current input.
  37843. * @returns the class name
  37844. */
  37845. getClassName(): string;
  37846. /**
  37847. * Get the friendly name associated with the input class.
  37848. * @returns the input friendly name
  37849. */
  37850. getSimpleName(): string;
  37851. /**
  37852. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37853. * allow modification of the heightOffset value.
  37854. */
  37855. private _modifierHeightOffset;
  37856. /**
  37857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37858. * allow modification of the rotationOffset value.
  37859. */
  37860. private _modifierRotationOffset;
  37861. /**
  37862. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37863. * allow modification of the radius value.
  37864. */
  37865. private _modifierRadius;
  37866. }
  37867. }
  37868. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37869. import { Nullable } from "babylonjs/types";
  37870. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37872. import { Observable } from "babylonjs/Misc/observable";
  37873. module "babylonjs/Cameras/freeCameraInputsManager" {
  37874. interface FreeCameraInputsManager {
  37875. /**
  37876. * @hidden
  37877. */
  37878. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37879. /**
  37880. * Add orientation input support to the input manager.
  37881. * @returns the current input manager
  37882. */
  37883. addDeviceOrientation(): FreeCameraInputsManager;
  37884. }
  37885. }
  37886. /**
  37887. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37888. * Screen rotation is taken into account.
  37889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37890. */
  37891. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37892. private _camera;
  37893. private _screenOrientationAngle;
  37894. private _constantTranform;
  37895. private _screenQuaternion;
  37896. private _alpha;
  37897. private _beta;
  37898. private _gamma;
  37899. /**
  37900. * @hidden
  37901. */
  37902. _onDeviceOrientationChangedObservable: Observable<void>;
  37903. /**
  37904. * Instantiates a new input
  37905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37906. */
  37907. constructor();
  37908. /**
  37909. * Define the camera controlled by the input.
  37910. */
  37911. camera: FreeCamera;
  37912. /**
  37913. * Attach the input controls to a specific dom element to get the input from.
  37914. * @param element Defines the element the controls should be listened from
  37915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37916. */
  37917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37918. private _orientationChanged;
  37919. private _deviceOrientation;
  37920. /**
  37921. * Detach the current controls from the specified dom element.
  37922. * @param element Defines the element to stop listening the inputs from
  37923. */
  37924. detachControl(element: Nullable<HTMLElement>): void;
  37925. /**
  37926. * Update the current camera state depending on the inputs that have been used this frame.
  37927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37928. */
  37929. checkInputs(): void;
  37930. /**
  37931. * Gets the class name of the current intput.
  37932. * @returns the class name
  37933. */
  37934. getClassName(): string;
  37935. /**
  37936. * Get the friendly name associated with the input class.
  37937. * @returns the input friendly name
  37938. */
  37939. getSimpleName(): string;
  37940. }
  37941. }
  37942. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37943. import { Nullable } from "babylonjs/types";
  37944. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37946. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37947. /**
  37948. * Manage the gamepad inputs to control a free camera.
  37949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37950. */
  37951. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37952. /**
  37953. * Define the camera the input is attached to.
  37954. */
  37955. camera: FreeCamera;
  37956. /**
  37957. * Define the Gamepad controlling the input
  37958. */
  37959. gamepad: Nullable<Gamepad>;
  37960. /**
  37961. * Defines the gamepad rotation sensiblity.
  37962. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37963. */
  37964. gamepadAngularSensibility: number;
  37965. /**
  37966. * Defines the gamepad move sensiblity.
  37967. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37968. */
  37969. gamepadMoveSensibility: number;
  37970. private _onGamepadConnectedObserver;
  37971. private _onGamepadDisconnectedObserver;
  37972. private _cameraTransform;
  37973. private _deltaTransform;
  37974. private _vector3;
  37975. private _vector2;
  37976. /**
  37977. * Attach the input controls to a specific dom element to get the input from.
  37978. * @param element Defines the element the controls should be listened from
  37979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37980. */
  37981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37982. /**
  37983. * Detach the current controls from the specified dom element.
  37984. * @param element Defines the element to stop listening the inputs from
  37985. */
  37986. detachControl(element: Nullable<HTMLElement>): void;
  37987. /**
  37988. * Update the current camera state depending on the inputs that have been used this frame.
  37989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37990. */
  37991. checkInputs(): void;
  37992. /**
  37993. * Gets the class name of the current intput.
  37994. * @returns the class name
  37995. */
  37996. getClassName(): string;
  37997. /**
  37998. * Get the friendly name associated with the input class.
  37999. * @returns the input friendly name
  38000. */
  38001. getSimpleName(): string;
  38002. }
  38003. }
  38004. declare module "babylonjs/Misc/virtualJoystick" {
  38005. import { Nullable } from "babylonjs/types";
  38006. import { Vector3 } from "babylonjs/Maths/math";
  38007. /**
  38008. * Defines the potential axis of a Joystick
  38009. */
  38010. export enum JoystickAxis {
  38011. /** X axis */
  38012. X = 0,
  38013. /** Y axis */
  38014. Y = 1,
  38015. /** Z axis */
  38016. Z = 2
  38017. }
  38018. /**
  38019. * Class used to define virtual joystick (used in touch mode)
  38020. */
  38021. export class VirtualJoystick {
  38022. /**
  38023. * Gets or sets a boolean indicating that left and right values must be inverted
  38024. */
  38025. reverseLeftRight: boolean;
  38026. /**
  38027. * Gets or sets a boolean indicating that up and down values must be inverted
  38028. */
  38029. reverseUpDown: boolean;
  38030. /**
  38031. * Gets the offset value for the position (ie. the change of the position value)
  38032. */
  38033. deltaPosition: Vector3;
  38034. /**
  38035. * Gets a boolean indicating if the virtual joystick was pressed
  38036. */
  38037. pressed: boolean;
  38038. /**
  38039. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38040. */
  38041. static Canvas: Nullable<HTMLCanvasElement>;
  38042. private static _globalJoystickIndex;
  38043. private static vjCanvasContext;
  38044. private static vjCanvasWidth;
  38045. private static vjCanvasHeight;
  38046. private static halfWidth;
  38047. private _action;
  38048. private _axisTargetedByLeftAndRight;
  38049. private _axisTargetedByUpAndDown;
  38050. private _joystickSensibility;
  38051. private _inversedSensibility;
  38052. private _joystickPointerID;
  38053. private _joystickColor;
  38054. private _joystickPointerPos;
  38055. private _joystickPreviousPointerPos;
  38056. private _joystickPointerStartPos;
  38057. private _deltaJoystickVector;
  38058. private _leftJoystick;
  38059. private _touches;
  38060. private _onPointerDownHandlerRef;
  38061. private _onPointerMoveHandlerRef;
  38062. private _onPointerUpHandlerRef;
  38063. private _onResize;
  38064. /**
  38065. * Creates a new virtual joystick
  38066. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38067. */
  38068. constructor(leftJoystick?: boolean);
  38069. /**
  38070. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38071. * @param newJoystickSensibility defines the new sensibility
  38072. */
  38073. setJoystickSensibility(newJoystickSensibility: number): void;
  38074. private _onPointerDown;
  38075. private _onPointerMove;
  38076. private _onPointerUp;
  38077. /**
  38078. * Change the color of the virtual joystick
  38079. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38080. */
  38081. setJoystickColor(newColor: string): void;
  38082. /**
  38083. * Defines a callback to call when the joystick is touched
  38084. * @param action defines the callback
  38085. */
  38086. setActionOnTouch(action: () => any): void;
  38087. /**
  38088. * Defines which axis you'd like to control for left & right
  38089. * @param axis defines the axis to use
  38090. */
  38091. setAxisForLeftRight(axis: JoystickAxis): void;
  38092. /**
  38093. * Defines which axis you'd like to control for up & down
  38094. * @param axis defines the axis to use
  38095. */
  38096. setAxisForUpDown(axis: JoystickAxis): void;
  38097. private _drawVirtualJoystick;
  38098. /**
  38099. * Release internal HTML canvas
  38100. */
  38101. releaseCanvas(): void;
  38102. }
  38103. }
  38104. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38105. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38106. import { Nullable } from "babylonjs/types";
  38107. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38108. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38109. module "babylonjs/Cameras/freeCameraInputsManager" {
  38110. interface FreeCameraInputsManager {
  38111. /**
  38112. * Add virtual joystick input support to the input manager.
  38113. * @returns the current input manager
  38114. */
  38115. addVirtualJoystick(): FreeCameraInputsManager;
  38116. }
  38117. }
  38118. /**
  38119. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38121. */
  38122. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38123. /**
  38124. * Defines the camera the input is attached to.
  38125. */
  38126. camera: FreeCamera;
  38127. private _leftjoystick;
  38128. private _rightjoystick;
  38129. /**
  38130. * Gets the left stick of the virtual joystick.
  38131. * @returns The virtual Joystick
  38132. */
  38133. getLeftJoystick(): VirtualJoystick;
  38134. /**
  38135. * Gets the right stick of the virtual joystick.
  38136. * @returns The virtual Joystick
  38137. */
  38138. getRightJoystick(): VirtualJoystick;
  38139. /**
  38140. * Update the current camera state depending on the inputs that have been used this frame.
  38141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38142. */
  38143. checkInputs(): void;
  38144. /**
  38145. * Attach the input controls to a specific dom element to get the input from.
  38146. * @param element Defines the element the controls should be listened from
  38147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38148. */
  38149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38150. /**
  38151. * Detach the current controls from the specified dom element.
  38152. * @param element Defines the element to stop listening the inputs from
  38153. */
  38154. detachControl(element: Nullable<HTMLElement>): void;
  38155. /**
  38156. * Gets the class name of the current intput.
  38157. * @returns the class name
  38158. */
  38159. getClassName(): string;
  38160. /**
  38161. * Get the friendly name associated with the input class.
  38162. * @returns the input friendly name
  38163. */
  38164. getSimpleName(): string;
  38165. }
  38166. }
  38167. declare module "babylonjs/Cameras/Inputs/index" {
  38168. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38169. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38170. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38171. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38172. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38173. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38174. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38175. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38176. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38177. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38178. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38179. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38180. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38181. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38182. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38183. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38184. }
  38185. declare module "babylonjs/Cameras/touchCamera" {
  38186. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38187. import { Scene } from "babylonjs/scene";
  38188. import { Vector3 } from "babylonjs/Maths/math";
  38189. /**
  38190. * This represents a FPS type of camera controlled by touch.
  38191. * This is like a universal camera minus the Gamepad controls.
  38192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38193. */
  38194. export class TouchCamera extends FreeCamera {
  38195. /**
  38196. * Defines the touch sensibility for rotation.
  38197. * The higher the faster.
  38198. */
  38199. touchAngularSensibility: number;
  38200. /**
  38201. * Defines the touch sensibility for move.
  38202. * The higher the faster.
  38203. */
  38204. touchMoveSensibility: number;
  38205. /**
  38206. * Instantiates a new touch camera.
  38207. * This represents a FPS type of camera controlled by touch.
  38208. * This is like a universal camera minus the Gamepad controls.
  38209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38210. * @param name Define the name of the camera in the scene
  38211. * @param position Define the start position of the camera in the scene
  38212. * @param scene Define the scene the camera belongs to
  38213. */
  38214. constructor(name: string, position: Vector3, scene: Scene);
  38215. /**
  38216. * Gets the current object class name.
  38217. * @return the class name
  38218. */
  38219. getClassName(): string;
  38220. /** @hidden */
  38221. _setupInputs(): void;
  38222. }
  38223. }
  38224. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38226. import { Scene } from "babylonjs/scene";
  38227. import { Vector3, Axis } from "babylonjs/Maths/math";
  38228. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38229. /**
  38230. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38231. * being tilted forward or back and left or right.
  38232. */
  38233. export class DeviceOrientationCamera extends FreeCamera {
  38234. private _initialQuaternion;
  38235. private _quaternionCache;
  38236. private _tmpDragQuaternion;
  38237. /**
  38238. * Creates a new device orientation camera
  38239. * @param name The name of the camera
  38240. * @param position The start position camera
  38241. * @param scene The scene the camera belongs to
  38242. */
  38243. constructor(name: string, position: Vector3, scene: Scene);
  38244. /**
  38245. * Disabled pointer input on first orientation sensor update (Default: true)
  38246. */
  38247. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38248. private _dragFactor;
  38249. /**
  38250. * Enabled turning on the y axis when the orientation sensor is active
  38251. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38252. */
  38253. enableHorizontalDragging(dragFactor?: number): void;
  38254. /**
  38255. * Gets the current instance class name ("DeviceOrientationCamera").
  38256. * This helps avoiding instanceof at run time.
  38257. * @returns the class name
  38258. */
  38259. getClassName(): string;
  38260. /**
  38261. * @hidden
  38262. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38263. */
  38264. _checkInputs(): void;
  38265. /**
  38266. * Reset the camera to its default orientation on the specified axis only.
  38267. * @param axis The axis to reset
  38268. */
  38269. resetToCurrentRotation(axis?: Axis): void;
  38270. }
  38271. }
  38272. declare module "babylonjs/Cameras/universalCamera" {
  38273. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38274. import { Scene } from "babylonjs/scene";
  38275. import { Vector3 } from "babylonjs/Maths/math";
  38276. /**
  38277. * 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,
  38278. * which still works and will still be found in many Playgrounds.
  38279. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38280. */
  38281. export class UniversalCamera extends TouchCamera {
  38282. /**
  38283. * Defines the gamepad rotation sensiblity.
  38284. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38285. */
  38286. gamepadAngularSensibility: number;
  38287. /**
  38288. * Defines the gamepad move sensiblity.
  38289. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38290. */
  38291. gamepadMoveSensibility: number;
  38292. /**
  38293. * 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,
  38294. * which still works and will still be found in many Playgrounds.
  38295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38296. * @param name Define the name of the camera in the scene
  38297. * @param position Define the start position of the camera in the scene
  38298. * @param scene Define the scene the camera belongs to
  38299. */
  38300. constructor(name: string, position: Vector3, scene: Scene);
  38301. /**
  38302. * Gets the current object class name.
  38303. * @return the class name
  38304. */
  38305. getClassName(): string;
  38306. }
  38307. }
  38308. declare module "babylonjs/Cameras/gamepadCamera" {
  38309. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38310. import { Scene } from "babylonjs/scene";
  38311. import { Vector3 } from "babylonjs/Maths/math";
  38312. /**
  38313. * This represents a FPS type of camera. This is only here for back compat purpose.
  38314. * Please use the UniversalCamera instead as both are identical.
  38315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38316. */
  38317. export class GamepadCamera extends UniversalCamera {
  38318. /**
  38319. * Instantiates a new Gamepad Camera
  38320. * This represents a FPS type of camera. This is only here for back compat purpose.
  38321. * Please use the UniversalCamera instead as both are identical.
  38322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38323. * @param name Define the name of the camera in the scene
  38324. * @param position Define the start position of the camera in the scene
  38325. * @param scene Define the scene the camera belongs to
  38326. */
  38327. constructor(name: string, position: Vector3, scene: Scene);
  38328. /**
  38329. * Gets the current object class name.
  38330. * @return the class name
  38331. */
  38332. getClassName(): string;
  38333. }
  38334. }
  38335. declare module "babylonjs/Shaders/pass.fragment" {
  38336. /** @hidden */
  38337. export var passPixelShader: {
  38338. name: string;
  38339. shader: string;
  38340. };
  38341. }
  38342. declare module "babylonjs/Shaders/passCube.fragment" {
  38343. /** @hidden */
  38344. export var passCubePixelShader: {
  38345. name: string;
  38346. shader: string;
  38347. };
  38348. }
  38349. declare module "babylonjs/PostProcesses/passPostProcess" {
  38350. import { Nullable } from "babylonjs/types";
  38351. import { Camera } from "babylonjs/Cameras/camera";
  38352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38353. import { Engine } from "babylonjs/Engines/engine";
  38354. import "babylonjs/Shaders/pass.fragment";
  38355. import "babylonjs/Shaders/passCube.fragment";
  38356. /**
  38357. * PassPostProcess which produces an output the same as it's input
  38358. */
  38359. export class PassPostProcess extends PostProcess {
  38360. /**
  38361. * Creates the PassPostProcess
  38362. * @param name The name of the effect.
  38363. * @param options The required width/height ratio to downsize to before computing the render pass.
  38364. * @param camera The camera to apply the render pass to.
  38365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38366. * @param engine The engine which the post process will be applied. (default: current engine)
  38367. * @param reusable If the post process can be reused on the same frame. (default: false)
  38368. * @param textureType The type of texture to be used when performing the post processing.
  38369. * @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)
  38370. */
  38371. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38372. }
  38373. /**
  38374. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38375. */
  38376. export class PassCubePostProcess extends PostProcess {
  38377. private _face;
  38378. /**
  38379. * Gets or sets the cube face to display.
  38380. * * 0 is +X
  38381. * * 1 is -X
  38382. * * 2 is +Y
  38383. * * 3 is -Y
  38384. * * 4 is +Z
  38385. * * 5 is -Z
  38386. */
  38387. face: number;
  38388. /**
  38389. * Creates the PassCubePostProcess
  38390. * @param name The name of the effect.
  38391. * @param options The required width/height ratio to downsize to before computing the render pass.
  38392. * @param camera The camera to apply the render pass to.
  38393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38394. * @param engine The engine which the post process will be applied. (default: current engine)
  38395. * @param reusable If the post process can be reused on the same frame. (default: false)
  38396. * @param textureType The type of texture to be used when performing the post processing.
  38397. * @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)
  38398. */
  38399. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38400. }
  38401. }
  38402. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38403. /** @hidden */
  38404. export var anaglyphPixelShader: {
  38405. name: string;
  38406. shader: string;
  38407. };
  38408. }
  38409. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38410. import { Engine } from "babylonjs/Engines/engine";
  38411. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38412. import { Camera } from "babylonjs/Cameras/camera";
  38413. import "babylonjs/Shaders/anaglyph.fragment";
  38414. /**
  38415. * Postprocess used to generate anaglyphic rendering
  38416. */
  38417. export class AnaglyphPostProcess extends PostProcess {
  38418. private _passedProcess;
  38419. /**
  38420. * Creates a new AnaglyphPostProcess
  38421. * @param name defines postprocess name
  38422. * @param options defines creation options or target ratio scale
  38423. * @param rigCameras defines cameras using this postprocess
  38424. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38425. * @param engine defines hosting engine
  38426. * @param reusable defines if the postprocess will be reused multiple times per frame
  38427. */
  38428. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38429. }
  38430. }
  38431. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38432. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38433. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38434. import { Scene } from "babylonjs/scene";
  38435. import { Vector3 } from "babylonjs/Maths/math";
  38436. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38437. /**
  38438. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38440. */
  38441. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38442. /**
  38443. * Creates a new AnaglyphArcRotateCamera
  38444. * @param name defines camera name
  38445. * @param alpha defines alpha angle (in radians)
  38446. * @param beta defines beta angle (in radians)
  38447. * @param radius defines radius
  38448. * @param target defines camera target
  38449. * @param interaxialDistance defines distance between each color axis
  38450. * @param scene defines the hosting scene
  38451. */
  38452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38453. /**
  38454. * Gets camera class name
  38455. * @returns AnaglyphArcRotateCamera
  38456. */
  38457. getClassName(): string;
  38458. }
  38459. }
  38460. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38461. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38462. import { Scene } from "babylonjs/scene";
  38463. import { Vector3 } from "babylonjs/Maths/math";
  38464. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38465. /**
  38466. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38467. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38468. */
  38469. export class AnaglyphFreeCamera extends FreeCamera {
  38470. /**
  38471. * Creates a new AnaglyphFreeCamera
  38472. * @param name defines camera name
  38473. * @param position defines initial position
  38474. * @param interaxialDistance defines distance between each color axis
  38475. * @param scene defines the hosting scene
  38476. */
  38477. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38478. /**
  38479. * Gets camera class name
  38480. * @returns AnaglyphFreeCamera
  38481. */
  38482. getClassName(): string;
  38483. }
  38484. }
  38485. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38486. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38487. import { Scene } from "babylonjs/scene";
  38488. import { Vector3 } from "babylonjs/Maths/math";
  38489. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38490. /**
  38491. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38492. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38493. */
  38494. export class AnaglyphGamepadCamera extends GamepadCamera {
  38495. /**
  38496. * Creates a new AnaglyphGamepadCamera
  38497. * @param name defines camera name
  38498. * @param position defines initial position
  38499. * @param interaxialDistance defines distance between each color axis
  38500. * @param scene defines the hosting scene
  38501. */
  38502. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38503. /**
  38504. * Gets camera class name
  38505. * @returns AnaglyphGamepadCamera
  38506. */
  38507. getClassName(): string;
  38508. }
  38509. }
  38510. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38511. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38512. import { Scene } from "babylonjs/scene";
  38513. import { Vector3 } from "babylonjs/Maths/math";
  38514. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38515. /**
  38516. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38517. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38518. */
  38519. export class AnaglyphUniversalCamera extends UniversalCamera {
  38520. /**
  38521. * Creates a new AnaglyphUniversalCamera
  38522. * @param name defines camera name
  38523. * @param position defines initial position
  38524. * @param interaxialDistance defines distance between each color axis
  38525. * @param scene defines the hosting scene
  38526. */
  38527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38528. /**
  38529. * Gets camera class name
  38530. * @returns AnaglyphUniversalCamera
  38531. */
  38532. getClassName(): string;
  38533. }
  38534. }
  38535. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38536. /** @hidden */
  38537. export var stereoscopicInterlacePixelShader: {
  38538. name: string;
  38539. shader: string;
  38540. };
  38541. }
  38542. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38543. import { Camera } from "babylonjs/Cameras/camera";
  38544. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38545. import { Engine } from "babylonjs/Engines/engine";
  38546. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38547. /**
  38548. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38549. */
  38550. export class StereoscopicInterlacePostProcess extends PostProcess {
  38551. private _stepSize;
  38552. private _passedProcess;
  38553. /**
  38554. * Initializes a StereoscopicInterlacePostProcess
  38555. * @param name The name of the effect.
  38556. * @param rigCameras The rig cameras to be appled to the post process
  38557. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38559. * @param engine The engine which the post process will be applied. (default: current engine)
  38560. * @param reusable If the post process can be reused on the same frame. (default: false)
  38561. */
  38562. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38563. }
  38564. }
  38565. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38566. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38568. import { Scene } from "babylonjs/scene";
  38569. import { Vector3 } from "babylonjs/Maths/math";
  38570. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38571. /**
  38572. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38573. * @see http://doc.babylonjs.com/features/cameras
  38574. */
  38575. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38576. /**
  38577. * Creates a new StereoscopicArcRotateCamera
  38578. * @param name defines camera name
  38579. * @param alpha defines alpha angle (in radians)
  38580. * @param beta defines beta angle (in radians)
  38581. * @param radius defines radius
  38582. * @param target defines camera target
  38583. * @param interaxialDistance defines distance between each color axis
  38584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38585. * @param scene defines the hosting scene
  38586. */
  38587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38588. /**
  38589. * Gets camera class name
  38590. * @returns StereoscopicArcRotateCamera
  38591. */
  38592. getClassName(): string;
  38593. }
  38594. }
  38595. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38596. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38597. import { Scene } from "babylonjs/scene";
  38598. import { Vector3 } from "babylonjs/Maths/math";
  38599. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38600. /**
  38601. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38602. * @see http://doc.babylonjs.com/features/cameras
  38603. */
  38604. export class StereoscopicFreeCamera extends FreeCamera {
  38605. /**
  38606. * Creates a new StereoscopicFreeCamera
  38607. * @param name defines camera name
  38608. * @param position defines initial position
  38609. * @param interaxialDistance defines distance between each color axis
  38610. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38611. * @param scene defines the hosting scene
  38612. */
  38613. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38614. /**
  38615. * Gets camera class name
  38616. * @returns StereoscopicFreeCamera
  38617. */
  38618. getClassName(): string;
  38619. }
  38620. }
  38621. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38622. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38623. import { Scene } from "babylonjs/scene";
  38624. import { Vector3 } from "babylonjs/Maths/math";
  38625. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38626. /**
  38627. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38628. * @see http://doc.babylonjs.com/features/cameras
  38629. */
  38630. export class StereoscopicGamepadCamera extends GamepadCamera {
  38631. /**
  38632. * Creates a new StereoscopicGamepadCamera
  38633. * @param name defines camera name
  38634. * @param position defines initial position
  38635. * @param interaxialDistance defines distance between each color axis
  38636. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38637. * @param scene defines the hosting scene
  38638. */
  38639. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38640. /**
  38641. * Gets camera class name
  38642. * @returns StereoscopicGamepadCamera
  38643. */
  38644. getClassName(): string;
  38645. }
  38646. }
  38647. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38648. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38649. import { Scene } from "babylonjs/scene";
  38650. import { Vector3 } from "babylonjs/Maths/math";
  38651. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38652. /**
  38653. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38654. * @see http://doc.babylonjs.com/features/cameras
  38655. */
  38656. export class StereoscopicUniversalCamera extends UniversalCamera {
  38657. /**
  38658. * Creates a new StereoscopicUniversalCamera
  38659. * @param name defines camera name
  38660. * @param position defines initial position
  38661. * @param interaxialDistance defines distance between each color axis
  38662. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38663. * @param scene defines the hosting scene
  38664. */
  38665. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38666. /**
  38667. * Gets camera class name
  38668. * @returns StereoscopicUniversalCamera
  38669. */
  38670. getClassName(): string;
  38671. }
  38672. }
  38673. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38674. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38675. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38676. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38677. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38678. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38679. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38680. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38681. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38682. }
  38683. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38684. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38685. import { Scene } from "babylonjs/scene";
  38686. import { Vector3 } from "babylonjs/Maths/math";
  38687. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38688. /**
  38689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38690. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38691. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38692. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38693. */
  38694. export class VirtualJoysticksCamera extends FreeCamera {
  38695. /**
  38696. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38697. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38698. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38699. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38700. * @param name Define the name of the camera in the scene
  38701. * @param position Define the start position of the camera in the scene
  38702. * @param scene Define the scene the camera belongs to
  38703. */
  38704. constructor(name: string, position: Vector3, scene: Scene);
  38705. /**
  38706. * Gets the current object class name.
  38707. * @return the class name
  38708. */
  38709. getClassName(): string;
  38710. }
  38711. }
  38712. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38713. import { Matrix } from "babylonjs/Maths/math";
  38714. /**
  38715. * This represents all the required metrics to create a VR camera.
  38716. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38717. */
  38718. export class VRCameraMetrics {
  38719. /**
  38720. * Define the horizontal resolution off the screen.
  38721. */
  38722. hResolution: number;
  38723. /**
  38724. * Define the vertical resolution off the screen.
  38725. */
  38726. vResolution: number;
  38727. /**
  38728. * Define the horizontal screen size.
  38729. */
  38730. hScreenSize: number;
  38731. /**
  38732. * Define the vertical screen size.
  38733. */
  38734. vScreenSize: number;
  38735. /**
  38736. * Define the vertical screen center position.
  38737. */
  38738. vScreenCenter: number;
  38739. /**
  38740. * Define the distance of the eyes to the screen.
  38741. */
  38742. eyeToScreenDistance: number;
  38743. /**
  38744. * Define the distance between both lenses
  38745. */
  38746. lensSeparationDistance: number;
  38747. /**
  38748. * Define the distance between both viewer's eyes.
  38749. */
  38750. interpupillaryDistance: number;
  38751. /**
  38752. * Define the distortion factor of the VR postprocess.
  38753. * Please, touch with care.
  38754. */
  38755. distortionK: number[];
  38756. /**
  38757. * Define the chromatic aberration correction factors for the VR post process.
  38758. */
  38759. chromaAbCorrection: number[];
  38760. /**
  38761. * Define the scale factor of the post process.
  38762. * The smaller the better but the slower.
  38763. */
  38764. postProcessScaleFactor: number;
  38765. /**
  38766. * Define an offset for the lens center.
  38767. */
  38768. lensCenterOffset: number;
  38769. /**
  38770. * Define if the current vr camera should compensate the distortion of the lense or not.
  38771. */
  38772. compensateDistortion: boolean;
  38773. /**
  38774. * Defines if multiview should be enabled when rendering (Default: false)
  38775. */
  38776. multiviewEnabled: boolean;
  38777. /**
  38778. * Gets the rendering aspect ratio based on the provided resolutions.
  38779. */
  38780. readonly aspectRatio: number;
  38781. /**
  38782. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38783. */
  38784. readonly aspectRatioFov: number;
  38785. /**
  38786. * @hidden
  38787. */
  38788. readonly leftHMatrix: Matrix;
  38789. /**
  38790. * @hidden
  38791. */
  38792. readonly rightHMatrix: Matrix;
  38793. /**
  38794. * @hidden
  38795. */
  38796. readonly leftPreViewMatrix: Matrix;
  38797. /**
  38798. * @hidden
  38799. */
  38800. readonly rightPreViewMatrix: Matrix;
  38801. /**
  38802. * Get the default VRMetrics based on the most generic setup.
  38803. * @returns the default vr metrics
  38804. */
  38805. static GetDefault(): VRCameraMetrics;
  38806. }
  38807. }
  38808. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38809. /** @hidden */
  38810. export var vrDistortionCorrectionPixelShader: {
  38811. name: string;
  38812. shader: string;
  38813. };
  38814. }
  38815. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38816. import { Camera } from "babylonjs/Cameras/camera";
  38817. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38819. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38820. /**
  38821. * VRDistortionCorrectionPostProcess used for mobile VR
  38822. */
  38823. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38824. private _isRightEye;
  38825. private _distortionFactors;
  38826. private _postProcessScaleFactor;
  38827. private _lensCenterOffset;
  38828. private _scaleIn;
  38829. private _scaleFactor;
  38830. private _lensCenter;
  38831. /**
  38832. * Initializes the VRDistortionCorrectionPostProcess
  38833. * @param name The name of the effect.
  38834. * @param camera The camera to apply the render pass to.
  38835. * @param isRightEye If this is for the right eye distortion
  38836. * @param vrMetrics All the required metrics for the VR camera
  38837. */
  38838. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38839. }
  38840. }
  38841. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38842. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38843. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38844. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38845. import { Scene } from "babylonjs/scene";
  38846. import { Vector3 } from "babylonjs/Maths/math";
  38847. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38848. import "babylonjs/Cameras/RigModes/vrRigMode";
  38849. /**
  38850. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38851. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38852. */
  38853. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38854. /**
  38855. * Creates a new VRDeviceOrientationArcRotateCamera
  38856. * @param name defines camera name
  38857. * @param alpha defines the camera rotation along the logitudinal axis
  38858. * @param beta defines the camera rotation along the latitudinal axis
  38859. * @param radius defines the camera distance from its target
  38860. * @param target defines the camera target
  38861. * @param scene defines the scene the camera belongs to
  38862. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38863. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38864. */
  38865. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38866. /**
  38867. * Gets camera class name
  38868. * @returns VRDeviceOrientationArcRotateCamera
  38869. */
  38870. getClassName(): string;
  38871. }
  38872. }
  38873. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38874. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38875. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38876. import { Scene } from "babylonjs/scene";
  38877. import { Vector3 } from "babylonjs/Maths/math";
  38878. import "babylonjs/Cameras/RigModes/vrRigMode";
  38879. /**
  38880. * Camera used to simulate VR rendering (based on FreeCamera)
  38881. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38882. */
  38883. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38884. /**
  38885. * Creates a new VRDeviceOrientationFreeCamera
  38886. * @param name defines camera name
  38887. * @param position defines the start position of the camera
  38888. * @param scene defines the scene the camera belongs to
  38889. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38890. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38891. */
  38892. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38893. /**
  38894. * Gets camera class name
  38895. * @returns VRDeviceOrientationFreeCamera
  38896. */
  38897. getClassName(): string;
  38898. }
  38899. }
  38900. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38901. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38902. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38903. import { Scene } from "babylonjs/scene";
  38904. import { Vector3 } from "babylonjs/Maths/math";
  38905. /**
  38906. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38907. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38908. */
  38909. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38910. /**
  38911. * Creates a new VRDeviceOrientationGamepadCamera
  38912. * @param name defines camera name
  38913. * @param position defines the start position of the camera
  38914. * @param scene defines the scene the camera belongs to
  38915. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38916. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38917. */
  38918. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38919. /**
  38920. * Gets camera class name
  38921. * @returns VRDeviceOrientationGamepadCamera
  38922. */
  38923. getClassName(): string;
  38924. }
  38925. }
  38926. declare module "babylonjs/Gamepads/xboxGamepad" {
  38927. import { Observable } from "babylonjs/Misc/observable";
  38928. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38929. /**
  38930. * Defines supported buttons for XBox360 compatible gamepads
  38931. */
  38932. export enum Xbox360Button {
  38933. /** A */
  38934. A = 0,
  38935. /** B */
  38936. B = 1,
  38937. /** X */
  38938. X = 2,
  38939. /** Y */
  38940. Y = 3,
  38941. /** Start */
  38942. Start = 4,
  38943. /** Back */
  38944. Back = 5,
  38945. /** Left button */
  38946. LB = 6,
  38947. /** Right button */
  38948. RB = 7,
  38949. /** Left stick */
  38950. LeftStick = 8,
  38951. /** Right stick */
  38952. RightStick = 9
  38953. }
  38954. /** Defines values for XBox360 DPad */
  38955. export enum Xbox360Dpad {
  38956. /** Up */
  38957. Up = 0,
  38958. /** Down */
  38959. Down = 1,
  38960. /** Left */
  38961. Left = 2,
  38962. /** Right */
  38963. Right = 3
  38964. }
  38965. /**
  38966. * Defines a XBox360 gamepad
  38967. */
  38968. export class Xbox360Pad extends Gamepad {
  38969. private _leftTrigger;
  38970. private _rightTrigger;
  38971. private _onlefttriggerchanged;
  38972. private _onrighttriggerchanged;
  38973. private _onbuttondown;
  38974. private _onbuttonup;
  38975. private _ondpaddown;
  38976. private _ondpadup;
  38977. /** Observable raised when a button is pressed */
  38978. onButtonDownObservable: Observable<Xbox360Button>;
  38979. /** Observable raised when a button is released */
  38980. onButtonUpObservable: Observable<Xbox360Button>;
  38981. /** Observable raised when a pad is pressed */
  38982. onPadDownObservable: Observable<Xbox360Dpad>;
  38983. /** Observable raised when a pad is released */
  38984. onPadUpObservable: Observable<Xbox360Dpad>;
  38985. private _buttonA;
  38986. private _buttonB;
  38987. private _buttonX;
  38988. private _buttonY;
  38989. private _buttonBack;
  38990. private _buttonStart;
  38991. private _buttonLB;
  38992. private _buttonRB;
  38993. private _buttonLeftStick;
  38994. private _buttonRightStick;
  38995. private _dPadUp;
  38996. private _dPadDown;
  38997. private _dPadLeft;
  38998. private _dPadRight;
  38999. private _isXboxOnePad;
  39000. /**
  39001. * Creates a new XBox360 gamepad object
  39002. * @param id defines the id of this gamepad
  39003. * @param index defines its index
  39004. * @param gamepad defines the internal HTML gamepad object
  39005. * @param xboxOne defines if it is a XBox One gamepad
  39006. */
  39007. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39008. /**
  39009. * Defines the callback to call when left trigger is pressed
  39010. * @param callback defines the callback to use
  39011. */
  39012. onlefttriggerchanged(callback: (value: number) => void): void;
  39013. /**
  39014. * Defines the callback to call when right trigger is pressed
  39015. * @param callback defines the callback to use
  39016. */
  39017. onrighttriggerchanged(callback: (value: number) => void): void;
  39018. /**
  39019. * Gets the left trigger value
  39020. */
  39021. /**
  39022. * Sets the left trigger value
  39023. */
  39024. leftTrigger: number;
  39025. /**
  39026. * Gets the right trigger value
  39027. */
  39028. /**
  39029. * Sets the right trigger value
  39030. */
  39031. rightTrigger: number;
  39032. /**
  39033. * Defines the callback to call when a button is pressed
  39034. * @param callback defines the callback to use
  39035. */
  39036. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39037. /**
  39038. * Defines the callback to call when a button is released
  39039. * @param callback defines the callback to use
  39040. */
  39041. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39042. /**
  39043. * Defines the callback to call when a pad is pressed
  39044. * @param callback defines the callback to use
  39045. */
  39046. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39047. /**
  39048. * Defines the callback to call when a pad is released
  39049. * @param callback defines the callback to use
  39050. */
  39051. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39052. private _setButtonValue;
  39053. private _setDPadValue;
  39054. /**
  39055. * Gets the value of the `A` button
  39056. */
  39057. /**
  39058. * Sets the value of the `A` button
  39059. */
  39060. buttonA: number;
  39061. /**
  39062. * Gets the value of the `B` button
  39063. */
  39064. /**
  39065. * Sets the value of the `B` button
  39066. */
  39067. buttonB: number;
  39068. /**
  39069. * Gets the value of the `X` button
  39070. */
  39071. /**
  39072. * Sets the value of the `X` button
  39073. */
  39074. buttonX: number;
  39075. /**
  39076. * Gets the value of the `Y` button
  39077. */
  39078. /**
  39079. * Sets the value of the `Y` button
  39080. */
  39081. buttonY: number;
  39082. /**
  39083. * Gets the value of the `Start` button
  39084. */
  39085. /**
  39086. * Sets the value of the `Start` button
  39087. */
  39088. buttonStart: number;
  39089. /**
  39090. * Gets the value of the `Back` button
  39091. */
  39092. /**
  39093. * Sets the value of the `Back` button
  39094. */
  39095. buttonBack: number;
  39096. /**
  39097. * Gets the value of the `Left` button
  39098. */
  39099. /**
  39100. * Sets the value of the `Left` button
  39101. */
  39102. buttonLB: number;
  39103. /**
  39104. * Gets the value of the `Right` button
  39105. */
  39106. /**
  39107. * Sets the value of the `Right` button
  39108. */
  39109. buttonRB: number;
  39110. /**
  39111. * Gets the value of the Left joystick
  39112. */
  39113. /**
  39114. * Sets the value of the Left joystick
  39115. */
  39116. buttonLeftStick: number;
  39117. /**
  39118. * Gets the value of the Right joystick
  39119. */
  39120. /**
  39121. * Sets the value of the Right joystick
  39122. */
  39123. buttonRightStick: number;
  39124. /**
  39125. * Gets the value of D-pad up
  39126. */
  39127. /**
  39128. * Sets the value of D-pad up
  39129. */
  39130. dPadUp: number;
  39131. /**
  39132. * Gets the value of D-pad down
  39133. */
  39134. /**
  39135. * Sets the value of D-pad down
  39136. */
  39137. dPadDown: number;
  39138. /**
  39139. * Gets the value of D-pad left
  39140. */
  39141. /**
  39142. * Sets the value of D-pad left
  39143. */
  39144. dPadLeft: number;
  39145. /**
  39146. * Gets the value of D-pad right
  39147. */
  39148. /**
  39149. * Sets the value of D-pad right
  39150. */
  39151. dPadRight: number;
  39152. /**
  39153. * Force the gamepad to synchronize with device values
  39154. */
  39155. update(): void;
  39156. /**
  39157. * Disposes the gamepad
  39158. */
  39159. dispose(): void;
  39160. }
  39161. }
  39162. declare module "babylonjs/Materials/pushMaterial" {
  39163. import { Nullable } from "babylonjs/types";
  39164. import { Scene } from "babylonjs/scene";
  39165. import { Matrix } from "babylonjs/Maths/math";
  39166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39167. import { Mesh } from "babylonjs/Meshes/mesh";
  39168. import { Material } from "babylonjs/Materials/material";
  39169. import { Effect } from "babylonjs/Materials/effect";
  39170. /**
  39171. * Base class of materials working in push mode in babylon JS
  39172. * @hidden
  39173. */
  39174. export class PushMaterial extends Material {
  39175. protected _activeEffect: Effect;
  39176. protected _normalMatrix: Matrix;
  39177. /**
  39178. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39179. * This means that the material can keep using a previous shader while a new one is being compiled.
  39180. * This is mostly used when shader parallel compilation is supported (true by default)
  39181. */
  39182. allowShaderHotSwapping: boolean;
  39183. constructor(name: string, scene: Scene);
  39184. getEffect(): Effect;
  39185. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39186. /**
  39187. * Binds the given world matrix to the active effect
  39188. *
  39189. * @param world the matrix to bind
  39190. */
  39191. bindOnlyWorldMatrix(world: Matrix): void;
  39192. /**
  39193. * Binds the given normal matrix to the active effect
  39194. *
  39195. * @param normalMatrix the matrix to bind
  39196. */
  39197. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39198. bind(world: Matrix, mesh?: Mesh): void;
  39199. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39200. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39201. }
  39202. }
  39203. declare module "babylonjs/Materials/materialFlags" {
  39204. /**
  39205. * This groups all the flags used to control the materials channel.
  39206. */
  39207. export class MaterialFlags {
  39208. private static _DiffuseTextureEnabled;
  39209. /**
  39210. * Are diffuse textures enabled in the application.
  39211. */
  39212. static DiffuseTextureEnabled: boolean;
  39213. private static _AmbientTextureEnabled;
  39214. /**
  39215. * Are ambient textures enabled in the application.
  39216. */
  39217. static AmbientTextureEnabled: boolean;
  39218. private static _OpacityTextureEnabled;
  39219. /**
  39220. * Are opacity textures enabled in the application.
  39221. */
  39222. static OpacityTextureEnabled: boolean;
  39223. private static _ReflectionTextureEnabled;
  39224. /**
  39225. * Are reflection textures enabled in the application.
  39226. */
  39227. static ReflectionTextureEnabled: boolean;
  39228. private static _EmissiveTextureEnabled;
  39229. /**
  39230. * Are emissive textures enabled in the application.
  39231. */
  39232. static EmissiveTextureEnabled: boolean;
  39233. private static _SpecularTextureEnabled;
  39234. /**
  39235. * Are specular textures enabled in the application.
  39236. */
  39237. static SpecularTextureEnabled: boolean;
  39238. private static _BumpTextureEnabled;
  39239. /**
  39240. * Are bump textures enabled in the application.
  39241. */
  39242. static BumpTextureEnabled: boolean;
  39243. private static _LightmapTextureEnabled;
  39244. /**
  39245. * Are lightmap textures enabled in the application.
  39246. */
  39247. static LightmapTextureEnabled: boolean;
  39248. private static _RefractionTextureEnabled;
  39249. /**
  39250. * Are refraction textures enabled in the application.
  39251. */
  39252. static RefractionTextureEnabled: boolean;
  39253. private static _ColorGradingTextureEnabled;
  39254. /**
  39255. * Are color grading textures enabled in the application.
  39256. */
  39257. static ColorGradingTextureEnabled: boolean;
  39258. private static _FresnelEnabled;
  39259. /**
  39260. * Are fresnels enabled in the application.
  39261. */
  39262. static FresnelEnabled: boolean;
  39263. private static _ClearCoatTextureEnabled;
  39264. /**
  39265. * Are clear coat textures enabled in the application.
  39266. */
  39267. static ClearCoatTextureEnabled: boolean;
  39268. private static _ClearCoatBumpTextureEnabled;
  39269. /**
  39270. * Are clear coat bump textures enabled in the application.
  39271. */
  39272. static ClearCoatBumpTextureEnabled: boolean;
  39273. private static _ClearCoatTintTextureEnabled;
  39274. /**
  39275. * Are clear coat tint textures enabled in the application.
  39276. */
  39277. static ClearCoatTintTextureEnabled: boolean;
  39278. private static _SheenTextureEnabled;
  39279. /**
  39280. * Are sheen textures enabled in the application.
  39281. */
  39282. static SheenTextureEnabled: boolean;
  39283. private static _AnisotropicTextureEnabled;
  39284. /**
  39285. * Are anisotropic textures enabled in the application.
  39286. */
  39287. static AnisotropicTextureEnabled: boolean;
  39288. private static _ThicknessTextureEnabled;
  39289. /**
  39290. * Are thickness textures enabled in the application.
  39291. */
  39292. static ThicknessTextureEnabled: boolean;
  39293. }
  39294. }
  39295. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39296. /** @hidden */
  39297. export var defaultFragmentDeclaration: {
  39298. name: string;
  39299. shader: string;
  39300. };
  39301. }
  39302. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39303. /** @hidden */
  39304. export var defaultUboDeclaration: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39310. /** @hidden */
  39311. export var lightFragmentDeclaration: {
  39312. name: string;
  39313. shader: string;
  39314. };
  39315. }
  39316. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39317. /** @hidden */
  39318. export var lightUboDeclaration: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39324. /** @hidden */
  39325. export var lightsFragmentFunctions: {
  39326. name: string;
  39327. shader: string;
  39328. };
  39329. }
  39330. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39331. /** @hidden */
  39332. export var shadowsFragmentFunctions: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39338. /** @hidden */
  39339. export var fresnelFunction: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39345. /** @hidden */
  39346. export var reflectionFunction: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39352. /** @hidden */
  39353. export var bumpFragmentFunctions: {
  39354. name: string;
  39355. shader: string;
  39356. };
  39357. }
  39358. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39359. /** @hidden */
  39360. export var logDepthDeclaration: {
  39361. name: string;
  39362. shader: string;
  39363. };
  39364. }
  39365. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39366. /** @hidden */
  39367. export var bumpFragment: {
  39368. name: string;
  39369. shader: string;
  39370. };
  39371. }
  39372. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39373. /** @hidden */
  39374. export var depthPrePass: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39380. /** @hidden */
  39381. export var lightFragment: {
  39382. name: string;
  39383. shader: string;
  39384. };
  39385. }
  39386. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39387. /** @hidden */
  39388. export var logDepthFragment: {
  39389. name: string;
  39390. shader: string;
  39391. };
  39392. }
  39393. declare module "babylonjs/Shaders/default.fragment" {
  39394. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39395. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39396. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39397. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39398. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39399. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39400. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39401. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39402. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39403. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39404. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39405. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39406. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39407. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39408. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39409. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39410. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39411. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39412. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39413. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39414. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39415. /** @hidden */
  39416. export var defaultPixelShader: {
  39417. name: string;
  39418. shader: string;
  39419. };
  39420. }
  39421. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39422. /** @hidden */
  39423. export var defaultVertexDeclaration: {
  39424. name: string;
  39425. shader: string;
  39426. };
  39427. }
  39428. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39429. /** @hidden */
  39430. export var bumpVertexDeclaration: {
  39431. name: string;
  39432. shader: string;
  39433. };
  39434. }
  39435. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39436. /** @hidden */
  39437. export var bumpVertex: {
  39438. name: string;
  39439. shader: string;
  39440. };
  39441. }
  39442. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39443. /** @hidden */
  39444. export var fogVertex: {
  39445. name: string;
  39446. shader: string;
  39447. };
  39448. }
  39449. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39450. /** @hidden */
  39451. export var shadowsVertex: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39457. /** @hidden */
  39458. export var pointCloudVertex: {
  39459. name: string;
  39460. shader: string;
  39461. };
  39462. }
  39463. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39464. /** @hidden */
  39465. export var logDepthVertex: {
  39466. name: string;
  39467. shader: string;
  39468. };
  39469. }
  39470. declare module "babylonjs/Shaders/default.vertex" {
  39471. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39472. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39474. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39475. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39476. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39477. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39478. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39479. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39480. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39483. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39485. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39486. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39487. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39488. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39489. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39490. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39491. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39492. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39493. /** @hidden */
  39494. export var defaultVertexShader: {
  39495. name: string;
  39496. shader: string;
  39497. };
  39498. }
  39499. declare module "babylonjs/Materials/standardMaterial" {
  39500. import { SmartArray } from "babylonjs/Misc/smartArray";
  39501. import { IAnimatable } from "babylonjs/Misc/tools";
  39502. import { Nullable } from "babylonjs/types";
  39503. import { Scene } from "babylonjs/scene";
  39504. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39507. import { Mesh } from "babylonjs/Meshes/mesh";
  39508. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39509. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39510. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39511. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39512. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39515. import "babylonjs/Shaders/default.fragment";
  39516. import "babylonjs/Shaders/default.vertex";
  39517. /** @hidden */
  39518. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39519. MAINUV1: boolean;
  39520. MAINUV2: boolean;
  39521. DIFFUSE: boolean;
  39522. DIFFUSEDIRECTUV: number;
  39523. AMBIENT: boolean;
  39524. AMBIENTDIRECTUV: number;
  39525. OPACITY: boolean;
  39526. OPACITYDIRECTUV: number;
  39527. OPACITYRGB: boolean;
  39528. REFLECTION: boolean;
  39529. EMISSIVE: boolean;
  39530. EMISSIVEDIRECTUV: number;
  39531. SPECULAR: boolean;
  39532. SPECULARDIRECTUV: number;
  39533. BUMP: boolean;
  39534. BUMPDIRECTUV: number;
  39535. PARALLAX: boolean;
  39536. PARALLAXOCCLUSION: boolean;
  39537. SPECULAROVERALPHA: boolean;
  39538. CLIPPLANE: boolean;
  39539. CLIPPLANE2: boolean;
  39540. CLIPPLANE3: boolean;
  39541. CLIPPLANE4: boolean;
  39542. ALPHATEST: boolean;
  39543. DEPTHPREPASS: boolean;
  39544. ALPHAFROMDIFFUSE: boolean;
  39545. POINTSIZE: boolean;
  39546. FOG: boolean;
  39547. SPECULARTERM: boolean;
  39548. DIFFUSEFRESNEL: boolean;
  39549. OPACITYFRESNEL: boolean;
  39550. REFLECTIONFRESNEL: boolean;
  39551. REFRACTIONFRESNEL: boolean;
  39552. EMISSIVEFRESNEL: boolean;
  39553. FRESNEL: boolean;
  39554. NORMAL: boolean;
  39555. UV1: boolean;
  39556. UV2: boolean;
  39557. VERTEXCOLOR: boolean;
  39558. VERTEXALPHA: boolean;
  39559. NUM_BONE_INFLUENCERS: number;
  39560. BonesPerMesh: number;
  39561. BONETEXTURE: boolean;
  39562. INSTANCES: boolean;
  39563. GLOSSINESS: boolean;
  39564. ROUGHNESS: boolean;
  39565. EMISSIVEASILLUMINATION: boolean;
  39566. LINKEMISSIVEWITHDIFFUSE: boolean;
  39567. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39568. LIGHTMAP: boolean;
  39569. LIGHTMAPDIRECTUV: number;
  39570. OBJECTSPACE_NORMALMAP: boolean;
  39571. USELIGHTMAPASSHADOWMAP: boolean;
  39572. REFLECTIONMAP_3D: boolean;
  39573. REFLECTIONMAP_SPHERICAL: boolean;
  39574. REFLECTIONMAP_PLANAR: boolean;
  39575. REFLECTIONMAP_CUBIC: boolean;
  39576. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39577. REFLECTIONMAP_PROJECTION: boolean;
  39578. REFLECTIONMAP_SKYBOX: boolean;
  39579. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39580. REFLECTIONMAP_EXPLICIT: boolean;
  39581. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39582. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39583. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39584. INVERTCUBICMAP: boolean;
  39585. LOGARITHMICDEPTH: boolean;
  39586. REFRACTION: boolean;
  39587. REFRACTIONMAP_3D: boolean;
  39588. REFLECTIONOVERALPHA: boolean;
  39589. TWOSIDEDLIGHTING: boolean;
  39590. SHADOWFLOAT: boolean;
  39591. MORPHTARGETS: boolean;
  39592. MORPHTARGETS_NORMAL: boolean;
  39593. MORPHTARGETS_TANGENT: boolean;
  39594. NUM_MORPH_INFLUENCERS: number;
  39595. NONUNIFORMSCALING: boolean;
  39596. PREMULTIPLYALPHA: boolean;
  39597. IMAGEPROCESSING: boolean;
  39598. VIGNETTE: boolean;
  39599. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39600. VIGNETTEBLENDMODEOPAQUE: boolean;
  39601. TONEMAPPING: boolean;
  39602. TONEMAPPING_ACES: boolean;
  39603. CONTRAST: boolean;
  39604. COLORCURVES: boolean;
  39605. COLORGRADING: boolean;
  39606. COLORGRADING3D: boolean;
  39607. SAMPLER3DGREENDEPTH: boolean;
  39608. SAMPLER3DBGRMAP: boolean;
  39609. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39610. MULTIVIEW: boolean;
  39611. /**
  39612. * If the reflection texture on this material is in linear color space
  39613. * @hidden
  39614. */
  39615. IS_REFLECTION_LINEAR: boolean;
  39616. /**
  39617. * If the refraction texture on this material is in linear color space
  39618. * @hidden
  39619. */
  39620. IS_REFRACTION_LINEAR: boolean;
  39621. EXPOSURE: boolean;
  39622. constructor();
  39623. setReflectionMode(modeToEnable: string): void;
  39624. }
  39625. /**
  39626. * This is the default material used in Babylon. It is the best trade off between quality
  39627. * and performances.
  39628. * @see http://doc.babylonjs.com/babylon101/materials
  39629. */
  39630. export class StandardMaterial extends PushMaterial {
  39631. private _diffuseTexture;
  39632. /**
  39633. * The basic texture of the material as viewed under a light.
  39634. */
  39635. diffuseTexture: Nullable<BaseTexture>;
  39636. private _ambientTexture;
  39637. /**
  39638. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39639. */
  39640. ambientTexture: Nullable<BaseTexture>;
  39641. private _opacityTexture;
  39642. /**
  39643. * Define the transparency of the material from a texture.
  39644. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39645. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39646. */
  39647. opacityTexture: Nullable<BaseTexture>;
  39648. private _reflectionTexture;
  39649. /**
  39650. * Define the texture used to display the reflection.
  39651. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39652. */
  39653. reflectionTexture: Nullable<BaseTexture>;
  39654. private _emissiveTexture;
  39655. /**
  39656. * Define texture of the material as if self lit.
  39657. * This will be mixed in the final result even in the absence of light.
  39658. */
  39659. emissiveTexture: Nullable<BaseTexture>;
  39660. private _specularTexture;
  39661. /**
  39662. * Define how the color and intensity of the highlight given by the light in the material.
  39663. */
  39664. specularTexture: Nullable<BaseTexture>;
  39665. private _bumpTexture;
  39666. /**
  39667. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39668. * 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.
  39669. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39670. */
  39671. bumpTexture: Nullable<BaseTexture>;
  39672. private _lightmapTexture;
  39673. /**
  39674. * Complex lighting can be computationally expensive to compute at runtime.
  39675. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39676. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39677. */
  39678. lightmapTexture: Nullable<BaseTexture>;
  39679. private _refractionTexture;
  39680. /**
  39681. * Define the texture used to display the refraction.
  39682. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39683. */
  39684. refractionTexture: Nullable<BaseTexture>;
  39685. /**
  39686. * The color of the material lit by the environmental background lighting.
  39687. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39688. */
  39689. ambientColor: Color3;
  39690. /**
  39691. * The basic color of the material as viewed under a light.
  39692. */
  39693. diffuseColor: Color3;
  39694. /**
  39695. * Define how the color and intensity of the highlight given by the light in the material.
  39696. */
  39697. specularColor: Color3;
  39698. /**
  39699. * Define the color of the material as if self lit.
  39700. * This will be mixed in the final result even in the absence of light.
  39701. */
  39702. emissiveColor: Color3;
  39703. /**
  39704. * Defines how sharp are the highlights in the material.
  39705. * The bigger the value the sharper giving a more glossy feeling to the result.
  39706. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39707. */
  39708. specularPower: number;
  39709. private _useAlphaFromDiffuseTexture;
  39710. /**
  39711. * Does the transparency come from the diffuse texture alpha channel.
  39712. */
  39713. useAlphaFromDiffuseTexture: boolean;
  39714. private _useEmissiveAsIllumination;
  39715. /**
  39716. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39717. */
  39718. useEmissiveAsIllumination: boolean;
  39719. private _linkEmissiveWithDiffuse;
  39720. /**
  39721. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39722. * the emissive level when the final color is close to one.
  39723. */
  39724. linkEmissiveWithDiffuse: boolean;
  39725. private _useSpecularOverAlpha;
  39726. /**
  39727. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39728. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39729. */
  39730. useSpecularOverAlpha: boolean;
  39731. private _useReflectionOverAlpha;
  39732. /**
  39733. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39734. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39735. */
  39736. useReflectionOverAlpha: boolean;
  39737. private _disableLighting;
  39738. /**
  39739. * Does lights from the scene impacts this material.
  39740. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39741. */
  39742. disableLighting: boolean;
  39743. private _useObjectSpaceNormalMap;
  39744. /**
  39745. * Allows using an object space normal map (instead of tangent space).
  39746. */
  39747. useObjectSpaceNormalMap: boolean;
  39748. private _useParallax;
  39749. /**
  39750. * Is parallax enabled or not.
  39751. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39752. */
  39753. useParallax: boolean;
  39754. private _useParallaxOcclusion;
  39755. /**
  39756. * Is parallax occlusion enabled or not.
  39757. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39758. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39759. */
  39760. useParallaxOcclusion: boolean;
  39761. /**
  39762. * 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.
  39763. */
  39764. parallaxScaleBias: number;
  39765. private _roughness;
  39766. /**
  39767. * Helps to define how blurry the reflections should appears in the material.
  39768. */
  39769. roughness: number;
  39770. /**
  39771. * In case of refraction, define the value of the indice of refraction.
  39772. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39773. */
  39774. indexOfRefraction: number;
  39775. /**
  39776. * Invert the refraction texture alongside the y axis.
  39777. * It can be useful with procedural textures or probe for instance.
  39778. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39779. */
  39780. invertRefractionY: boolean;
  39781. /**
  39782. * Defines the alpha limits in alpha test mode.
  39783. */
  39784. alphaCutOff: number;
  39785. private _useLightmapAsShadowmap;
  39786. /**
  39787. * In case of light mapping, define whether the map contains light or shadow informations.
  39788. */
  39789. useLightmapAsShadowmap: boolean;
  39790. private _diffuseFresnelParameters;
  39791. /**
  39792. * Define the diffuse fresnel parameters of the material.
  39793. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39794. */
  39795. diffuseFresnelParameters: FresnelParameters;
  39796. private _opacityFresnelParameters;
  39797. /**
  39798. * Define the opacity fresnel parameters of the material.
  39799. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39800. */
  39801. opacityFresnelParameters: FresnelParameters;
  39802. private _reflectionFresnelParameters;
  39803. /**
  39804. * Define the reflection fresnel parameters of the material.
  39805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39806. */
  39807. reflectionFresnelParameters: FresnelParameters;
  39808. private _refractionFresnelParameters;
  39809. /**
  39810. * Define the refraction fresnel parameters of the material.
  39811. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39812. */
  39813. refractionFresnelParameters: FresnelParameters;
  39814. private _emissiveFresnelParameters;
  39815. /**
  39816. * Define the emissive fresnel parameters of the material.
  39817. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39818. */
  39819. emissiveFresnelParameters: FresnelParameters;
  39820. private _useReflectionFresnelFromSpecular;
  39821. /**
  39822. * If true automatically deducts the fresnels values from the material specularity.
  39823. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39824. */
  39825. useReflectionFresnelFromSpecular: boolean;
  39826. private _useGlossinessFromSpecularMapAlpha;
  39827. /**
  39828. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39829. */
  39830. useGlossinessFromSpecularMapAlpha: boolean;
  39831. private _maxSimultaneousLights;
  39832. /**
  39833. * Defines the maximum number of lights that can be used in the material
  39834. */
  39835. maxSimultaneousLights: number;
  39836. private _invertNormalMapX;
  39837. /**
  39838. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39839. */
  39840. invertNormalMapX: boolean;
  39841. private _invertNormalMapY;
  39842. /**
  39843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39844. */
  39845. invertNormalMapY: boolean;
  39846. private _twoSidedLighting;
  39847. /**
  39848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39849. */
  39850. twoSidedLighting: boolean;
  39851. /**
  39852. * Default configuration related to image processing available in the standard Material.
  39853. */
  39854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39855. /**
  39856. * Gets the image processing configuration used either in this material.
  39857. */
  39858. /**
  39859. * Sets the Default image processing configuration used either in the this material.
  39860. *
  39861. * If sets to null, the scene one is in use.
  39862. */
  39863. imageProcessingConfiguration: ImageProcessingConfiguration;
  39864. /**
  39865. * Keep track of the image processing observer to allow dispose and replace.
  39866. */
  39867. private _imageProcessingObserver;
  39868. /**
  39869. * Attaches a new image processing configuration to the Standard Material.
  39870. * @param configuration
  39871. */
  39872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39873. /**
  39874. * Gets wether the color curves effect is enabled.
  39875. */
  39876. /**
  39877. * Sets wether the color curves effect is enabled.
  39878. */
  39879. cameraColorCurvesEnabled: boolean;
  39880. /**
  39881. * Gets wether the color grading effect is enabled.
  39882. */
  39883. /**
  39884. * Gets wether the color grading effect is enabled.
  39885. */
  39886. cameraColorGradingEnabled: boolean;
  39887. /**
  39888. * Gets wether tonemapping is enabled or not.
  39889. */
  39890. /**
  39891. * Sets wether tonemapping is enabled or not
  39892. */
  39893. cameraToneMappingEnabled: boolean;
  39894. /**
  39895. * The camera exposure used on this material.
  39896. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39897. * This corresponds to a photographic exposure.
  39898. */
  39899. /**
  39900. * The camera exposure used on this material.
  39901. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39902. * This corresponds to a photographic exposure.
  39903. */
  39904. cameraExposure: number;
  39905. /**
  39906. * Gets The camera contrast used on this material.
  39907. */
  39908. /**
  39909. * Sets The camera contrast used on this material.
  39910. */
  39911. cameraContrast: number;
  39912. /**
  39913. * Gets the Color Grading 2D Lookup Texture.
  39914. */
  39915. /**
  39916. * Sets the Color Grading 2D Lookup Texture.
  39917. */
  39918. cameraColorGradingTexture: Nullable<BaseTexture>;
  39919. /**
  39920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39922. * 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;
  39923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39924. */
  39925. /**
  39926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39928. * 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;
  39929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39930. */
  39931. cameraColorCurves: Nullable<ColorCurves>;
  39932. /**
  39933. * Custom callback helping to override the default shader used in the material.
  39934. */
  39935. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39936. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39937. protected _worldViewProjectionMatrix: Matrix;
  39938. protected _globalAmbientColor: Color3;
  39939. protected _useLogarithmicDepth: boolean;
  39940. /**
  39941. * Instantiates a new standard material.
  39942. * This is the default material used in Babylon. It is the best trade off between quality
  39943. * and performances.
  39944. * @see http://doc.babylonjs.com/babylon101/materials
  39945. * @param name Define the name of the material in the scene
  39946. * @param scene Define the scene the material belong to
  39947. */
  39948. constructor(name: string, scene: Scene);
  39949. /**
  39950. * Gets a boolean indicating that current material needs to register RTT
  39951. */
  39952. readonly hasRenderTargetTextures: boolean;
  39953. /**
  39954. * Gets the current class name of the material e.g. "StandardMaterial"
  39955. * Mainly use in serialization.
  39956. * @returns the class name
  39957. */
  39958. getClassName(): string;
  39959. /**
  39960. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39961. * You can try switching to logarithmic depth.
  39962. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39963. */
  39964. useLogarithmicDepth: boolean;
  39965. /**
  39966. * Specifies if the material will require alpha blending
  39967. * @returns a boolean specifying if alpha blending is needed
  39968. */
  39969. needAlphaBlending(): boolean;
  39970. /**
  39971. * Specifies if this material should be rendered in alpha test mode
  39972. * @returns a boolean specifying if an alpha test is needed.
  39973. */
  39974. needAlphaTesting(): boolean;
  39975. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39976. /**
  39977. * Get the texture used for alpha test purpose.
  39978. * @returns the diffuse texture in case of the standard material.
  39979. */
  39980. getAlphaTestTexture(): Nullable<BaseTexture>;
  39981. /**
  39982. * Get if the submesh is ready to be used and all its information available.
  39983. * Child classes can use it to update shaders
  39984. * @param mesh defines the mesh to check
  39985. * @param subMesh defines which submesh to check
  39986. * @param useInstances specifies that instances should be used
  39987. * @returns a boolean indicating that the submesh is ready or not
  39988. */
  39989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39990. /**
  39991. * Builds the material UBO layouts.
  39992. * Used internally during the effect preparation.
  39993. */
  39994. buildUniformLayout(): void;
  39995. /**
  39996. * Unbinds the material from the mesh
  39997. */
  39998. unbind(): void;
  39999. /**
  40000. * Binds the submesh to this material by preparing the effect and shader to draw
  40001. * @param world defines the world transformation matrix
  40002. * @param mesh defines the mesh containing the submesh
  40003. * @param subMesh defines the submesh to bind the material to
  40004. */
  40005. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40006. /**
  40007. * Get the list of animatables in the material.
  40008. * @returns the list of animatables object used in the material
  40009. */
  40010. getAnimatables(): IAnimatable[];
  40011. /**
  40012. * Gets the active textures from the material
  40013. * @returns an array of textures
  40014. */
  40015. getActiveTextures(): BaseTexture[];
  40016. /**
  40017. * Specifies if the material uses a texture
  40018. * @param texture defines the texture to check against the material
  40019. * @returns a boolean specifying if the material uses the texture
  40020. */
  40021. hasTexture(texture: BaseTexture): boolean;
  40022. /**
  40023. * Disposes the material
  40024. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40025. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40026. */
  40027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40028. /**
  40029. * Makes a duplicate of the material, and gives it a new name
  40030. * @param name defines the new name for the duplicated material
  40031. * @returns the cloned material
  40032. */
  40033. clone(name: string): StandardMaterial;
  40034. /**
  40035. * Serializes this material in a JSON representation
  40036. * @returns the serialized material object
  40037. */
  40038. serialize(): any;
  40039. /**
  40040. * Creates a standard material from parsed material data
  40041. * @param source defines the JSON representation of the material
  40042. * @param scene defines the hosting scene
  40043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40044. * @returns a new standard material
  40045. */
  40046. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40047. /**
  40048. * Are diffuse textures enabled in the application.
  40049. */
  40050. static DiffuseTextureEnabled: boolean;
  40051. /**
  40052. * Are ambient textures enabled in the application.
  40053. */
  40054. static AmbientTextureEnabled: boolean;
  40055. /**
  40056. * Are opacity textures enabled in the application.
  40057. */
  40058. static OpacityTextureEnabled: boolean;
  40059. /**
  40060. * Are reflection textures enabled in the application.
  40061. */
  40062. static ReflectionTextureEnabled: boolean;
  40063. /**
  40064. * Are emissive textures enabled in the application.
  40065. */
  40066. static EmissiveTextureEnabled: boolean;
  40067. /**
  40068. * Are specular textures enabled in the application.
  40069. */
  40070. static SpecularTextureEnabled: boolean;
  40071. /**
  40072. * Are bump textures enabled in the application.
  40073. */
  40074. static BumpTextureEnabled: boolean;
  40075. /**
  40076. * Are lightmap textures enabled in the application.
  40077. */
  40078. static LightmapTextureEnabled: boolean;
  40079. /**
  40080. * Are refraction textures enabled in the application.
  40081. */
  40082. static RefractionTextureEnabled: boolean;
  40083. /**
  40084. * Are color grading textures enabled in the application.
  40085. */
  40086. static ColorGradingTextureEnabled: boolean;
  40087. /**
  40088. * Are fresnels enabled in the application.
  40089. */
  40090. static FresnelEnabled: boolean;
  40091. }
  40092. }
  40093. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40094. import { Scene } from "babylonjs/scene";
  40095. import { Texture } from "babylonjs/Materials/Textures/texture";
  40096. /**
  40097. * A class extending Texture allowing drawing on a texture
  40098. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40099. */
  40100. export class DynamicTexture extends Texture {
  40101. private _generateMipMaps;
  40102. private _canvas;
  40103. private _context;
  40104. private _engine;
  40105. /**
  40106. * Creates a DynamicTexture
  40107. * @param name defines the name of the texture
  40108. * @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
  40109. * @param scene defines the scene where you want the texture
  40110. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40111. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40112. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40113. */
  40114. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40115. /**
  40116. * Get the current class name of the texture useful for serialization or dynamic coding.
  40117. * @returns "DynamicTexture"
  40118. */
  40119. getClassName(): string;
  40120. /**
  40121. * Gets the current state of canRescale
  40122. */
  40123. readonly canRescale: boolean;
  40124. private _recreate;
  40125. /**
  40126. * Scales the texture
  40127. * @param ratio the scale factor to apply to both width and height
  40128. */
  40129. scale(ratio: number): void;
  40130. /**
  40131. * Resizes the texture
  40132. * @param width the new width
  40133. * @param height the new height
  40134. */
  40135. scaleTo(width: number, height: number): void;
  40136. /**
  40137. * Gets the context of the canvas used by the texture
  40138. * @returns the canvas context of the dynamic texture
  40139. */
  40140. getContext(): CanvasRenderingContext2D;
  40141. /**
  40142. * Clears the texture
  40143. */
  40144. clear(): void;
  40145. /**
  40146. * Updates the texture
  40147. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40148. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40149. */
  40150. update(invertY?: boolean, premulAlpha?: boolean): void;
  40151. /**
  40152. * Draws text onto the texture
  40153. * @param text defines the text to be drawn
  40154. * @param x defines the placement of the text from the left
  40155. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40156. * @param font defines the font to be used with font-style, font-size, font-name
  40157. * @param color defines the color used for the text
  40158. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40159. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40160. * @param update defines whether texture is immediately update (default is true)
  40161. */
  40162. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40163. /**
  40164. * Clones the texture
  40165. * @returns the clone of the texture.
  40166. */
  40167. clone(): DynamicTexture;
  40168. /**
  40169. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40170. * @returns a serialized dynamic texture object
  40171. */
  40172. serialize(): any;
  40173. /** @hidden */
  40174. _rebuild(): void;
  40175. }
  40176. }
  40177. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40178. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40179. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40180. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40181. /** @hidden */
  40182. export var imageProcessingPixelShader: {
  40183. name: string;
  40184. shader: string;
  40185. };
  40186. }
  40187. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40188. import { Nullable } from "babylonjs/types";
  40189. import { Color4 } from "babylonjs/Maths/math";
  40190. import { Camera } from "babylonjs/Cameras/camera";
  40191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40192. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40193. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40194. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40195. import { Engine } from "babylonjs/Engines/engine";
  40196. import "babylonjs/Shaders/imageProcessing.fragment";
  40197. import "babylonjs/Shaders/postprocess.vertex";
  40198. /**
  40199. * ImageProcessingPostProcess
  40200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40201. */
  40202. export class ImageProcessingPostProcess extends PostProcess {
  40203. /**
  40204. * Default configuration related to image processing available in the PBR Material.
  40205. */
  40206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40207. /**
  40208. * Gets the image processing configuration used either in this material.
  40209. */
  40210. /**
  40211. * Sets the Default image processing configuration used either in the this material.
  40212. *
  40213. * If sets to null, the scene one is in use.
  40214. */
  40215. imageProcessingConfiguration: ImageProcessingConfiguration;
  40216. /**
  40217. * Keep track of the image processing observer to allow dispose and replace.
  40218. */
  40219. private _imageProcessingObserver;
  40220. /**
  40221. * Attaches a new image processing configuration to the PBR Material.
  40222. * @param configuration
  40223. */
  40224. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40225. /**
  40226. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40227. */
  40228. /**
  40229. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40230. */
  40231. colorCurves: Nullable<ColorCurves>;
  40232. /**
  40233. * Gets wether the color curves effect is enabled.
  40234. */
  40235. /**
  40236. * Sets wether the color curves effect is enabled.
  40237. */
  40238. colorCurvesEnabled: boolean;
  40239. /**
  40240. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40241. */
  40242. /**
  40243. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40244. */
  40245. colorGradingTexture: Nullable<BaseTexture>;
  40246. /**
  40247. * Gets wether the color grading effect is enabled.
  40248. */
  40249. /**
  40250. * Gets wether the color grading effect is enabled.
  40251. */
  40252. colorGradingEnabled: boolean;
  40253. /**
  40254. * Gets exposure used in the effect.
  40255. */
  40256. /**
  40257. * Sets exposure used in the effect.
  40258. */
  40259. exposure: number;
  40260. /**
  40261. * Gets wether tonemapping is enabled or not.
  40262. */
  40263. /**
  40264. * Sets wether tonemapping is enabled or not
  40265. */
  40266. toneMappingEnabled: boolean;
  40267. /**
  40268. * Gets the type of tone mapping effect.
  40269. */
  40270. /**
  40271. * Sets the type of tone mapping effect.
  40272. */
  40273. toneMappingType: number;
  40274. /**
  40275. * Gets contrast used in the effect.
  40276. */
  40277. /**
  40278. * Sets contrast used in the effect.
  40279. */
  40280. contrast: number;
  40281. /**
  40282. * Gets Vignette stretch size.
  40283. */
  40284. /**
  40285. * Sets Vignette stretch size.
  40286. */
  40287. vignetteStretch: number;
  40288. /**
  40289. * Gets Vignette centre X Offset.
  40290. */
  40291. /**
  40292. * Sets Vignette centre X Offset.
  40293. */
  40294. vignetteCentreX: number;
  40295. /**
  40296. * Gets Vignette centre Y Offset.
  40297. */
  40298. /**
  40299. * Sets Vignette centre Y Offset.
  40300. */
  40301. vignetteCentreY: number;
  40302. /**
  40303. * Gets Vignette weight or intensity of the vignette effect.
  40304. */
  40305. /**
  40306. * Sets Vignette weight or intensity of the vignette effect.
  40307. */
  40308. vignetteWeight: number;
  40309. /**
  40310. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40311. * if vignetteEnabled is set to true.
  40312. */
  40313. /**
  40314. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40315. * if vignetteEnabled is set to true.
  40316. */
  40317. vignetteColor: Color4;
  40318. /**
  40319. * Gets Camera field of view used by the Vignette effect.
  40320. */
  40321. /**
  40322. * Sets Camera field of view used by the Vignette effect.
  40323. */
  40324. vignetteCameraFov: number;
  40325. /**
  40326. * Gets the vignette blend mode allowing different kind of effect.
  40327. */
  40328. /**
  40329. * Sets the vignette blend mode allowing different kind of effect.
  40330. */
  40331. vignetteBlendMode: number;
  40332. /**
  40333. * Gets wether the vignette effect is enabled.
  40334. */
  40335. /**
  40336. * Sets wether the vignette effect is enabled.
  40337. */
  40338. vignetteEnabled: boolean;
  40339. private _fromLinearSpace;
  40340. /**
  40341. * Gets wether the input of the processing is in Gamma or Linear Space.
  40342. */
  40343. /**
  40344. * Sets wether the input of the processing is in Gamma or Linear Space.
  40345. */
  40346. fromLinearSpace: boolean;
  40347. /**
  40348. * Defines cache preventing GC.
  40349. */
  40350. private _defines;
  40351. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40352. /**
  40353. * "ImageProcessingPostProcess"
  40354. * @returns "ImageProcessingPostProcess"
  40355. */
  40356. getClassName(): string;
  40357. protected _updateParameters(): void;
  40358. dispose(camera?: Camera): void;
  40359. }
  40360. }
  40361. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40362. import { Scene } from "babylonjs/scene";
  40363. import { Color3 } from "babylonjs/Maths/math";
  40364. import { Mesh } from "babylonjs/Meshes/mesh";
  40365. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40366. import { Nullable } from "babylonjs/types";
  40367. /**
  40368. * Class containing static functions to help procedurally build meshes
  40369. */
  40370. export class GroundBuilder {
  40371. /**
  40372. * Creates a ground mesh
  40373. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40374. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40376. * @param name defines the name of the mesh
  40377. * @param options defines the options used to create the mesh
  40378. * @param scene defines the hosting scene
  40379. * @returns the ground mesh
  40380. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40381. */
  40382. static CreateGround(name: string, options: {
  40383. width?: number;
  40384. height?: number;
  40385. subdivisions?: number;
  40386. subdivisionsX?: number;
  40387. subdivisionsY?: number;
  40388. updatable?: boolean;
  40389. }, scene: any): Mesh;
  40390. /**
  40391. * Creates a tiled ground mesh
  40392. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40393. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40394. * * 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
  40395. * * 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
  40396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40397. * @param name defines the name of the mesh
  40398. * @param options defines the options used to create the mesh
  40399. * @param scene defines the hosting scene
  40400. * @returns the tiled ground mesh
  40401. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40402. */
  40403. static CreateTiledGround(name: string, options: {
  40404. xmin: number;
  40405. zmin: number;
  40406. xmax: number;
  40407. zmax: number;
  40408. subdivisions?: {
  40409. w: number;
  40410. h: number;
  40411. };
  40412. precision?: {
  40413. w: number;
  40414. h: number;
  40415. };
  40416. updatable?: boolean;
  40417. }, scene?: Nullable<Scene>): Mesh;
  40418. /**
  40419. * Creates a ground mesh from a height map
  40420. * * The parameter `url` sets the URL of the height map image resource.
  40421. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40422. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40423. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40424. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40425. * * 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.
  40426. * * 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).
  40427. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40429. * @param name defines the name of the mesh
  40430. * @param url defines the url to the height map
  40431. * @param options defines the options used to create the mesh
  40432. * @param scene defines the hosting scene
  40433. * @returns the ground mesh
  40434. * @see https://doc.babylonjs.com/babylon101/height_map
  40435. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40436. */
  40437. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40438. width?: number;
  40439. height?: number;
  40440. subdivisions?: number;
  40441. minHeight?: number;
  40442. maxHeight?: number;
  40443. colorFilter?: Color3;
  40444. alphaFilter?: number;
  40445. updatable?: boolean;
  40446. onReady?: (mesh: GroundMesh) => void;
  40447. }, scene?: Nullable<Scene>): GroundMesh;
  40448. }
  40449. }
  40450. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40451. import { Vector4 } from "babylonjs/Maths/math";
  40452. import { Mesh } from "babylonjs/Meshes/mesh";
  40453. /**
  40454. * Class containing static functions to help procedurally build meshes
  40455. */
  40456. export class TorusBuilder {
  40457. /**
  40458. * Creates a torus mesh
  40459. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40460. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40461. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40465. * @param name defines the name of the mesh
  40466. * @param options defines the options used to create the mesh
  40467. * @param scene defines the hosting scene
  40468. * @returns the torus mesh
  40469. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40470. */
  40471. static CreateTorus(name: string, options: {
  40472. diameter?: number;
  40473. thickness?: number;
  40474. tessellation?: number;
  40475. updatable?: boolean;
  40476. sideOrientation?: number;
  40477. frontUVs?: Vector4;
  40478. backUVs?: Vector4;
  40479. }, scene: any): Mesh;
  40480. }
  40481. }
  40482. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40483. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40484. import { Mesh } from "babylonjs/Meshes/mesh";
  40485. /**
  40486. * Class containing static functions to help procedurally build meshes
  40487. */
  40488. export class CylinderBuilder {
  40489. /**
  40490. * Creates a cylinder or a cone mesh
  40491. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40492. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40493. * * 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.
  40494. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40495. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40496. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40497. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40498. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40499. * * 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).
  40500. * * 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
  40501. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40502. * * 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
  40503. * * 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.
  40504. * * If `enclose` is false, a ring surface is one element.
  40505. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40506. * * 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
  40507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40510. * @param name defines the name of the mesh
  40511. * @param options defines the options used to create the mesh
  40512. * @param scene defines the hosting scene
  40513. * @returns the cylinder mesh
  40514. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40515. */
  40516. static CreateCylinder(name: string, options: {
  40517. height?: number;
  40518. diameterTop?: number;
  40519. diameterBottom?: number;
  40520. diameter?: number;
  40521. tessellation?: number;
  40522. subdivisions?: number;
  40523. arc?: number;
  40524. faceColors?: Color4[];
  40525. faceUV?: Vector4[];
  40526. updatable?: boolean;
  40527. hasRings?: boolean;
  40528. enclose?: boolean;
  40529. sideOrientation?: number;
  40530. frontUVs?: Vector4;
  40531. backUVs?: Vector4;
  40532. }, scene: any): Mesh;
  40533. }
  40534. }
  40535. declare module "babylonjs/Gamepads/gamepadManager" {
  40536. import { Observable } from "babylonjs/Misc/observable";
  40537. import { Nullable } from "babylonjs/types";
  40538. import { Scene } from "babylonjs/scene";
  40539. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40540. /**
  40541. * Manager for handling gamepads
  40542. */
  40543. export class GamepadManager {
  40544. private _scene?;
  40545. private _babylonGamepads;
  40546. private _oneGamepadConnected;
  40547. /** @hidden */
  40548. _isMonitoring: boolean;
  40549. private _gamepadEventSupported;
  40550. private _gamepadSupport;
  40551. /**
  40552. * observable to be triggered when the gamepad controller has been connected
  40553. */
  40554. onGamepadConnectedObservable: Observable<Gamepad>;
  40555. /**
  40556. * observable to be triggered when the gamepad controller has been disconnected
  40557. */
  40558. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40559. private _onGamepadConnectedEvent;
  40560. private _onGamepadDisconnectedEvent;
  40561. /**
  40562. * Initializes the gamepad manager
  40563. * @param _scene BabylonJS scene
  40564. */
  40565. constructor(_scene?: Scene | undefined);
  40566. /**
  40567. * The gamepads in the game pad manager
  40568. */
  40569. readonly gamepads: Gamepad[];
  40570. /**
  40571. * Get the gamepad controllers based on type
  40572. * @param type The type of gamepad controller
  40573. * @returns Nullable gamepad
  40574. */
  40575. getGamepadByType(type?: number): Nullable<Gamepad>;
  40576. /**
  40577. * Disposes the gamepad manager
  40578. */
  40579. dispose(): void;
  40580. private _addNewGamepad;
  40581. private _startMonitoringGamepads;
  40582. private _stopMonitoringGamepads;
  40583. /** @hidden */
  40584. _checkGamepadsStatus(): void;
  40585. private _updateGamepadObjects;
  40586. }
  40587. }
  40588. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40589. import { Nullable } from "babylonjs/types";
  40590. import { Scene } from "babylonjs/scene";
  40591. import { ISceneComponent } from "babylonjs/sceneComponent";
  40592. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40593. module "babylonjs/scene" {
  40594. interface Scene {
  40595. /** @hidden */
  40596. _gamepadManager: Nullable<GamepadManager>;
  40597. /**
  40598. * Gets the gamepad manager associated with the scene
  40599. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40600. */
  40601. gamepadManager: GamepadManager;
  40602. }
  40603. }
  40604. module "babylonjs/Cameras/freeCameraInputsManager" {
  40605. /**
  40606. * Interface representing a free camera inputs manager
  40607. */
  40608. interface FreeCameraInputsManager {
  40609. /**
  40610. * Adds gamepad input support to the FreeCameraInputsManager.
  40611. * @returns the FreeCameraInputsManager
  40612. */
  40613. addGamepad(): FreeCameraInputsManager;
  40614. }
  40615. }
  40616. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40617. /**
  40618. * Interface representing an arc rotate camera inputs manager
  40619. */
  40620. interface ArcRotateCameraInputsManager {
  40621. /**
  40622. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40623. * @returns the camera inputs manager
  40624. */
  40625. addGamepad(): ArcRotateCameraInputsManager;
  40626. }
  40627. }
  40628. /**
  40629. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40630. */
  40631. export class GamepadSystemSceneComponent implements ISceneComponent {
  40632. /**
  40633. * The component name helpfull to identify the component in the list of scene components.
  40634. */
  40635. readonly name: string;
  40636. /**
  40637. * The scene the component belongs to.
  40638. */
  40639. scene: Scene;
  40640. /**
  40641. * Creates a new instance of the component for the given scene
  40642. * @param scene Defines the scene to register the component in
  40643. */
  40644. constructor(scene: Scene);
  40645. /**
  40646. * Registers the component in a given scene
  40647. */
  40648. register(): void;
  40649. /**
  40650. * Rebuilds the elements related to this component in case of
  40651. * context lost for instance.
  40652. */
  40653. rebuild(): void;
  40654. /**
  40655. * Disposes the component and the associated ressources
  40656. */
  40657. dispose(): void;
  40658. private _beforeCameraUpdate;
  40659. }
  40660. }
  40661. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40662. import { Observable } from "babylonjs/Misc/observable";
  40663. import { Nullable } from "babylonjs/types";
  40664. import { Camera } from "babylonjs/Cameras/camera";
  40665. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40666. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40667. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40668. import { Scene } from "babylonjs/scene";
  40669. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40670. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40672. import { Mesh } from "babylonjs/Meshes/mesh";
  40673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40674. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40675. import "babylonjs/Meshes/Builders/groundBuilder";
  40676. import "babylonjs/Meshes/Builders/torusBuilder";
  40677. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40678. import "babylonjs/Gamepads/gamepadSceneComponent";
  40679. import "babylonjs/Animations/animatable";
  40680. /**
  40681. * Options to modify the vr teleportation behavior.
  40682. */
  40683. export interface VRTeleportationOptions {
  40684. /**
  40685. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40686. */
  40687. floorMeshName?: string;
  40688. /**
  40689. * A list of meshes to be used as the teleportation floor. (default: empty)
  40690. */
  40691. floorMeshes?: Mesh[];
  40692. }
  40693. /**
  40694. * Options to modify the vr experience helper's behavior.
  40695. */
  40696. export interface VRExperienceHelperOptions extends WebVROptions {
  40697. /**
  40698. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40699. */
  40700. createDeviceOrientationCamera?: boolean;
  40701. /**
  40702. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40703. */
  40704. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40705. /**
  40706. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40707. */
  40708. laserToggle?: boolean;
  40709. /**
  40710. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40711. */
  40712. floorMeshes?: Mesh[];
  40713. /**
  40714. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40715. */
  40716. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40717. }
  40718. /**
  40719. * Event containing information after VR has been entered
  40720. */
  40721. export class OnAfterEnteringVRObservableEvent {
  40722. /**
  40723. * If entering vr was successful
  40724. */
  40725. success: boolean;
  40726. }
  40727. /**
  40728. * Helps to quickly add VR support to an existing scene.
  40729. * See http://doc.babylonjs.com/how_to/webvr_helper
  40730. */
  40731. export class VRExperienceHelper {
  40732. /** Options to modify the vr experience helper's behavior. */
  40733. webVROptions: VRExperienceHelperOptions;
  40734. private _scene;
  40735. private _position;
  40736. private _btnVR;
  40737. private _btnVRDisplayed;
  40738. private _webVRsupported;
  40739. private _webVRready;
  40740. private _webVRrequesting;
  40741. private _webVRpresenting;
  40742. private _hasEnteredVR;
  40743. private _fullscreenVRpresenting;
  40744. private _canvas;
  40745. private _webVRCamera;
  40746. private _vrDeviceOrientationCamera;
  40747. private _deviceOrientationCamera;
  40748. private _existingCamera;
  40749. private _onKeyDown;
  40750. private _onVrDisplayPresentChange;
  40751. private _onVRDisplayChanged;
  40752. private _onVRRequestPresentStart;
  40753. private _onVRRequestPresentComplete;
  40754. /**
  40755. * Observable raised right before entering VR.
  40756. */
  40757. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40758. /**
  40759. * Observable raised when entering VR has completed.
  40760. */
  40761. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40762. /**
  40763. * Observable raised when exiting VR.
  40764. */
  40765. onExitingVRObservable: Observable<VRExperienceHelper>;
  40766. /**
  40767. * Observable raised when controller mesh is loaded.
  40768. */
  40769. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40770. /** Return this.onEnteringVRObservable
  40771. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40772. */
  40773. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40774. /** Return this.onExitingVRObservable
  40775. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40776. */
  40777. readonly onExitingVR: Observable<VRExperienceHelper>;
  40778. /** Return this.onControllerMeshLoadedObservable
  40779. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40780. */
  40781. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40782. private _rayLength;
  40783. private _useCustomVRButton;
  40784. private _teleportationRequested;
  40785. private _teleportActive;
  40786. private _floorMeshName;
  40787. private _floorMeshesCollection;
  40788. private _rotationAllowed;
  40789. private _teleportBackwardsVector;
  40790. private _teleportationTarget;
  40791. private _isDefaultTeleportationTarget;
  40792. private _postProcessMove;
  40793. private _teleportationFillColor;
  40794. private _teleportationBorderColor;
  40795. private _rotationAngle;
  40796. private _haloCenter;
  40797. private _cameraGazer;
  40798. private _padSensibilityUp;
  40799. private _padSensibilityDown;
  40800. private _leftController;
  40801. private _rightController;
  40802. /**
  40803. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40804. */
  40805. onNewMeshSelected: Observable<AbstractMesh>;
  40806. /**
  40807. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40808. */
  40809. onNewMeshPicked: Observable<PickingInfo>;
  40810. private _circleEase;
  40811. /**
  40812. * Observable raised before camera teleportation
  40813. */
  40814. onBeforeCameraTeleport: Observable<Vector3>;
  40815. /**
  40816. * Observable raised after camera teleportation
  40817. */
  40818. onAfterCameraTeleport: Observable<Vector3>;
  40819. /**
  40820. * Observable raised when current selected mesh gets unselected
  40821. */
  40822. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40823. private _raySelectionPredicate;
  40824. /**
  40825. * To be optionaly changed by user to define custom ray selection
  40826. */
  40827. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40828. /**
  40829. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40830. */
  40831. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40832. /**
  40833. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40834. */
  40835. teleportationEnabled: boolean;
  40836. private _defaultHeight;
  40837. private _teleportationInitialized;
  40838. private _interactionsEnabled;
  40839. private _interactionsRequested;
  40840. private _displayGaze;
  40841. private _displayLaserPointer;
  40842. /**
  40843. * The mesh used to display where the user is going to teleport.
  40844. */
  40845. /**
  40846. * Sets the mesh to be used to display where the user is going to teleport.
  40847. */
  40848. teleportationTarget: Mesh;
  40849. /**
  40850. * 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
  40851. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40852. * See http://doc.babylonjs.com/resources/baking_transformations
  40853. */
  40854. gazeTrackerMesh: Mesh;
  40855. /**
  40856. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40857. */
  40858. updateGazeTrackerScale: boolean;
  40859. /**
  40860. * If the gaze trackers color should be updated when selecting meshes
  40861. */
  40862. updateGazeTrackerColor: boolean;
  40863. /**
  40864. * The gaze tracking mesh corresponding to the left controller
  40865. */
  40866. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40867. /**
  40868. * The gaze tracking mesh corresponding to the right controller
  40869. */
  40870. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40871. /**
  40872. * If the ray of the gaze should be displayed.
  40873. */
  40874. /**
  40875. * Sets if the ray of the gaze should be displayed.
  40876. */
  40877. displayGaze: boolean;
  40878. /**
  40879. * If the ray of the LaserPointer should be displayed.
  40880. */
  40881. /**
  40882. * Sets if the ray of the LaserPointer should be displayed.
  40883. */
  40884. displayLaserPointer: boolean;
  40885. /**
  40886. * The deviceOrientationCamera used as the camera when not in VR.
  40887. */
  40888. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40889. /**
  40890. * Based on the current WebVR support, returns the current VR camera used.
  40891. */
  40892. readonly currentVRCamera: Nullable<Camera>;
  40893. /**
  40894. * The webVRCamera which is used when in VR.
  40895. */
  40896. readonly webVRCamera: WebVRFreeCamera;
  40897. /**
  40898. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40899. */
  40900. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40901. private readonly _teleportationRequestInitiated;
  40902. /**
  40903. * Defines wether or not Pointer lock should be requested when switching to
  40904. * full screen.
  40905. */
  40906. requestPointerLockOnFullScreen: boolean;
  40907. /**
  40908. * Instantiates a VRExperienceHelper.
  40909. * Helps to quickly add VR support to an existing scene.
  40910. * @param scene The scene the VRExperienceHelper belongs to.
  40911. * @param webVROptions Options to modify the vr experience helper's behavior.
  40912. */
  40913. constructor(scene: Scene,
  40914. /** Options to modify the vr experience helper's behavior. */
  40915. webVROptions?: VRExperienceHelperOptions);
  40916. private _onDefaultMeshLoaded;
  40917. private _onResize;
  40918. private _onFullscreenChange;
  40919. /**
  40920. * Gets a value indicating if we are currently in VR mode.
  40921. */
  40922. readonly isInVRMode: boolean;
  40923. private onVrDisplayPresentChange;
  40924. private onVRDisplayChanged;
  40925. private moveButtonToBottomRight;
  40926. private displayVRButton;
  40927. private updateButtonVisibility;
  40928. private _cachedAngularSensibility;
  40929. /**
  40930. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40931. * Otherwise, will use the fullscreen API.
  40932. */
  40933. enterVR(): void;
  40934. /**
  40935. * Attempt to exit VR, or fullscreen.
  40936. */
  40937. exitVR(): void;
  40938. /**
  40939. * The position of the vr experience helper.
  40940. */
  40941. /**
  40942. * Sets the position of the vr experience helper.
  40943. */
  40944. position: Vector3;
  40945. /**
  40946. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40947. */
  40948. enableInteractions(): void;
  40949. private readonly _noControllerIsActive;
  40950. private beforeRender;
  40951. private _isTeleportationFloor;
  40952. /**
  40953. * Adds a floor mesh to be used for teleportation.
  40954. * @param floorMesh the mesh to be used for teleportation.
  40955. */
  40956. addFloorMesh(floorMesh: Mesh): void;
  40957. /**
  40958. * Removes a floor mesh from being used for teleportation.
  40959. * @param floorMesh the mesh to be removed.
  40960. */
  40961. removeFloorMesh(floorMesh: Mesh): void;
  40962. /**
  40963. * Enables interactions and teleportation using the VR controllers and gaze.
  40964. * @param vrTeleportationOptions options to modify teleportation behavior.
  40965. */
  40966. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40967. private _onNewGamepadConnected;
  40968. private _tryEnableInteractionOnController;
  40969. private _onNewGamepadDisconnected;
  40970. private _enableInteractionOnController;
  40971. private _checkTeleportWithRay;
  40972. private _checkRotate;
  40973. private _checkTeleportBackwards;
  40974. private _enableTeleportationOnController;
  40975. private _createTeleportationCircles;
  40976. private _displayTeleportationTarget;
  40977. private _hideTeleportationTarget;
  40978. private _rotateCamera;
  40979. private _moveTeleportationSelectorTo;
  40980. private _workingVector;
  40981. private _workingQuaternion;
  40982. private _workingMatrix;
  40983. /**
  40984. * Teleports the users feet to the desired location
  40985. * @param location The location where the user's feet should be placed
  40986. */
  40987. teleportCamera(location: Vector3): void;
  40988. private _convertNormalToDirectionOfRay;
  40989. private _castRayAndSelectObject;
  40990. private _notifySelectedMeshUnselected;
  40991. /**
  40992. * Sets the color of the laser ray from the vr controllers.
  40993. * @param color new color for the ray.
  40994. */
  40995. changeLaserColor(color: Color3): void;
  40996. /**
  40997. * Sets the color of the ray from the vr headsets gaze.
  40998. * @param color new color for the ray.
  40999. */
  41000. changeGazeColor(color: Color3): void;
  41001. /**
  41002. * Exits VR and disposes of the vr experience helper
  41003. */
  41004. dispose(): void;
  41005. /**
  41006. * Gets the name of the VRExperienceHelper class
  41007. * @returns "VRExperienceHelper"
  41008. */
  41009. getClassName(): string;
  41010. }
  41011. }
  41012. declare module "babylonjs/Cameras/VR/index" {
  41013. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41014. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41015. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41016. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41017. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41018. export * from "babylonjs/Cameras/VR/webVRCamera";
  41019. }
  41020. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41021. import { Observable } from "babylonjs/Misc/observable";
  41022. import { Nullable } from "babylonjs/types";
  41023. import { IDisposable, Scene } from "babylonjs/scene";
  41024. import { Vector3 } from "babylonjs/Maths/math";
  41025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41026. import { Ray } from "babylonjs/Culling/ray";
  41027. /**
  41028. * Manages an XRSession
  41029. * @see https://doc.babylonjs.com/how_to/webxr
  41030. */
  41031. export class WebXRSessionManager implements IDisposable {
  41032. private scene;
  41033. /**
  41034. * Fires every time a new xrFrame arrives which can be used to update the camera
  41035. */
  41036. onXRFrameObservable: Observable<any>;
  41037. /**
  41038. * Fires when the xr session is ended either by the device or manually done
  41039. */
  41040. onXRSessionEnded: Observable<any>;
  41041. /** @hidden */
  41042. _xrSession: XRSession;
  41043. /** @hidden */
  41044. _frameOfReference: XRFrameOfReference;
  41045. /** @hidden */
  41046. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41047. /** @hidden */
  41048. _currentXRFrame: Nullable<XRFrame>;
  41049. private _xrNavigator;
  41050. private _xrDevice;
  41051. private _tmpMatrix;
  41052. /**
  41053. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41054. * @param scene The scene which the session should be created for
  41055. */
  41056. constructor(scene: Scene);
  41057. /**
  41058. * Initializes the manager
  41059. * After initialization enterXR can be called to start an XR session
  41060. * @returns Promise which resolves after it is initialized
  41061. */
  41062. initializeAsync(): Promise<void>;
  41063. /**
  41064. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41065. * @param sessionCreationOptions xr options to create the session with
  41066. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41067. * @returns Promise which resolves after it enters XR
  41068. */
  41069. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41070. /**
  41071. * Stops the xrSession and restores the renderloop
  41072. * @returns Promise which resolves after it exits XR
  41073. */
  41074. exitXRAsync(): Promise<void>;
  41075. /**
  41076. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41077. * @param ray ray to cast into the environment
  41078. * @returns Promise which resolves with a collision point in the environment if it exists
  41079. */
  41080. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41081. /**
  41082. * Checks if a session would be supported for the creation options specified
  41083. * @param options creation options to check if they are supported
  41084. * @returns true if supported
  41085. */
  41086. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41087. /**
  41088. * @hidden
  41089. * Converts the render layer of xrSession to a render target
  41090. * @param session session to create render target for
  41091. * @param scene scene the new render target should be created for
  41092. */
  41093. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41094. /**
  41095. * Disposes of the session manager
  41096. */
  41097. dispose(): void;
  41098. }
  41099. }
  41100. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41101. import { Scene } from "babylonjs/scene";
  41102. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41103. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41104. /**
  41105. * WebXR Camera which holds the views for the xrSession
  41106. * @see https://doc.babylonjs.com/how_to/webxr
  41107. */
  41108. export class WebXRCamera extends FreeCamera {
  41109. private static _TmpMatrix;
  41110. /**
  41111. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41112. * @param name the name of the camera
  41113. * @param scene the scene to add the camera to
  41114. */
  41115. constructor(name: string, scene: Scene);
  41116. private _updateNumberOfRigCameras;
  41117. /** @hidden */
  41118. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41119. /**
  41120. * Updates the cameras position from the current pose information of the XR session
  41121. * @param xrSessionManager the session containing pose information
  41122. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41123. */
  41124. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41125. }
  41126. }
  41127. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41128. import { Nullable } from "babylonjs/types";
  41129. import { Observable } from "babylonjs/Misc/observable";
  41130. import { IDisposable, Scene } from "babylonjs/scene";
  41131. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41133. import { Ray } from "babylonjs/Culling/ray";
  41134. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41135. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41136. /**
  41137. * States of the webXR experience
  41138. */
  41139. export enum WebXRState {
  41140. /**
  41141. * Transitioning to being in XR mode
  41142. */
  41143. ENTERING_XR = 0,
  41144. /**
  41145. * Transitioning to non XR mode
  41146. */
  41147. EXITING_XR = 1,
  41148. /**
  41149. * In XR mode and presenting
  41150. */
  41151. IN_XR = 2,
  41152. /**
  41153. * Not entered XR mode
  41154. */
  41155. NOT_IN_XR = 3
  41156. }
  41157. /**
  41158. * Helper class used to enable XR
  41159. * @see https://doc.babylonjs.com/how_to/webxr
  41160. */
  41161. export class WebXRExperienceHelper implements IDisposable {
  41162. private scene;
  41163. /**
  41164. * 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
  41165. */
  41166. container: AbstractMesh;
  41167. /**
  41168. * Camera used to render xr content
  41169. */
  41170. camera: WebXRCamera;
  41171. /**
  41172. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41173. */
  41174. state: WebXRState;
  41175. private _setState;
  41176. private static _TmpVector;
  41177. /**
  41178. * Fires when the state of the experience helper has changed
  41179. */
  41180. onStateChangedObservable: Observable<WebXRState>;
  41181. /** @hidden */
  41182. _sessionManager: WebXRSessionManager;
  41183. private _nonVRCamera;
  41184. private _originalSceneAutoClear;
  41185. private _supported;
  41186. /**
  41187. * Creates the experience helper
  41188. * @param scene the scene to attach the experience helper to
  41189. * @returns a promise for the experience helper
  41190. */
  41191. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41192. /**
  41193. * Creates a WebXRExperienceHelper
  41194. * @param scene The scene the helper should be created in
  41195. */
  41196. private constructor();
  41197. /**
  41198. * Exits XR mode and returns the scene to its original state
  41199. * @returns promise that resolves after xr mode has exited
  41200. */
  41201. exitXRAsync(): Promise<void>;
  41202. /**
  41203. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41204. * @param sessionCreationOptions options for the XR session
  41205. * @param frameOfReference frame of reference of the XR session
  41206. * @returns promise that resolves after xr mode has entered
  41207. */
  41208. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41209. /**
  41210. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41211. * @param ray ray to cast into the environment
  41212. * @returns Promise which resolves with a collision point in the environment if it exists
  41213. */
  41214. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41215. /**
  41216. * Updates the global position of the camera by moving the camera's container
  41217. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41218. * @param position The desired global position of the camera
  41219. */
  41220. setPositionOfCameraUsingContainer(position: Vector3): void;
  41221. /**
  41222. * Rotates the xr camera by rotating the camera's container around the camera's position
  41223. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41224. * @param rotation the desired quaternion rotation to apply to the camera
  41225. */
  41226. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41227. /**
  41228. * Checks if the creation options are supported by the xr session
  41229. * @param options creation options
  41230. * @returns true if supported
  41231. */
  41232. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41233. /**
  41234. * Disposes of the experience helper
  41235. */
  41236. dispose(): void;
  41237. }
  41238. }
  41239. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41240. import { Nullable } from "babylonjs/types";
  41241. import { Observable } from "babylonjs/Misc/observable";
  41242. import { IDisposable, Scene } from "babylonjs/scene";
  41243. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41244. /**
  41245. * Button which can be used to enter a different mode of XR
  41246. */
  41247. export class WebXREnterExitUIButton {
  41248. /** button element */
  41249. element: HTMLElement;
  41250. /** XR initialization options for the button */
  41251. initializationOptions: XRSessionCreationOptions;
  41252. /**
  41253. * Creates a WebXREnterExitUIButton
  41254. * @param element button element
  41255. * @param initializationOptions XR initialization options for the button
  41256. */
  41257. constructor(
  41258. /** button element */
  41259. element: HTMLElement,
  41260. /** XR initialization options for the button */
  41261. initializationOptions: XRSessionCreationOptions);
  41262. /**
  41263. * Overwritable function which can be used to update the button's visuals when the state changes
  41264. * @param activeButton the current active button in the UI
  41265. */
  41266. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41267. }
  41268. /**
  41269. * Options to create the webXR UI
  41270. */
  41271. export class WebXREnterExitUIOptions {
  41272. /**
  41273. * Context to enter xr with
  41274. */
  41275. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41276. /**
  41277. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41278. */
  41279. customButtons?: Array<WebXREnterExitUIButton>;
  41280. }
  41281. /**
  41282. * UI to allow the user to enter/exit XR mode
  41283. */
  41284. export class WebXREnterExitUI implements IDisposable {
  41285. private scene;
  41286. private _overlay;
  41287. private _buttons;
  41288. private _activeButton;
  41289. /**
  41290. * Fired every time the active button is changed.
  41291. *
  41292. * When xr is entered via a button that launches xr that button will be the callback parameter
  41293. *
  41294. * When exiting xr the callback parameter will be null)
  41295. */
  41296. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41297. /**
  41298. * Creates UI to allow the user to enter/exit XR mode
  41299. * @param scene the scene to add the ui to
  41300. * @param helper the xr experience helper to enter/exit xr with
  41301. * @param options options to configure the UI
  41302. * @returns the created ui
  41303. */
  41304. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41305. private constructor();
  41306. private _updateButtons;
  41307. /**
  41308. * Disposes of the object
  41309. */
  41310. dispose(): void;
  41311. }
  41312. }
  41313. declare module "babylonjs/Cameras/XR/webXRInput" {
  41314. import { IDisposable, Scene } from "babylonjs/scene";
  41315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41316. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41317. /**
  41318. * Represents an XR input
  41319. */
  41320. export class WebXRController {
  41321. /**
  41322. * 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
  41323. */
  41324. grip?: AbstractMesh;
  41325. /**
  41326. * Pointer which can be used to select objects or attach a visible laser to
  41327. */
  41328. pointer: AbstractMesh;
  41329. /**
  41330. * Creates the controller
  41331. * @see https://doc.babylonjs.com/how_to/webxr
  41332. * @param scene the scene which the controller should be associated to
  41333. */
  41334. constructor(scene: Scene);
  41335. /**
  41336. * Disposes of the object
  41337. */
  41338. dispose(): void;
  41339. }
  41340. /**
  41341. * XR input used to track XR inputs such as controllers/rays
  41342. */
  41343. export class WebXRInput implements IDisposable {
  41344. private helper;
  41345. /**
  41346. * XR controllers being tracked
  41347. */
  41348. controllers: Array<WebXRController>;
  41349. private _tmpMatrix;
  41350. private _frameObserver;
  41351. /**
  41352. * Initializes the WebXRInput
  41353. * @param helper experience helper which the input should be created for
  41354. */
  41355. constructor(helper: WebXRExperienceHelper);
  41356. /**
  41357. * Disposes of the object
  41358. */
  41359. dispose(): void;
  41360. }
  41361. }
  41362. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41363. import { Nullable } from "babylonjs/types";
  41364. import { IDisposable } from "babylonjs/scene";
  41365. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41366. /**
  41367. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41368. */
  41369. export class WebXRManagedOutputCanvas implements IDisposable {
  41370. private _canvas;
  41371. /**
  41372. * xrpresent context of the canvas which can be used to display/mirror xr content
  41373. */
  41374. canvasContext: Nullable<WebGLRenderingContext>;
  41375. /**
  41376. * Initializes the canvas to be added/removed upon entering/exiting xr
  41377. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41378. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41379. */
  41380. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41381. /**
  41382. * Disposes of the object
  41383. */
  41384. dispose(): void;
  41385. private _setManagedOutputCanvas;
  41386. private _addCanvas;
  41387. private _removeCanvas;
  41388. }
  41389. }
  41390. declare module "babylonjs/Cameras/XR/index" {
  41391. export * from "babylonjs/Cameras/XR/webXRCamera";
  41392. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41393. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41394. export * from "babylonjs/Cameras/XR/webXRInput";
  41395. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41396. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41397. }
  41398. declare module "babylonjs/Cameras/RigModes/index" {
  41399. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41400. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41401. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41402. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41403. }
  41404. declare module "babylonjs/Cameras/index" {
  41405. export * from "babylonjs/Cameras/Inputs/index";
  41406. export * from "babylonjs/Cameras/cameraInputsManager";
  41407. export * from "babylonjs/Cameras/camera";
  41408. export * from "babylonjs/Cameras/targetCamera";
  41409. export * from "babylonjs/Cameras/freeCamera";
  41410. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41411. export * from "babylonjs/Cameras/touchCamera";
  41412. export * from "babylonjs/Cameras/arcRotateCamera";
  41413. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41414. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41415. export * from "babylonjs/Cameras/flyCamera";
  41416. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41417. export * from "babylonjs/Cameras/followCamera";
  41418. export * from "babylonjs/Cameras/gamepadCamera";
  41419. export * from "babylonjs/Cameras/Stereoscopic/index";
  41420. export * from "babylonjs/Cameras/universalCamera";
  41421. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41422. export * from "babylonjs/Cameras/VR/index";
  41423. export * from "babylonjs/Cameras/XR/index";
  41424. export * from "babylonjs/Cameras/RigModes/index";
  41425. }
  41426. declare module "babylonjs/Collisions/index" {
  41427. export * from "babylonjs/Collisions/collider";
  41428. export * from "babylonjs/Collisions/collisionCoordinator";
  41429. export * from "babylonjs/Collisions/pickingInfo";
  41430. export * from "babylonjs/Collisions/intersectionInfo";
  41431. }
  41432. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41433. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41434. import { Vector3, Plane } from "babylonjs/Maths/math";
  41435. import { Ray } from "babylonjs/Culling/ray";
  41436. /**
  41437. * Contains an array of blocks representing the octree
  41438. */
  41439. export interface IOctreeContainer<T> {
  41440. /**
  41441. * Blocks within the octree
  41442. */
  41443. blocks: Array<OctreeBlock<T>>;
  41444. }
  41445. /**
  41446. * Class used to store a cell in an octree
  41447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41448. */
  41449. export class OctreeBlock<T> {
  41450. /**
  41451. * Gets the content of the current block
  41452. */
  41453. entries: T[];
  41454. /**
  41455. * Gets the list of block children
  41456. */
  41457. blocks: Array<OctreeBlock<T>>;
  41458. private _depth;
  41459. private _maxDepth;
  41460. private _capacity;
  41461. private _minPoint;
  41462. private _maxPoint;
  41463. private _boundingVectors;
  41464. private _creationFunc;
  41465. /**
  41466. * Creates a new block
  41467. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41468. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41469. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41470. * @param depth defines the current depth of this block in the octree
  41471. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41472. * @param creationFunc defines a callback to call when an element is added to the block
  41473. */
  41474. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41475. /**
  41476. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41477. */
  41478. readonly capacity: number;
  41479. /**
  41480. * Gets the minimum vector (in world space) of the block's bounding box
  41481. */
  41482. readonly minPoint: Vector3;
  41483. /**
  41484. * Gets the maximum vector (in world space) of the block's bounding box
  41485. */
  41486. readonly maxPoint: Vector3;
  41487. /**
  41488. * Add a new element to this block
  41489. * @param entry defines the element to add
  41490. */
  41491. addEntry(entry: T): void;
  41492. /**
  41493. * Remove an element from this block
  41494. * @param entry defines the element to remove
  41495. */
  41496. removeEntry(entry: T): void;
  41497. /**
  41498. * Add an array of elements to this block
  41499. * @param entries defines the array of elements to add
  41500. */
  41501. addEntries(entries: T[]): void;
  41502. /**
  41503. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41504. * @param frustumPlanes defines the frustum planes to test
  41505. * @param selection defines the array to store current content if selection is positive
  41506. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41507. */
  41508. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41509. /**
  41510. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41511. * @param sphereCenter defines the bounding sphere center
  41512. * @param sphereRadius defines the bounding sphere radius
  41513. * @param selection defines the array to store current content if selection is positive
  41514. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41515. */
  41516. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41517. /**
  41518. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41519. * @param ray defines the ray to test with
  41520. * @param selection defines the array to store current content if selection is positive
  41521. */
  41522. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41523. /**
  41524. * Subdivide the content into child blocks (this block will then be empty)
  41525. */
  41526. createInnerBlocks(): void;
  41527. /**
  41528. * @hidden
  41529. */
  41530. 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;
  41531. }
  41532. }
  41533. declare module "babylonjs/Culling/Octrees/octree" {
  41534. import { SmartArray } from "babylonjs/Misc/smartArray";
  41535. import { Vector3, Plane } from "babylonjs/Maths/math";
  41536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41538. import { Ray } from "babylonjs/Culling/ray";
  41539. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41540. /**
  41541. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41542. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41543. */
  41544. export class Octree<T> {
  41545. /** 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.) */
  41546. maxDepth: number;
  41547. /**
  41548. * Blocks within the octree containing objects
  41549. */
  41550. blocks: Array<OctreeBlock<T>>;
  41551. /**
  41552. * Content stored in the octree
  41553. */
  41554. dynamicContent: T[];
  41555. private _maxBlockCapacity;
  41556. private _selectionContent;
  41557. private _creationFunc;
  41558. /**
  41559. * Creates a octree
  41560. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41561. * @param creationFunc function to be used to instatiate the octree
  41562. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41563. * @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.)
  41564. */
  41565. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41566. /** 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.) */
  41567. maxDepth?: number);
  41568. /**
  41569. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41570. * @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);
  41571. * @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);
  41572. * @param entries meshes to be added to the octree blocks
  41573. */
  41574. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41575. /**
  41576. * Adds a mesh to the octree
  41577. * @param entry Mesh to add to the octree
  41578. */
  41579. addMesh(entry: T): void;
  41580. /**
  41581. * Remove an element from the octree
  41582. * @param entry defines the element to remove
  41583. */
  41584. removeMesh(entry: T): void;
  41585. /**
  41586. * Selects an array of meshes within the frustum
  41587. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41588. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41589. * @returns array of meshes within the frustum
  41590. */
  41591. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41592. /**
  41593. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41594. * @param sphereCenter defines the bounding sphere center
  41595. * @param sphereRadius defines the bounding sphere radius
  41596. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41597. * @returns an array of objects that intersect the sphere
  41598. */
  41599. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41600. /**
  41601. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41602. * @param ray defines the ray to test with
  41603. * @returns array of intersected objects
  41604. */
  41605. intersectsRay(ray: Ray): SmartArray<T>;
  41606. /**
  41607. * Adds a mesh into the octree block if it intersects the block
  41608. */
  41609. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41610. /**
  41611. * Adds a submesh into the octree block if it intersects the block
  41612. */
  41613. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41614. }
  41615. }
  41616. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41617. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41618. import { Scene } from "babylonjs/scene";
  41619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41621. import { Ray } from "babylonjs/Culling/ray";
  41622. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41623. import { Collider } from "babylonjs/Collisions/collider";
  41624. module "babylonjs/scene" {
  41625. interface Scene {
  41626. /**
  41627. * @hidden
  41628. * Backing Filed
  41629. */
  41630. _selectionOctree: Octree<AbstractMesh>;
  41631. /**
  41632. * Gets the octree used to boost mesh selection (picking)
  41633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41634. */
  41635. selectionOctree: Octree<AbstractMesh>;
  41636. /**
  41637. * Creates or updates the octree used to boost selection (picking)
  41638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41639. * @param maxCapacity defines the maximum capacity per leaf
  41640. * @param maxDepth defines the maximum depth of the octree
  41641. * @returns an octree of AbstractMesh
  41642. */
  41643. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41644. }
  41645. }
  41646. module "babylonjs/Meshes/abstractMesh" {
  41647. interface AbstractMesh {
  41648. /**
  41649. * @hidden
  41650. * Backing Field
  41651. */
  41652. _submeshesOctree: Octree<SubMesh>;
  41653. /**
  41654. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41655. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41656. * @param maxCapacity defines the maximum size of each block (64 by default)
  41657. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41658. * @returns the new octree
  41659. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41661. */
  41662. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41663. }
  41664. }
  41665. /**
  41666. * Defines the octree scene component responsible to manage any octrees
  41667. * in a given scene.
  41668. */
  41669. export class OctreeSceneComponent {
  41670. /**
  41671. * The component name helpfull to identify the component in the list of scene components.
  41672. */
  41673. readonly name: string;
  41674. /**
  41675. * The scene the component belongs to.
  41676. */
  41677. scene: Scene;
  41678. /**
  41679. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41680. */
  41681. readonly checksIsEnabled: boolean;
  41682. /**
  41683. * Creates a new instance of the component for the given scene
  41684. * @param scene Defines the scene to register the component in
  41685. */
  41686. constructor(scene: Scene);
  41687. /**
  41688. * Registers the component in a given scene
  41689. */
  41690. register(): void;
  41691. /**
  41692. * Return the list of active meshes
  41693. * @returns the list of active meshes
  41694. */
  41695. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41696. /**
  41697. * Return the list of active sub meshes
  41698. * @param mesh The mesh to get the candidates sub meshes from
  41699. * @returns the list of active sub meshes
  41700. */
  41701. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41702. private _tempRay;
  41703. /**
  41704. * Return the list of sub meshes intersecting with a given local ray
  41705. * @param mesh defines the mesh to find the submesh for
  41706. * @param localRay defines the ray in local space
  41707. * @returns the list of intersecting sub meshes
  41708. */
  41709. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41710. /**
  41711. * Return the list of sub meshes colliding with a collider
  41712. * @param mesh defines the mesh to find the submesh for
  41713. * @param collider defines the collider to evaluate the collision against
  41714. * @returns the list of colliding sub meshes
  41715. */
  41716. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41717. /**
  41718. * Rebuilds the elements related to this component in case of
  41719. * context lost for instance.
  41720. */
  41721. rebuild(): void;
  41722. /**
  41723. * Disposes the component and the associated ressources.
  41724. */
  41725. dispose(): void;
  41726. }
  41727. }
  41728. declare module "babylonjs/Culling/Octrees/index" {
  41729. export * from "babylonjs/Culling/Octrees/octree";
  41730. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41731. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41732. }
  41733. declare module "babylonjs/Culling/index" {
  41734. export * from "babylonjs/Culling/boundingBox";
  41735. export * from "babylonjs/Culling/boundingInfo";
  41736. export * from "babylonjs/Culling/boundingSphere";
  41737. export * from "babylonjs/Culling/Octrees/index";
  41738. export * from "babylonjs/Culling/ray";
  41739. }
  41740. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41741. import { IDisposable, Scene } from "babylonjs/scene";
  41742. import { Nullable } from "babylonjs/types";
  41743. import { Observable } from "babylonjs/Misc/observable";
  41744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41745. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41746. /**
  41747. * Renders a layer on top of an existing scene
  41748. */
  41749. export class UtilityLayerRenderer implements IDisposable {
  41750. /** the original scene that will be rendered on top of */
  41751. originalScene: Scene;
  41752. private _pointerCaptures;
  41753. private _lastPointerEvents;
  41754. private static _DefaultUtilityLayer;
  41755. private static _DefaultKeepDepthUtilityLayer;
  41756. private _sharedGizmoLight;
  41757. /**
  41758. * @hidden
  41759. * Light which used by gizmos to get light shading
  41760. */
  41761. _getSharedGizmoLight(): HemisphericLight;
  41762. /**
  41763. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41764. */
  41765. pickUtilitySceneFirst: boolean;
  41766. /**
  41767. * 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)
  41768. */
  41769. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41770. /**
  41771. * 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)
  41772. */
  41773. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41774. /**
  41775. * The scene that is rendered on top of the original scene
  41776. */
  41777. utilityLayerScene: Scene;
  41778. /**
  41779. * If the utility layer should automatically be rendered on top of existing scene
  41780. */
  41781. shouldRender: boolean;
  41782. /**
  41783. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41784. */
  41785. onlyCheckPointerDownEvents: boolean;
  41786. /**
  41787. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41788. */
  41789. processAllEvents: boolean;
  41790. /**
  41791. * Observable raised when the pointer move from the utility layer scene to the main scene
  41792. */
  41793. onPointerOutObservable: Observable<number>;
  41794. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41795. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41796. private _afterRenderObserver;
  41797. private _sceneDisposeObserver;
  41798. private _originalPointerObserver;
  41799. /**
  41800. * Instantiates a UtilityLayerRenderer
  41801. * @param originalScene the original scene that will be rendered on top of
  41802. * @param handleEvents boolean indicating if the utility layer should handle events
  41803. */
  41804. constructor(
  41805. /** the original scene that will be rendered on top of */
  41806. originalScene: Scene, handleEvents?: boolean);
  41807. private _notifyObservers;
  41808. /**
  41809. * Renders the utility layers scene on top of the original scene
  41810. */
  41811. render(): void;
  41812. /**
  41813. * Disposes of the renderer
  41814. */
  41815. dispose(): void;
  41816. private _updateCamera;
  41817. }
  41818. }
  41819. declare module "babylonjs/Gizmos/gizmo" {
  41820. import { Nullable } from "babylonjs/types";
  41821. import { IDisposable } from "babylonjs/scene";
  41822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41823. import { Mesh } from "babylonjs/Meshes/mesh";
  41824. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41825. /**
  41826. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41827. */
  41828. export class Gizmo implements IDisposable {
  41829. /** The utility layer the gizmo will be added to */
  41830. gizmoLayer: UtilityLayerRenderer;
  41831. /**
  41832. * The root mesh of the gizmo
  41833. */
  41834. _rootMesh: Mesh;
  41835. private _attachedMesh;
  41836. /**
  41837. * Ratio for the scale of the gizmo (Default: 1)
  41838. */
  41839. scaleRatio: number;
  41840. private _tmpMatrix;
  41841. /**
  41842. * If a custom mesh has been set (Default: false)
  41843. */
  41844. protected _customMeshSet: boolean;
  41845. /**
  41846. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41847. * * When set, interactions will be enabled
  41848. */
  41849. attachedMesh: Nullable<AbstractMesh>;
  41850. /**
  41851. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41852. * @param mesh The mesh to replace the default mesh of the gizmo
  41853. */
  41854. setCustomMesh(mesh: Mesh): void;
  41855. /**
  41856. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41857. */
  41858. updateGizmoRotationToMatchAttachedMesh: boolean;
  41859. /**
  41860. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41861. */
  41862. updateGizmoPositionToMatchAttachedMesh: boolean;
  41863. /**
  41864. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41865. */
  41866. protected _updateScale: boolean;
  41867. protected _interactionsEnabled: boolean;
  41868. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41869. private _beforeRenderObserver;
  41870. /**
  41871. * Creates a gizmo
  41872. * @param gizmoLayer The utility layer the gizmo will be added to
  41873. */
  41874. constructor(
  41875. /** The utility layer the gizmo will be added to */
  41876. gizmoLayer?: UtilityLayerRenderer);
  41877. private _tempVector;
  41878. /**
  41879. * @hidden
  41880. * Updates the gizmo to match the attached mesh's position/rotation
  41881. */
  41882. protected _update(): void;
  41883. /**
  41884. * Disposes of the gizmo
  41885. */
  41886. dispose(): void;
  41887. }
  41888. }
  41889. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41890. import { Observable } from "babylonjs/Misc/observable";
  41891. import { Nullable } from "babylonjs/types";
  41892. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41895. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41896. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41898. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41899. import { Scene } from "babylonjs/scene";
  41900. /**
  41901. * Single axis drag gizmo
  41902. */
  41903. export class AxisDragGizmo extends Gizmo {
  41904. /**
  41905. * Drag behavior responsible for the gizmos dragging interactions
  41906. */
  41907. dragBehavior: PointerDragBehavior;
  41908. private _pointerObserver;
  41909. /**
  41910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41911. */
  41912. snapDistance: number;
  41913. /**
  41914. * Event that fires each time the gizmo snaps to a new location.
  41915. * * snapDistance is the the change in distance
  41916. */
  41917. onSnapObservable: Observable<{
  41918. snapDistance: number;
  41919. }>;
  41920. /** @hidden */
  41921. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41922. /** @hidden */
  41923. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41924. /**
  41925. * Creates an AxisDragGizmo
  41926. * @param gizmoLayer The utility layer the gizmo will be added to
  41927. * @param dragAxis The axis which the gizmo will be able to drag on
  41928. * @param color The color of the gizmo
  41929. */
  41930. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41932. /**
  41933. * Disposes of the gizmo
  41934. */
  41935. dispose(): void;
  41936. }
  41937. }
  41938. declare module "babylonjs/Debug/axesViewer" {
  41939. import { Vector3 } from "babylonjs/Maths/math";
  41940. import { Nullable } from "babylonjs/types";
  41941. import { Scene } from "babylonjs/scene";
  41942. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41943. /**
  41944. * The Axes viewer will show 3 axes in a specific point in space
  41945. */
  41946. export class AxesViewer {
  41947. private _xAxis;
  41948. private _yAxis;
  41949. private _zAxis;
  41950. private _scaleLinesFactor;
  41951. private _instanced;
  41952. /**
  41953. * Gets the hosting scene
  41954. */
  41955. scene: Scene;
  41956. /**
  41957. * Gets or sets a number used to scale line length
  41958. */
  41959. scaleLines: number;
  41960. /** Gets the node hierarchy used to render x-axis */
  41961. readonly xAxis: TransformNode;
  41962. /** Gets the node hierarchy used to render y-axis */
  41963. readonly yAxis: TransformNode;
  41964. /** Gets the node hierarchy used to render z-axis */
  41965. readonly zAxis: TransformNode;
  41966. /**
  41967. * Creates a new AxesViewer
  41968. * @param scene defines the hosting scene
  41969. * @param scaleLines defines a number used to scale line length (1 by default)
  41970. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41971. * @param xAxis defines the node hierarchy used to render the x-axis
  41972. * @param yAxis defines the node hierarchy used to render the y-axis
  41973. * @param zAxis defines the node hierarchy used to render the z-axis
  41974. */
  41975. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41976. /**
  41977. * Force the viewer to update
  41978. * @param position defines the position of the viewer
  41979. * @param xaxis defines the x axis of the viewer
  41980. * @param yaxis defines the y axis of the viewer
  41981. * @param zaxis defines the z axis of the viewer
  41982. */
  41983. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41984. /**
  41985. * Creates an instance of this axes viewer.
  41986. * @returns a new axes viewer with instanced meshes
  41987. */
  41988. createInstance(): AxesViewer;
  41989. /** Releases resources */
  41990. dispose(): void;
  41991. private static _SetRenderingGroupId;
  41992. }
  41993. }
  41994. declare module "babylonjs/Debug/boneAxesViewer" {
  41995. import { Nullable } from "babylonjs/types";
  41996. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41997. import { Vector3 } from "babylonjs/Maths/math";
  41998. import { Mesh } from "babylonjs/Meshes/mesh";
  41999. import { Bone } from "babylonjs/Bones/bone";
  42000. import { Scene } from "babylonjs/scene";
  42001. /**
  42002. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42003. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42004. */
  42005. export class BoneAxesViewer extends AxesViewer {
  42006. /**
  42007. * Gets or sets the target mesh where to display the axes viewer
  42008. */
  42009. mesh: Nullable<Mesh>;
  42010. /**
  42011. * Gets or sets the target bone where to display the axes viewer
  42012. */
  42013. bone: Nullable<Bone>;
  42014. /** Gets current position */
  42015. pos: Vector3;
  42016. /** Gets direction of X axis */
  42017. xaxis: Vector3;
  42018. /** Gets direction of Y axis */
  42019. yaxis: Vector3;
  42020. /** Gets direction of Z axis */
  42021. zaxis: Vector3;
  42022. /**
  42023. * Creates a new BoneAxesViewer
  42024. * @param scene defines the hosting scene
  42025. * @param bone defines the target bone
  42026. * @param mesh defines the target mesh
  42027. * @param scaleLines defines a scaling factor for line length (1 by default)
  42028. */
  42029. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42030. /**
  42031. * Force the viewer to update
  42032. */
  42033. update(): void;
  42034. /** Releases resources */
  42035. dispose(): void;
  42036. }
  42037. }
  42038. declare module "babylonjs/Debug/debugLayer" {
  42039. import { Observable } from "babylonjs/Misc/observable";
  42040. import { Scene } from "babylonjs/scene";
  42041. /**
  42042. * Interface used to define scene explorer extensibility option
  42043. */
  42044. export interface IExplorerExtensibilityOption {
  42045. /**
  42046. * Define the option label
  42047. */
  42048. label: string;
  42049. /**
  42050. * Defines the action to execute on click
  42051. */
  42052. action: (entity: any) => void;
  42053. }
  42054. /**
  42055. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42056. */
  42057. export interface IExplorerExtensibilityGroup {
  42058. /**
  42059. * Defines a predicate to test if a given type mut be extended
  42060. */
  42061. predicate: (entity: any) => boolean;
  42062. /**
  42063. * Gets the list of options added to a type
  42064. */
  42065. entries: IExplorerExtensibilityOption[];
  42066. }
  42067. /**
  42068. * Interface used to define the options to use to create the Inspector
  42069. */
  42070. export interface IInspectorOptions {
  42071. /**
  42072. * Display in overlay mode (default: false)
  42073. */
  42074. overlay?: boolean;
  42075. /**
  42076. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42077. */
  42078. globalRoot?: HTMLElement;
  42079. /**
  42080. * Display the Scene explorer
  42081. */
  42082. showExplorer?: boolean;
  42083. /**
  42084. * Display the property inspector
  42085. */
  42086. showInspector?: boolean;
  42087. /**
  42088. * Display in embed mode (both panes on the right)
  42089. */
  42090. embedMode?: boolean;
  42091. /**
  42092. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42093. */
  42094. handleResize?: boolean;
  42095. /**
  42096. * Allow the panes to popup (default: true)
  42097. */
  42098. enablePopup?: boolean;
  42099. /**
  42100. * Allow the panes to be closed by users (default: true)
  42101. */
  42102. enableClose?: boolean;
  42103. /**
  42104. * Optional list of extensibility entries
  42105. */
  42106. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42107. /**
  42108. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42109. */
  42110. inspectorURL?: string;
  42111. }
  42112. module "babylonjs/scene" {
  42113. interface Scene {
  42114. /**
  42115. * @hidden
  42116. * Backing field
  42117. */
  42118. _debugLayer: DebugLayer;
  42119. /**
  42120. * Gets the debug layer (aka Inspector) associated with the scene
  42121. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42122. */
  42123. debugLayer: DebugLayer;
  42124. }
  42125. }
  42126. /**
  42127. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42128. * what is happening in your scene
  42129. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42130. */
  42131. export class DebugLayer {
  42132. /**
  42133. * Define the url to get the inspector script from.
  42134. * By default it uses the babylonjs CDN.
  42135. * @ignoreNaming
  42136. */
  42137. static InspectorURL: string;
  42138. private _scene;
  42139. private BJSINSPECTOR;
  42140. /**
  42141. * Observable triggered when a property is changed through the inspector.
  42142. */
  42143. onPropertyChangedObservable: Observable<{
  42144. object: any;
  42145. property: string;
  42146. value: any;
  42147. initialValue: any;
  42148. }>;
  42149. /**
  42150. * Instantiates a new debug layer.
  42151. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42152. * what is happening in your scene
  42153. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42154. * @param scene Defines the scene to inspect
  42155. */
  42156. constructor(scene: Scene);
  42157. /** Creates the inspector window. */
  42158. private _createInspector;
  42159. /**
  42160. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42161. * @param entity defines the entity to select
  42162. * @param lineContainerTitle defines the specific block to highlight
  42163. */
  42164. select(entity: any, lineContainerTitle?: string): void;
  42165. /** Get the inspector from bundle or global */
  42166. private _getGlobalInspector;
  42167. /**
  42168. * Get if the inspector is visible or not.
  42169. * @returns true if visible otherwise, false
  42170. */
  42171. isVisible(): boolean;
  42172. /**
  42173. * Hide the inspector and close its window.
  42174. */
  42175. hide(): void;
  42176. /**
  42177. * Launch the debugLayer.
  42178. * @param config Define the configuration of the inspector
  42179. * @return a promise fulfilled when the debug layer is visible
  42180. */
  42181. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42182. }
  42183. }
  42184. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42185. import { Nullable } from "babylonjs/types";
  42186. import { Scene } from "babylonjs/scene";
  42187. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42188. import { Mesh } from "babylonjs/Meshes/mesh";
  42189. /**
  42190. * Class containing static functions to help procedurally build meshes
  42191. */
  42192. export class BoxBuilder {
  42193. /**
  42194. * Creates a box mesh
  42195. * * The parameter `size` sets the size (float) of each box side (default 1)
  42196. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42197. * * 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)
  42198. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42202. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42203. * @param name defines the name of the mesh
  42204. * @param options defines the options used to create the mesh
  42205. * @param scene defines the hosting scene
  42206. * @returns the box mesh
  42207. */
  42208. static CreateBox(name: string, options: {
  42209. size?: number;
  42210. width?: number;
  42211. height?: number;
  42212. depth?: number;
  42213. faceUV?: Vector4[];
  42214. faceColors?: Color4[];
  42215. sideOrientation?: number;
  42216. frontUVs?: Vector4;
  42217. backUVs?: Vector4;
  42218. updatable?: boolean;
  42219. }, scene?: Nullable<Scene>): Mesh;
  42220. }
  42221. }
  42222. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42223. import { Vector4 } from "babylonjs/Maths/math";
  42224. import { Mesh } from "babylonjs/Meshes/mesh";
  42225. /**
  42226. * Class containing static functions to help procedurally build meshes
  42227. */
  42228. export class SphereBuilder {
  42229. /**
  42230. * Creates a sphere mesh
  42231. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42232. * * 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`)
  42233. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42234. * * 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
  42235. * * 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)
  42236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42239. * @param name defines the name of the mesh
  42240. * @param options defines the options used to create the mesh
  42241. * @param scene defines the hosting scene
  42242. * @returns the sphere mesh
  42243. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42244. */
  42245. static CreateSphere(name: string, options: {
  42246. segments?: number;
  42247. diameter?: number;
  42248. diameterX?: number;
  42249. diameterY?: number;
  42250. diameterZ?: number;
  42251. arc?: number;
  42252. slice?: number;
  42253. sideOrientation?: number;
  42254. frontUVs?: Vector4;
  42255. backUVs?: Vector4;
  42256. updatable?: boolean;
  42257. }, scene: any): Mesh;
  42258. }
  42259. }
  42260. declare module "babylonjs/Debug/physicsViewer" {
  42261. import { Nullable } from "babylonjs/types";
  42262. import { Scene } from "babylonjs/scene";
  42263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42264. import { Mesh } from "babylonjs/Meshes/mesh";
  42265. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42266. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42267. /**
  42268. * Used to show the physics impostor around the specific mesh
  42269. */
  42270. export class PhysicsViewer {
  42271. /** @hidden */
  42272. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42273. /** @hidden */
  42274. protected _meshes: Array<Nullable<AbstractMesh>>;
  42275. /** @hidden */
  42276. protected _scene: Nullable<Scene>;
  42277. /** @hidden */
  42278. protected _numMeshes: number;
  42279. /** @hidden */
  42280. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42281. private _renderFunction;
  42282. private _utilityLayer;
  42283. private _debugBoxMesh;
  42284. private _debugSphereMesh;
  42285. private _debugMaterial;
  42286. private _debugMeshMeshes;
  42287. /**
  42288. * Creates a new PhysicsViewer
  42289. * @param scene defines the hosting scene
  42290. */
  42291. constructor(scene: Scene);
  42292. /** @hidden */
  42293. protected _updateDebugMeshes(): void;
  42294. /**
  42295. * Renders a specified physic impostor
  42296. * @param impostor defines the impostor to render
  42297. * @param targetMesh defines the mesh represented by the impostor
  42298. * @returns the new debug mesh used to render the impostor
  42299. */
  42300. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42301. /**
  42302. * Hides a specified physic impostor
  42303. * @param impostor defines the impostor to hide
  42304. */
  42305. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42306. private _getDebugMaterial;
  42307. private _getDebugBoxMesh;
  42308. private _getDebugSphereMesh;
  42309. private _getDebugMeshMesh;
  42310. private _getDebugMesh;
  42311. /** Releases all resources */
  42312. dispose(): void;
  42313. }
  42314. }
  42315. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42316. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42317. import { Nullable } from "babylonjs/types";
  42318. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42319. import { Scene } from "babylonjs/scene";
  42320. /**
  42321. * Class containing static functions to help procedurally build meshes
  42322. */
  42323. export class LinesBuilder {
  42324. /**
  42325. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42326. * * 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
  42327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42328. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42329. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42330. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42331. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42332. * * 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
  42333. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42336. * @param name defines the name of the new line system
  42337. * @param options defines the options used to create the line system
  42338. * @param scene defines the hosting scene
  42339. * @returns a new line system mesh
  42340. */
  42341. static CreateLineSystem(name: string, options: {
  42342. lines: Vector3[][];
  42343. updatable?: boolean;
  42344. instance?: Nullable<LinesMesh>;
  42345. colors?: Nullable<Color4[][]>;
  42346. useVertexAlpha?: boolean;
  42347. }, scene: Nullable<Scene>): LinesMesh;
  42348. /**
  42349. * Creates a line mesh
  42350. * 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
  42351. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42352. * * The parameter `points` is an array successive Vector3
  42353. * * 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
  42354. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42355. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42356. * * When updating an instance, remember that only point positions can change, not the number of points
  42357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42359. * @param name defines the name of the new line system
  42360. * @param options defines the options used to create the line system
  42361. * @param scene defines the hosting scene
  42362. * @returns a new line mesh
  42363. */
  42364. static CreateLines(name: string, options: {
  42365. points: Vector3[];
  42366. updatable?: boolean;
  42367. instance?: Nullable<LinesMesh>;
  42368. colors?: Color4[];
  42369. useVertexAlpha?: boolean;
  42370. }, scene?: Nullable<Scene>): LinesMesh;
  42371. /**
  42372. * Creates a dashed line mesh
  42373. * * 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
  42374. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42375. * * The parameter `points` is an array successive Vector3
  42376. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42377. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42378. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42379. * * 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
  42380. * * When updating an instance, remember that only point positions can change, not the number of points
  42381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42382. * @param name defines the name of the mesh
  42383. * @param options defines the options used to create the mesh
  42384. * @param scene defines the hosting scene
  42385. * @returns the dashed line mesh
  42386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42387. */
  42388. static CreateDashedLines(name: string, options: {
  42389. points: Vector3[];
  42390. dashSize?: number;
  42391. gapSize?: number;
  42392. dashNb?: number;
  42393. updatable?: boolean;
  42394. instance?: LinesMesh;
  42395. }, scene?: Nullable<Scene>): LinesMesh;
  42396. }
  42397. }
  42398. declare module "babylonjs/Debug/rayHelper" {
  42399. import { Nullable } from "babylonjs/types";
  42400. import { Ray } from "babylonjs/Culling/ray";
  42401. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42402. import { Scene } from "babylonjs/scene";
  42403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42404. import "babylonjs/Meshes/Builders/linesBuilder";
  42405. /**
  42406. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42407. * in order to better appreciate the issue one might have.
  42408. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42409. */
  42410. export class RayHelper {
  42411. /**
  42412. * Defines the ray we are currently tryin to visualize.
  42413. */
  42414. ray: Nullable<Ray>;
  42415. private _renderPoints;
  42416. private _renderLine;
  42417. private _renderFunction;
  42418. private _scene;
  42419. private _updateToMeshFunction;
  42420. private _attachedToMesh;
  42421. private _meshSpaceDirection;
  42422. private _meshSpaceOrigin;
  42423. /**
  42424. * Helper function to create a colored helper in a scene in one line.
  42425. * @param ray Defines the ray we are currently tryin to visualize
  42426. * @param scene Defines the scene the ray is used in
  42427. * @param color Defines the color we want to see the ray in
  42428. * @returns The newly created ray helper.
  42429. */
  42430. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42431. /**
  42432. * Instantiate a new ray helper.
  42433. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42434. * in order to better appreciate the issue one might have.
  42435. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42436. * @param ray Defines the ray we are currently tryin to visualize
  42437. */
  42438. constructor(ray: Ray);
  42439. /**
  42440. * Shows the ray we are willing to debug.
  42441. * @param scene Defines the scene the ray needs to be rendered in
  42442. * @param color Defines the color the ray needs to be rendered in
  42443. */
  42444. show(scene: Scene, color?: Color3): void;
  42445. /**
  42446. * Hides the ray we are debugging.
  42447. */
  42448. hide(): void;
  42449. private _render;
  42450. /**
  42451. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42452. * @param mesh Defines the mesh we want the helper attached to
  42453. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42454. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42455. * @param length Defines the length of the ray
  42456. */
  42457. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42458. /**
  42459. * Detach the ray helper from the mesh it has previously been attached to.
  42460. */
  42461. detachFromMesh(): void;
  42462. private _updateToMesh;
  42463. /**
  42464. * Dispose the helper and release its associated resources.
  42465. */
  42466. dispose(): void;
  42467. }
  42468. }
  42469. declare module "babylonjs/Debug/skeletonViewer" {
  42470. import { Color3 } from "babylonjs/Maths/math";
  42471. import { Scene } from "babylonjs/scene";
  42472. import { Nullable } from "babylonjs/types";
  42473. import { Skeleton } from "babylonjs/Bones/skeleton";
  42474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42475. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42476. /**
  42477. * Class used to render a debug view of a given skeleton
  42478. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42479. */
  42480. export class SkeletonViewer {
  42481. /** defines the skeleton to render */
  42482. skeleton: Skeleton;
  42483. /** defines the mesh attached to the skeleton */
  42484. mesh: AbstractMesh;
  42485. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42486. autoUpdateBonesMatrices: boolean;
  42487. /** defines the rendering group id to use with the viewer */
  42488. renderingGroupId: number;
  42489. /** Gets or sets the color used to render the skeleton */
  42490. color: Color3;
  42491. private _scene;
  42492. private _debugLines;
  42493. private _debugMesh;
  42494. private _isEnabled;
  42495. private _renderFunction;
  42496. private _utilityLayer;
  42497. /**
  42498. * Returns the mesh used to render the bones
  42499. */
  42500. readonly debugMesh: Nullable<LinesMesh>;
  42501. /**
  42502. * Creates a new SkeletonViewer
  42503. * @param skeleton defines the skeleton to render
  42504. * @param mesh defines the mesh attached to the skeleton
  42505. * @param scene defines the hosting scene
  42506. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42507. * @param renderingGroupId defines the rendering group id to use with the viewer
  42508. */
  42509. constructor(
  42510. /** defines the skeleton to render */
  42511. skeleton: Skeleton,
  42512. /** defines the mesh attached to the skeleton */
  42513. mesh: AbstractMesh, scene: Scene,
  42514. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42515. autoUpdateBonesMatrices?: boolean,
  42516. /** defines the rendering group id to use with the viewer */
  42517. renderingGroupId?: number);
  42518. /** Gets or sets a boolean indicating if the viewer is enabled */
  42519. isEnabled: boolean;
  42520. private _getBonePosition;
  42521. private _getLinesForBonesWithLength;
  42522. private _getLinesForBonesNoLength;
  42523. /** Update the viewer to sync with current skeleton state */
  42524. update(): void;
  42525. /** Release associated resources */
  42526. dispose(): void;
  42527. }
  42528. }
  42529. declare module "babylonjs/Debug/index" {
  42530. export * from "babylonjs/Debug/axesViewer";
  42531. export * from "babylonjs/Debug/boneAxesViewer";
  42532. export * from "babylonjs/Debug/debugLayer";
  42533. export * from "babylonjs/Debug/physicsViewer";
  42534. export * from "babylonjs/Debug/rayHelper";
  42535. export * from "babylonjs/Debug/skeletonViewer";
  42536. }
  42537. declare module "babylonjs/Engines/nullEngine" {
  42538. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42539. import { Scene } from "babylonjs/scene";
  42540. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42541. import { Engine } from "babylonjs/Engines/engine";
  42542. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42543. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42545. import { Effect } from "babylonjs/Materials/effect";
  42546. /**
  42547. * Options to create the null engine
  42548. */
  42549. export class NullEngineOptions {
  42550. /**
  42551. * Render width (Default: 512)
  42552. */
  42553. renderWidth: number;
  42554. /**
  42555. * Render height (Default: 256)
  42556. */
  42557. renderHeight: number;
  42558. /**
  42559. * Texture size (Default: 512)
  42560. */
  42561. textureSize: number;
  42562. /**
  42563. * If delta time between frames should be constant
  42564. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42565. */
  42566. deterministicLockstep: boolean;
  42567. /**
  42568. * Maximum about of steps between frames (Default: 4)
  42569. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42570. */
  42571. lockstepMaxSteps: number;
  42572. }
  42573. /**
  42574. * The null engine class provides support for headless version of babylon.js.
  42575. * This can be used in server side scenario or for testing purposes
  42576. */
  42577. export class NullEngine extends Engine {
  42578. private _options;
  42579. /**
  42580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42581. */
  42582. isDeterministicLockStep(): boolean;
  42583. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42584. getLockstepMaxSteps(): number;
  42585. /**
  42586. * Sets hardware scaling, used to save performance if needed
  42587. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42588. */
  42589. getHardwareScalingLevel(): number;
  42590. constructor(options?: NullEngineOptions);
  42591. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42592. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42593. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42594. getRenderWidth(useScreen?: boolean): number;
  42595. getRenderHeight(useScreen?: boolean): number;
  42596. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42597. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42598. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42599. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42600. bindSamplers(effect: Effect): void;
  42601. enableEffect(effect: Effect): void;
  42602. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42603. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42604. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42605. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42606. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42607. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42608. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42609. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42610. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42611. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42612. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42613. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42614. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42615. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42616. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42617. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42618. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42619. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42620. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42621. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42622. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42623. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42624. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42625. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42626. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42627. bindBuffers(vertexBuffers: {
  42628. [key: string]: VertexBuffer;
  42629. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42630. wipeCaches(bruteForce?: boolean): void;
  42631. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42633. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42634. /** @hidden */
  42635. _createTexture(): WebGLTexture;
  42636. /** @hidden */
  42637. _releaseTexture(texture: InternalTexture): void;
  42638. 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;
  42639. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42640. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42641. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42642. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42643. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42644. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42645. areAllEffectsReady(): boolean;
  42646. /**
  42647. * @hidden
  42648. * Get the current error code of the webGL context
  42649. * @returns the error code
  42650. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42651. */
  42652. getError(): number;
  42653. /** @hidden */
  42654. _getUnpackAlignement(): number;
  42655. /** @hidden */
  42656. _unpackFlipY(value: boolean): void;
  42657. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42658. /**
  42659. * Updates a dynamic vertex buffer.
  42660. * @param vertexBuffer the vertex buffer to update
  42661. * @param data the data used to update the vertex buffer
  42662. * @param byteOffset the byte offset of the data (optional)
  42663. * @param byteLength the byte length of the data (optional)
  42664. */
  42665. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42666. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42667. /** @hidden */
  42668. _bindTexture(channel: number, texture: InternalTexture): void;
  42669. /** @hidden */
  42670. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42671. releaseEffects(): void;
  42672. displayLoadingUI(): void;
  42673. hideLoadingUI(): void;
  42674. /** @hidden */
  42675. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42676. /** @hidden */
  42677. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42678. /** @hidden */
  42679. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42680. /** @hidden */
  42681. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42682. }
  42683. }
  42684. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42685. import { Nullable, int } from "babylonjs/types";
  42686. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42687. /** @hidden */
  42688. export class _OcclusionDataStorage {
  42689. /** @hidden */
  42690. occlusionInternalRetryCounter: number;
  42691. /** @hidden */
  42692. isOcclusionQueryInProgress: boolean;
  42693. /** @hidden */
  42694. isOccluded: boolean;
  42695. /** @hidden */
  42696. occlusionRetryCount: number;
  42697. /** @hidden */
  42698. occlusionType: number;
  42699. /** @hidden */
  42700. occlusionQueryAlgorithmType: number;
  42701. }
  42702. module "babylonjs/Engines/engine" {
  42703. interface Engine {
  42704. /**
  42705. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42706. * @return the new query
  42707. */
  42708. createQuery(): WebGLQuery;
  42709. /**
  42710. * Delete and release a webGL query
  42711. * @param query defines the query to delete
  42712. * @return the current engine
  42713. */
  42714. deleteQuery(query: WebGLQuery): Engine;
  42715. /**
  42716. * Check if a given query has resolved and got its value
  42717. * @param query defines the query to check
  42718. * @returns true if the query got its value
  42719. */
  42720. isQueryResultAvailable(query: WebGLQuery): boolean;
  42721. /**
  42722. * Gets the value of a given query
  42723. * @param query defines the query to check
  42724. * @returns the value of the query
  42725. */
  42726. getQueryResult(query: WebGLQuery): number;
  42727. /**
  42728. * Initiates an occlusion query
  42729. * @param algorithmType defines the algorithm to use
  42730. * @param query defines the query to use
  42731. * @returns the current engine
  42732. * @see http://doc.babylonjs.com/features/occlusionquery
  42733. */
  42734. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42735. /**
  42736. * Ends an occlusion query
  42737. * @see http://doc.babylonjs.com/features/occlusionquery
  42738. * @param algorithmType defines the algorithm to use
  42739. * @returns the current engine
  42740. */
  42741. endOcclusionQuery(algorithmType: number): Engine;
  42742. /**
  42743. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42744. * Please note that only one query can be issued at a time
  42745. * @returns a time token used to track the time span
  42746. */
  42747. startTimeQuery(): Nullable<_TimeToken>;
  42748. /**
  42749. * Ends a time query
  42750. * @param token defines the token used to measure the time span
  42751. * @returns the time spent (in ns)
  42752. */
  42753. endTimeQuery(token: _TimeToken): int;
  42754. /** @hidden */
  42755. _currentNonTimestampToken: Nullable<_TimeToken>;
  42756. /** @hidden */
  42757. _createTimeQuery(): WebGLQuery;
  42758. /** @hidden */
  42759. _deleteTimeQuery(query: WebGLQuery): void;
  42760. /** @hidden */
  42761. _getGlAlgorithmType(algorithmType: number): number;
  42762. /** @hidden */
  42763. _getTimeQueryResult(query: WebGLQuery): any;
  42764. /** @hidden */
  42765. _getTimeQueryAvailability(query: WebGLQuery): any;
  42766. }
  42767. }
  42768. module "babylonjs/Meshes/abstractMesh" {
  42769. interface AbstractMesh {
  42770. /**
  42771. * Backing filed
  42772. * @hidden
  42773. */
  42774. __occlusionDataStorage: _OcclusionDataStorage;
  42775. /**
  42776. * Access property
  42777. * @hidden
  42778. */
  42779. _occlusionDataStorage: _OcclusionDataStorage;
  42780. /**
  42781. * 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.
  42782. * The default value is -1 which means don't break the query and wait till the result
  42783. * @see http://doc.babylonjs.com/features/occlusionquery
  42784. */
  42785. occlusionRetryCount: number;
  42786. /**
  42787. * 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:
  42788. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42789. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42790. * * 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.
  42791. * @see http://doc.babylonjs.com/features/occlusionquery
  42792. */
  42793. occlusionType: number;
  42794. /**
  42795. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42796. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42797. * * 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.
  42798. * @see http://doc.babylonjs.com/features/occlusionquery
  42799. */
  42800. occlusionQueryAlgorithmType: number;
  42801. /**
  42802. * 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
  42803. * @see http://doc.babylonjs.com/features/occlusionquery
  42804. */
  42805. isOccluded: boolean;
  42806. /**
  42807. * Flag to check the progress status of the query
  42808. * @see http://doc.babylonjs.com/features/occlusionquery
  42809. */
  42810. isOcclusionQueryInProgress: boolean;
  42811. }
  42812. }
  42813. }
  42814. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42815. import { Nullable } from "babylonjs/types";
  42816. /** @hidden */
  42817. export var _forceTransformFeedbackToBundle: boolean;
  42818. module "babylonjs/Engines/engine" {
  42819. interface Engine {
  42820. /**
  42821. * Creates a webGL transform feedback object
  42822. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42823. * @returns the webGL transform feedback object
  42824. */
  42825. createTransformFeedback(): WebGLTransformFeedback;
  42826. /**
  42827. * Delete a webGL transform feedback object
  42828. * @param value defines the webGL transform feedback object to delete
  42829. */
  42830. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42831. /**
  42832. * Bind a webGL transform feedback object to the webgl context
  42833. * @param value defines the webGL transform feedback object to bind
  42834. */
  42835. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42836. /**
  42837. * Begins a transform feedback operation
  42838. * @param usePoints defines if points or triangles must be used
  42839. */
  42840. beginTransformFeedback(usePoints: boolean): void;
  42841. /**
  42842. * Ends a transform feedback operation
  42843. */
  42844. endTransformFeedback(): void;
  42845. /**
  42846. * Specify the varyings to use with transform feedback
  42847. * @param program defines the associated webGL program
  42848. * @param value defines the list of strings representing the varying names
  42849. */
  42850. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42851. /**
  42852. * Bind a webGL buffer for a transform feedback operation
  42853. * @param value defines the webGL buffer to bind
  42854. */
  42855. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42856. }
  42857. }
  42858. }
  42859. declare module "babylonjs/Engines/Extensions/index" {
  42860. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42861. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42862. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42863. }
  42864. declare module "babylonjs/Engines/index" {
  42865. export * from "babylonjs/Engines/constants";
  42866. export * from "babylonjs/Engines/engine";
  42867. export * from "babylonjs/Engines/engineStore";
  42868. export * from "babylonjs/Engines/nullEngine";
  42869. export * from "babylonjs/Engines/Extensions/index";
  42870. }
  42871. declare module "babylonjs/Events/clipboardEvents" {
  42872. /**
  42873. * Gather the list of clipboard event types as constants.
  42874. */
  42875. export class ClipboardEventTypes {
  42876. /**
  42877. * The clipboard event is fired when a copy command is active (pressed).
  42878. */
  42879. static readonly COPY: number;
  42880. /**
  42881. * The clipboard event is fired when a cut command is active (pressed).
  42882. */
  42883. static readonly CUT: number;
  42884. /**
  42885. * The clipboard event is fired when a paste command is active (pressed).
  42886. */
  42887. static readonly PASTE: number;
  42888. }
  42889. /**
  42890. * This class is used to store clipboard related info for the onClipboardObservable event.
  42891. */
  42892. export class ClipboardInfo {
  42893. /**
  42894. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42895. */
  42896. type: number;
  42897. /**
  42898. * Defines the related dom event
  42899. */
  42900. event: ClipboardEvent;
  42901. /**
  42902. *Creates an instance of ClipboardInfo.
  42903. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42904. * @param event Defines the related dom event
  42905. */
  42906. constructor(
  42907. /**
  42908. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42909. */
  42910. type: number,
  42911. /**
  42912. * Defines the related dom event
  42913. */
  42914. event: ClipboardEvent);
  42915. /**
  42916. * Get the clipboard event's type from the keycode.
  42917. * @param keyCode Defines the keyCode for the current keyboard event.
  42918. * @return {number}
  42919. */
  42920. static GetTypeFromCharacter(keyCode: number): number;
  42921. }
  42922. }
  42923. declare module "babylonjs/Events/index" {
  42924. export * from "babylonjs/Events/keyboardEvents";
  42925. export * from "babylonjs/Events/pointerEvents";
  42926. export * from "babylonjs/Events/clipboardEvents";
  42927. }
  42928. declare module "babylonjs/Loading/sceneLoader" {
  42929. import { Observable } from "babylonjs/Misc/observable";
  42930. import { Nullable } from "babylonjs/types";
  42931. import { Scene } from "babylonjs/scene";
  42932. import { Engine } from "babylonjs/Engines/engine";
  42933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42934. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42935. import { AssetContainer } from "babylonjs/assetContainer";
  42936. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42937. import { Skeleton } from "babylonjs/Bones/skeleton";
  42938. /**
  42939. * Class used to represent data loading progression
  42940. */
  42941. export class SceneLoaderProgressEvent {
  42942. /** defines if data length to load can be evaluated */
  42943. readonly lengthComputable: boolean;
  42944. /** defines the loaded data length */
  42945. readonly loaded: number;
  42946. /** defines the data length to load */
  42947. readonly total: number;
  42948. /**
  42949. * Create a new progress event
  42950. * @param lengthComputable defines if data length to load can be evaluated
  42951. * @param loaded defines the loaded data length
  42952. * @param total defines the data length to load
  42953. */
  42954. constructor(
  42955. /** defines if data length to load can be evaluated */
  42956. lengthComputable: boolean,
  42957. /** defines the loaded data length */
  42958. loaded: number,
  42959. /** defines the data length to load */
  42960. total: number);
  42961. /**
  42962. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42963. * @param event defines the source event
  42964. * @returns a new SceneLoaderProgressEvent
  42965. */
  42966. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42967. }
  42968. /**
  42969. * Interface used by SceneLoader plugins to define supported file extensions
  42970. */
  42971. export interface ISceneLoaderPluginExtensions {
  42972. /**
  42973. * Defines the list of supported extensions
  42974. */
  42975. [extension: string]: {
  42976. isBinary: boolean;
  42977. };
  42978. }
  42979. /**
  42980. * Interface used by SceneLoader plugin factory
  42981. */
  42982. export interface ISceneLoaderPluginFactory {
  42983. /**
  42984. * Defines the name of the factory
  42985. */
  42986. name: string;
  42987. /**
  42988. * Function called to create a new plugin
  42989. * @return the new plugin
  42990. */
  42991. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42992. /**
  42993. * Boolean indicating if the plugin can direct load specific data
  42994. */
  42995. canDirectLoad?: (data: string) => boolean;
  42996. }
  42997. /**
  42998. * Interface used to define a SceneLoader plugin
  42999. */
  43000. export interface ISceneLoaderPlugin {
  43001. /**
  43002. * The friendly name of this plugin.
  43003. */
  43004. name: string;
  43005. /**
  43006. * The file extensions supported by this plugin.
  43007. */
  43008. extensions: string | ISceneLoaderPluginExtensions;
  43009. /**
  43010. * Import meshes into a scene.
  43011. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43012. * @param scene The scene to import into
  43013. * @param data The data to import
  43014. * @param rootUrl The root url for scene and resources
  43015. * @param meshes The meshes array to import into
  43016. * @param particleSystems The particle systems array to import into
  43017. * @param skeletons The skeletons array to import into
  43018. * @param onError The callback when import fails
  43019. * @returns True if successful or false otherwise
  43020. */
  43021. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43022. /**
  43023. * Load into a scene.
  43024. * @param scene The scene to load into
  43025. * @param data The data to import
  43026. * @param rootUrl The root url for scene and resources
  43027. * @param onError The callback when import fails
  43028. * @returns true if successful or false otherwise
  43029. */
  43030. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43031. /**
  43032. * The callback that returns true if the data can be directly loaded.
  43033. */
  43034. canDirectLoad?: (data: string) => boolean;
  43035. /**
  43036. * The callback that allows custom handling of the root url based on the response url.
  43037. */
  43038. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43039. /**
  43040. * Load into an asset container.
  43041. * @param scene The scene to load into
  43042. * @param data The data to import
  43043. * @param rootUrl The root url for scene and resources
  43044. * @param onError The callback when import fails
  43045. * @returns The loaded asset container
  43046. */
  43047. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43048. }
  43049. /**
  43050. * Interface used to define an async SceneLoader plugin
  43051. */
  43052. export interface ISceneLoaderPluginAsync {
  43053. /**
  43054. * The friendly name of this plugin.
  43055. */
  43056. name: string;
  43057. /**
  43058. * The file extensions supported by this plugin.
  43059. */
  43060. extensions: string | ISceneLoaderPluginExtensions;
  43061. /**
  43062. * Import meshes into a scene.
  43063. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43064. * @param scene The scene to import into
  43065. * @param data The data to import
  43066. * @param rootUrl The root url for scene and resources
  43067. * @param onProgress The callback when the load progresses
  43068. * @param fileName Defines the name of the file to load
  43069. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43070. */
  43071. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43072. meshes: AbstractMesh[];
  43073. particleSystems: IParticleSystem[];
  43074. skeletons: Skeleton[];
  43075. animationGroups: AnimationGroup[];
  43076. }>;
  43077. /**
  43078. * Load into a scene.
  43079. * @param scene The scene to load into
  43080. * @param data The data to import
  43081. * @param rootUrl The root url for scene and resources
  43082. * @param onProgress The callback when the load progresses
  43083. * @param fileName Defines the name of the file to load
  43084. * @returns Nothing
  43085. */
  43086. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43087. /**
  43088. * The callback that returns true if the data can be directly loaded.
  43089. */
  43090. canDirectLoad?: (data: string) => boolean;
  43091. /**
  43092. * The callback that allows custom handling of the root url based on the response url.
  43093. */
  43094. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43095. /**
  43096. * Load into an asset container.
  43097. * @param scene The scene to load into
  43098. * @param data The data to import
  43099. * @param rootUrl The root url for scene and resources
  43100. * @param onProgress The callback when the load progresses
  43101. * @param fileName Defines the name of the file to load
  43102. * @returns The loaded asset container
  43103. */
  43104. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43105. }
  43106. /**
  43107. * Class used to load scene from various file formats using registered plugins
  43108. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43109. */
  43110. export class SceneLoader {
  43111. /**
  43112. * No logging while loading
  43113. */
  43114. static readonly NO_LOGGING: number;
  43115. /**
  43116. * Minimal logging while loading
  43117. */
  43118. static readonly MINIMAL_LOGGING: number;
  43119. /**
  43120. * Summary logging while loading
  43121. */
  43122. static readonly SUMMARY_LOGGING: number;
  43123. /**
  43124. * Detailled logging while loading
  43125. */
  43126. static readonly DETAILED_LOGGING: number;
  43127. /**
  43128. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43129. */
  43130. static ForceFullSceneLoadingForIncremental: boolean;
  43131. /**
  43132. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43133. */
  43134. static ShowLoadingScreen: boolean;
  43135. /**
  43136. * Defines the current logging level (while loading the scene)
  43137. * @ignorenaming
  43138. */
  43139. static loggingLevel: number;
  43140. /**
  43141. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43142. */
  43143. static CleanBoneMatrixWeights: boolean;
  43144. /**
  43145. * Event raised when a plugin is used to load a scene
  43146. */
  43147. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43148. private static _registeredPlugins;
  43149. private static _getDefaultPlugin;
  43150. private static _getPluginForExtension;
  43151. private static _getPluginForDirectLoad;
  43152. private static _getPluginForFilename;
  43153. private static _getDirectLoad;
  43154. private static _loadData;
  43155. private static _getFileInfo;
  43156. /**
  43157. * Gets a plugin that can load the given extension
  43158. * @param extension defines the extension to load
  43159. * @returns a plugin or null if none works
  43160. */
  43161. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43162. /**
  43163. * Gets a boolean indicating that the given extension can be loaded
  43164. * @param extension defines the extension to load
  43165. * @returns true if the extension is supported
  43166. */
  43167. static IsPluginForExtensionAvailable(extension: string): boolean;
  43168. /**
  43169. * Adds a new plugin to the list of registered plugins
  43170. * @param plugin defines the plugin to add
  43171. */
  43172. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43173. /**
  43174. * Import meshes into a scene
  43175. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43176. * @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)
  43177. * @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)
  43178. * @param scene the instance of BABYLON.Scene to append to
  43179. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43180. * @param onProgress a callback with a progress event for each file being loaded
  43181. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43182. * @param pluginExtension the extension used to determine the plugin
  43183. * @returns The loaded plugin
  43184. */
  43185. 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>;
  43186. /**
  43187. * Import meshes into a scene
  43188. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43189. * @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)
  43190. * @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)
  43191. * @param scene the instance of BABYLON.Scene to append to
  43192. * @param onProgress a callback with a progress event for each file being loaded
  43193. * @param pluginExtension the extension used to determine the plugin
  43194. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43195. */
  43196. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43197. meshes: AbstractMesh[];
  43198. particleSystems: IParticleSystem[];
  43199. skeletons: Skeleton[];
  43200. animationGroups: AnimationGroup[];
  43201. }>;
  43202. /**
  43203. * Load a scene
  43204. * @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)
  43205. * @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)
  43206. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43207. * @param onSuccess a callback with the scene when import succeeds
  43208. * @param onProgress a callback with a progress event for each file being loaded
  43209. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43210. * @param pluginExtension the extension used to determine the plugin
  43211. * @returns The loaded plugin
  43212. */
  43213. 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>;
  43214. /**
  43215. * Load a scene
  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 engine is the instance of BABYLON.Engine to use to create the scene
  43219. * @param onProgress a callback with a progress event for each file being loaded
  43220. * @param pluginExtension the extension used to determine the plugin
  43221. * @returns The loaded scene
  43222. */
  43223. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43224. /**
  43225. * Append a scene
  43226. * @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)
  43227. * @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)
  43228. * @param scene is the instance of BABYLON.Scene to append to
  43229. * @param onSuccess a callback with the scene when import succeeds
  43230. * @param onProgress a callback with a progress event for each file being loaded
  43231. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43232. * @param pluginExtension the extension used to determine the plugin
  43233. * @returns The loaded plugin
  43234. */
  43235. 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>;
  43236. /**
  43237. * Append a scene
  43238. * @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)
  43239. * @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)
  43240. * @param scene is the instance of BABYLON.Scene to append to
  43241. * @param onProgress a callback with a progress event for each file being loaded
  43242. * @param pluginExtension the extension used to determine the plugin
  43243. * @returns The given scene
  43244. */
  43245. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43246. /**
  43247. * Load a scene into an asset container
  43248. * @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)
  43249. * @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)
  43250. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43251. * @param onSuccess a callback with the scene when import succeeds
  43252. * @param onProgress a callback with a progress event for each file being loaded
  43253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43254. * @param pluginExtension the extension used to determine the plugin
  43255. * @returns The loaded plugin
  43256. */
  43257. 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>;
  43258. /**
  43259. * Load a scene into an asset container
  43260. * @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)
  43261. * @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)
  43262. * @param scene is the instance of Scene to append to
  43263. * @param onProgress a callback with a progress event for each file being loaded
  43264. * @param pluginExtension the extension used to determine the plugin
  43265. * @returns The loaded asset container
  43266. */
  43267. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43268. }
  43269. }
  43270. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43271. import { Scene } from "babylonjs/scene";
  43272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43273. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43274. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43275. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43276. /**
  43277. * Google Daydream controller
  43278. */
  43279. export class DaydreamController extends WebVRController {
  43280. /**
  43281. * Base Url for the controller model.
  43282. */
  43283. static MODEL_BASE_URL: string;
  43284. /**
  43285. * File name for the controller model.
  43286. */
  43287. static MODEL_FILENAME: string;
  43288. /**
  43289. * Gamepad Id prefix used to identify Daydream Controller.
  43290. */
  43291. static readonly GAMEPAD_ID_PREFIX: string;
  43292. /**
  43293. * Creates a new DaydreamController from a gamepad
  43294. * @param vrGamepad the gamepad that the controller should be created from
  43295. */
  43296. constructor(vrGamepad: any);
  43297. /**
  43298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43299. * @param scene scene in which to add meshes
  43300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43301. */
  43302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43303. /**
  43304. * Called once for each button that changed state since the last frame
  43305. * @param buttonIdx Which button index changed
  43306. * @param state New state of the button
  43307. * @param changes Which properties on the state changed since last frame
  43308. */
  43309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43310. }
  43311. }
  43312. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43313. import { Scene } from "babylonjs/scene";
  43314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43315. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43316. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43317. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43318. /**
  43319. * Gear VR Controller
  43320. */
  43321. export class GearVRController extends WebVRController {
  43322. /**
  43323. * Base Url for the controller model.
  43324. */
  43325. static MODEL_BASE_URL: string;
  43326. /**
  43327. * File name for the controller model.
  43328. */
  43329. static MODEL_FILENAME: string;
  43330. /**
  43331. * Gamepad Id prefix used to identify this controller.
  43332. */
  43333. static readonly GAMEPAD_ID_PREFIX: string;
  43334. private readonly _buttonIndexToObservableNameMap;
  43335. /**
  43336. * Creates a new GearVRController from a gamepad
  43337. * @param vrGamepad the gamepad that the controller should be created from
  43338. */
  43339. constructor(vrGamepad: any);
  43340. /**
  43341. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43342. * @param scene scene in which to add meshes
  43343. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43344. */
  43345. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43346. /**
  43347. * Called once for each button that changed state since the last frame
  43348. * @param buttonIdx Which button index changed
  43349. * @param state New state of the button
  43350. * @param changes Which properties on the state changed since last frame
  43351. */
  43352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43353. }
  43354. }
  43355. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43359. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43360. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43361. /**
  43362. * Generic Controller
  43363. */
  43364. export class GenericController extends WebVRController {
  43365. /**
  43366. * Base Url for the controller model.
  43367. */
  43368. static readonly MODEL_BASE_URL: string;
  43369. /**
  43370. * File name for the controller model.
  43371. */
  43372. static readonly MODEL_FILENAME: string;
  43373. /**
  43374. * Creates a new GenericController from a gamepad
  43375. * @param vrGamepad the gamepad that the controller should be created from
  43376. */
  43377. constructor(vrGamepad: any);
  43378. /**
  43379. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43380. * @param scene scene in which to add meshes
  43381. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43382. */
  43383. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43384. /**
  43385. * Called once for each button that changed state since the last frame
  43386. * @param buttonIdx Which button index changed
  43387. * @param state New state of the button
  43388. * @param changes Which properties on the state changed since last frame
  43389. */
  43390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43391. }
  43392. }
  43393. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43394. import { Observable } from "babylonjs/Misc/observable";
  43395. import { Scene } from "babylonjs/scene";
  43396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43397. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43398. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43399. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43400. /**
  43401. * Oculus Touch Controller
  43402. */
  43403. export class OculusTouchController extends WebVRController {
  43404. /**
  43405. * Base Url for the controller model.
  43406. */
  43407. static MODEL_BASE_URL: string;
  43408. /**
  43409. * File name for the left controller model.
  43410. */
  43411. static MODEL_LEFT_FILENAME: string;
  43412. /**
  43413. * File name for the right controller model.
  43414. */
  43415. static MODEL_RIGHT_FILENAME: string;
  43416. /**
  43417. * Fired when the secondary trigger on this controller is modified
  43418. */
  43419. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43420. /**
  43421. * Fired when the thumb rest on this controller is modified
  43422. */
  43423. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43424. /**
  43425. * Creates a new OculusTouchController from a gamepad
  43426. * @param vrGamepad the gamepad that the controller should be created from
  43427. */
  43428. constructor(vrGamepad: any);
  43429. /**
  43430. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43431. * @param scene scene in which to add meshes
  43432. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43433. */
  43434. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43435. /**
  43436. * Fired when the A button on this controller is modified
  43437. */
  43438. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43439. /**
  43440. * Fired when the B button on this controller is modified
  43441. */
  43442. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43443. /**
  43444. * Fired when the X button on this controller is modified
  43445. */
  43446. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43447. /**
  43448. * Fired when the Y button on this controller is modified
  43449. */
  43450. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43451. /**
  43452. * Called once for each button that changed state since the last frame
  43453. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43454. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43455. * 2) secondary trigger (same)
  43456. * 3) A (right) X (left), touch, pressed = value
  43457. * 4) B / Y
  43458. * 5) thumb rest
  43459. * @param buttonIdx Which button index changed
  43460. * @param state New state of the button
  43461. * @param changes Which properties on the state changed since last frame
  43462. */
  43463. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43464. }
  43465. }
  43466. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43467. import { Scene } from "babylonjs/scene";
  43468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43469. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43470. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43471. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43472. import { Observable } from "babylonjs/Misc/observable";
  43473. /**
  43474. * Vive Controller
  43475. */
  43476. export class ViveController extends WebVRController {
  43477. /**
  43478. * Base Url for the controller model.
  43479. */
  43480. static MODEL_BASE_URL: string;
  43481. /**
  43482. * File name for the controller model.
  43483. */
  43484. static MODEL_FILENAME: string;
  43485. /**
  43486. * Creates a new ViveController from a gamepad
  43487. * @param vrGamepad the gamepad that the controller should be created from
  43488. */
  43489. constructor(vrGamepad: any);
  43490. /**
  43491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43492. * @param scene scene in which to add meshes
  43493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43494. */
  43495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43496. /**
  43497. * Fired when the left button on this controller is modified
  43498. */
  43499. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43500. /**
  43501. * Fired when the right button on this controller is modified
  43502. */
  43503. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43504. /**
  43505. * Fired when the menu button on this controller is modified
  43506. */
  43507. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43508. /**
  43509. * Called once for each button that changed state since the last frame
  43510. * Vive mapping:
  43511. * 0: touchpad
  43512. * 1: trigger
  43513. * 2: left AND right buttons
  43514. * 3: menu button
  43515. * @param buttonIdx Which button index changed
  43516. * @param state New state of the button
  43517. * @param changes Which properties on the state changed since last frame
  43518. */
  43519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43520. }
  43521. }
  43522. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43523. import { Observable } from "babylonjs/Misc/observable";
  43524. import { Scene } from "babylonjs/scene";
  43525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43526. import { Ray } from "babylonjs/Culling/ray";
  43527. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43528. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43529. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43530. /**
  43531. * Defines the WindowsMotionController object that the state of the windows motion controller
  43532. */
  43533. export class WindowsMotionController extends WebVRController {
  43534. /**
  43535. * The base url used to load the left and right controller models
  43536. */
  43537. static MODEL_BASE_URL: string;
  43538. /**
  43539. * The name of the left controller model file
  43540. */
  43541. static MODEL_LEFT_FILENAME: string;
  43542. /**
  43543. * The name of the right controller model file
  43544. */
  43545. static MODEL_RIGHT_FILENAME: string;
  43546. /**
  43547. * The controller name prefix for this controller type
  43548. */
  43549. static readonly GAMEPAD_ID_PREFIX: string;
  43550. /**
  43551. * The controller id pattern for this controller type
  43552. */
  43553. private static readonly GAMEPAD_ID_PATTERN;
  43554. private _loadedMeshInfo;
  43555. private readonly _mapping;
  43556. /**
  43557. * Fired when the trackpad on this controller is clicked
  43558. */
  43559. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43560. /**
  43561. * Fired when the trackpad on this controller is modified
  43562. */
  43563. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43564. /**
  43565. * The current x and y values of this controller's trackpad
  43566. */
  43567. trackpad: StickValues;
  43568. /**
  43569. * Creates a new WindowsMotionController from a gamepad
  43570. * @param vrGamepad the gamepad that the controller should be created from
  43571. */
  43572. constructor(vrGamepad: any);
  43573. /**
  43574. * Fired when the trigger on this controller is modified
  43575. */
  43576. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43577. /**
  43578. * Fired when the menu button on this controller is modified
  43579. */
  43580. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43581. /**
  43582. * Fired when the grip button on this controller is modified
  43583. */
  43584. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Fired when the thumbstick button on this controller is modified
  43587. */
  43588. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43589. /**
  43590. * Fired when the touchpad button on this controller is modified
  43591. */
  43592. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43593. /**
  43594. * Fired when the touchpad values on this controller are modified
  43595. */
  43596. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43597. private _updateTrackpad;
  43598. /**
  43599. * Called once per frame by the engine.
  43600. */
  43601. update(): void;
  43602. /**
  43603. * Called once for each button that changed state since the last frame
  43604. * @param buttonIdx Which button index changed
  43605. * @param state New state of the button
  43606. * @param changes Which properties on the state changed since last frame
  43607. */
  43608. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43609. /**
  43610. * Moves the buttons on the controller mesh based on their current state
  43611. * @param buttonName the name of the button to move
  43612. * @param buttonValue the value of the button which determines the buttons new position
  43613. */
  43614. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43615. /**
  43616. * Moves the axis on the controller mesh based on its current state
  43617. * @param axis the index of the axis
  43618. * @param axisValue the value of the axis which determines the meshes new position
  43619. * @hidden
  43620. */
  43621. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43622. /**
  43623. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43624. * @param scene scene in which to add meshes
  43625. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43626. */
  43627. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43628. /**
  43629. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43630. * can be transformed by button presses and axes values, based on this._mapping.
  43631. *
  43632. * @param scene scene in which the meshes exist
  43633. * @param meshes list of meshes that make up the controller model to process
  43634. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43635. */
  43636. private processModel;
  43637. private createMeshInfo;
  43638. /**
  43639. * Gets the ray of the controller in the direction the controller is pointing
  43640. * @param length the length the resulting ray should be
  43641. * @returns a ray in the direction the controller is pointing
  43642. */
  43643. getForwardRay(length?: number): Ray;
  43644. /**
  43645. * Disposes of the controller
  43646. */
  43647. dispose(): void;
  43648. }
  43649. }
  43650. declare module "babylonjs/Gamepads/Controllers/index" {
  43651. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43652. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43653. export * from "babylonjs/Gamepads/Controllers/genericController";
  43654. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43655. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43656. export * from "babylonjs/Gamepads/Controllers/viveController";
  43657. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43658. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43659. }
  43660. declare module "babylonjs/Gamepads/index" {
  43661. export * from "babylonjs/Gamepads/Controllers/index";
  43662. export * from "babylonjs/Gamepads/gamepad";
  43663. export * from "babylonjs/Gamepads/gamepadManager";
  43664. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43665. export * from "babylonjs/Gamepads/xboxGamepad";
  43666. }
  43667. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43668. import { Observable } from "babylonjs/Misc/observable";
  43669. import { Nullable } from "babylonjs/types";
  43670. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43672. import { Mesh } from "babylonjs/Meshes/mesh";
  43673. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43674. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43675. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43676. /**
  43677. * Single axis scale gizmo
  43678. */
  43679. export class AxisScaleGizmo extends Gizmo {
  43680. private _coloredMaterial;
  43681. /**
  43682. * Drag behavior responsible for the gizmos dragging interactions
  43683. */
  43684. dragBehavior: PointerDragBehavior;
  43685. private _pointerObserver;
  43686. /**
  43687. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43688. */
  43689. snapDistance: number;
  43690. /**
  43691. * Event that fires each time the gizmo snaps to a new location.
  43692. * * snapDistance is the the change in distance
  43693. */
  43694. onSnapObservable: Observable<{
  43695. snapDistance: number;
  43696. }>;
  43697. /**
  43698. * If the scaling operation should be done on all axis (default: false)
  43699. */
  43700. uniformScaling: boolean;
  43701. /**
  43702. * Creates an AxisScaleGizmo
  43703. * @param gizmoLayer The utility layer the gizmo will be added to
  43704. * @param dragAxis The axis which the gizmo will be able to scale on
  43705. * @param color The color of the gizmo
  43706. */
  43707. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43709. /**
  43710. * Disposes of the gizmo
  43711. */
  43712. dispose(): void;
  43713. /**
  43714. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43715. * @param mesh The mesh to replace the default mesh of the gizmo
  43716. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43717. */
  43718. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43719. }
  43720. }
  43721. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43722. import { Observable } from "babylonjs/Misc/observable";
  43723. import { Nullable } from "babylonjs/types";
  43724. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43726. import { Mesh } from "babylonjs/Meshes/mesh";
  43727. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43728. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43729. import "babylonjs/Meshes/Builders/boxBuilder";
  43730. /**
  43731. * Bounding box gizmo
  43732. */
  43733. export class BoundingBoxGizmo extends Gizmo {
  43734. private _lineBoundingBox;
  43735. private _rotateSpheresParent;
  43736. private _scaleBoxesParent;
  43737. private _boundingDimensions;
  43738. private _renderObserver;
  43739. private _pointerObserver;
  43740. private _scaleDragSpeed;
  43741. private _tmpQuaternion;
  43742. private _tmpVector;
  43743. private _tmpRotationMatrix;
  43744. /**
  43745. * 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)
  43746. */
  43747. ignoreChildren: boolean;
  43748. /**
  43749. * 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)
  43750. */
  43751. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43752. /**
  43753. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43754. */
  43755. rotationSphereSize: number;
  43756. /**
  43757. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43758. */
  43759. scaleBoxSize: number;
  43760. /**
  43761. * 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)
  43762. */
  43763. fixedDragMeshScreenSize: boolean;
  43764. /**
  43765. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43766. */
  43767. fixedDragMeshScreenSizeDistanceFactor: number;
  43768. /**
  43769. * Fired when a rotation sphere or scale box is dragged
  43770. */
  43771. onDragStartObservable: Observable<{}>;
  43772. /**
  43773. * Fired when a scale box is dragged
  43774. */
  43775. onScaleBoxDragObservable: Observable<{}>;
  43776. /**
  43777. * Fired when a scale box drag is ended
  43778. */
  43779. onScaleBoxDragEndObservable: Observable<{}>;
  43780. /**
  43781. * Fired when a rotation sphere is dragged
  43782. */
  43783. onRotationSphereDragObservable: Observable<{}>;
  43784. /**
  43785. * Fired when a rotation sphere drag is ended
  43786. */
  43787. onRotationSphereDragEndObservable: Observable<{}>;
  43788. /**
  43789. * 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)
  43790. */
  43791. scalePivot: Nullable<Vector3>;
  43792. private _anchorMesh;
  43793. private _existingMeshScale;
  43794. private _dragMesh;
  43795. private pointerDragBehavior;
  43796. private coloredMaterial;
  43797. private hoverColoredMaterial;
  43798. /**
  43799. * Sets the color of the bounding box gizmo
  43800. * @param color the color to set
  43801. */
  43802. setColor(color: Color3): void;
  43803. /**
  43804. * Creates an BoundingBoxGizmo
  43805. * @param gizmoLayer The utility layer the gizmo will be added to
  43806. * @param color The color of the gizmo
  43807. */
  43808. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43810. private _selectNode;
  43811. /**
  43812. * Updates the bounding box information for the Gizmo
  43813. */
  43814. updateBoundingBox(): void;
  43815. private _updateRotationSpheres;
  43816. private _updateScaleBoxes;
  43817. /**
  43818. * Enables rotation on the specified axis and disables rotation on the others
  43819. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43820. */
  43821. setEnabledRotationAxis(axis: string): void;
  43822. /**
  43823. * Enables/disables scaling
  43824. * @param enable if scaling should be enabled
  43825. */
  43826. setEnabledScaling(enable: boolean): void;
  43827. private _updateDummy;
  43828. /**
  43829. * Enables a pointer drag behavior on the bounding box of the gizmo
  43830. */
  43831. enableDragBehavior(): void;
  43832. /**
  43833. * Disposes of the gizmo
  43834. */
  43835. dispose(): void;
  43836. /**
  43837. * 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)
  43838. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43839. * @returns the bounding box mesh with the passed in mesh as a child
  43840. */
  43841. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43842. /**
  43843. * CustomMeshes are not supported by this gizmo
  43844. * @param mesh The mesh to replace the default mesh of the gizmo
  43845. */
  43846. setCustomMesh(mesh: Mesh): void;
  43847. }
  43848. }
  43849. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43850. import { Observable } from "babylonjs/Misc/observable";
  43851. import { Nullable } from "babylonjs/types";
  43852. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43854. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43855. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43856. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43857. import "babylonjs/Meshes/Builders/linesBuilder";
  43858. /**
  43859. * Single plane rotation gizmo
  43860. */
  43861. export class PlaneRotationGizmo extends Gizmo {
  43862. /**
  43863. * Drag behavior responsible for the gizmos dragging interactions
  43864. */
  43865. dragBehavior: PointerDragBehavior;
  43866. private _pointerObserver;
  43867. /**
  43868. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43869. */
  43870. snapDistance: number;
  43871. /**
  43872. * Event that fires each time the gizmo snaps to a new location.
  43873. * * snapDistance is the the change in distance
  43874. */
  43875. onSnapObservable: Observable<{
  43876. snapDistance: number;
  43877. }>;
  43878. /**
  43879. * Creates a PlaneRotationGizmo
  43880. * @param gizmoLayer The utility layer the gizmo will be added to
  43881. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43882. * @param color The color of the gizmo
  43883. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43884. */
  43885. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43887. /**
  43888. * Disposes of the gizmo
  43889. */
  43890. dispose(): void;
  43891. }
  43892. }
  43893. declare module "babylonjs/Gizmos/rotationGizmo" {
  43894. import { Observable } from "babylonjs/Misc/observable";
  43895. import { Nullable } from "babylonjs/types";
  43896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43897. import { Mesh } from "babylonjs/Meshes/mesh";
  43898. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43899. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43901. /**
  43902. * Gizmo that enables rotating a mesh along 3 axis
  43903. */
  43904. export class RotationGizmo extends Gizmo {
  43905. /**
  43906. * Internal gizmo used for interactions on the x axis
  43907. */
  43908. xGizmo: PlaneRotationGizmo;
  43909. /**
  43910. * Internal gizmo used for interactions on the y axis
  43911. */
  43912. yGizmo: PlaneRotationGizmo;
  43913. /**
  43914. * Internal gizmo used for interactions on the z axis
  43915. */
  43916. zGizmo: PlaneRotationGizmo;
  43917. /** Fires an event when any of it's sub gizmos are dragged */
  43918. onDragStartObservable: Observable<{}>;
  43919. /** Fires an event when any of it's sub gizmos are released from dragging */
  43920. onDragEndObservable: Observable<{}>;
  43921. attachedMesh: Nullable<AbstractMesh>;
  43922. /**
  43923. * Creates a RotationGizmo
  43924. * @param gizmoLayer The utility layer the gizmo will be added to
  43925. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43926. */
  43927. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43928. updateGizmoRotationToMatchAttachedMesh: boolean;
  43929. /**
  43930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43931. */
  43932. snapDistance: number;
  43933. /**
  43934. * Ratio for the scale of the gizmo (Default: 1)
  43935. */
  43936. scaleRatio: number;
  43937. /**
  43938. * Disposes of the gizmo
  43939. */
  43940. dispose(): void;
  43941. /**
  43942. * CustomMeshes are not supported by this gizmo
  43943. * @param mesh The mesh to replace the default mesh of the gizmo
  43944. */
  43945. setCustomMesh(mesh: Mesh): void;
  43946. }
  43947. }
  43948. declare module "babylonjs/Gizmos/positionGizmo" {
  43949. import { Observable } from "babylonjs/Misc/observable";
  43950. import { Nullable } from "babylonjs/types";
  43951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43952. import { Mesh } from "babylonjs/Meshes/mesh";
  43953. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43954. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43955. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43956. /**
  43957. * Gizmo that enables dragging a mesh along 3 axis
  43958. */
  43959. export class PositionGizmo extends Gizmo {
  43960. /**
  43961. * Internal gizmo used for interactions on the x axis
  43962. */
  43963. xGizmo: AxisDragGizmo;
  43964. /**
  43965. * Internal gizmo used for interactions on the y axis
  43966. */
  43967. yGizmo: AxisDragGizmo;
  43968. /**
  43969. * Internal gizmo used for interactions on the z axis
  43970. */
  43971. zGizmo: AxisDragGizmo;
  43972. /** Fires an event when any of it's sub gizmos are dragged */
  43973. onDragStartObservable: Observable<{}>;
  43974. /** Fires an event when any of it's sub gizmos are released from dragging */
  43975. onDragEndObservable: Observable<{}>;
  43976. attachedMesh: Nullable<AbstractMesh>;
  43977. /**
  43978. * Creates a PositionGizmo
  43979. * @param gizmoLayer The utility layer the gizmo will be added to
  43980. */
  43981. constructor(gizmoLayer?: UtilityLayerRenderer);
  43982. updateGizmoRotationToMatchAttachedMesh: boolean;
  43983. /**
  43984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43985. */
  43986. snapDistance: number;
  43987. /**
  43988. * Ratio for the scale of the gizmo (Default: 1)
  43989. */
  43990. scaleRatio: number;
  43991. /**
  43992. * Disposes of the gizmo
  43993. */
  43994. dispose(): void;
  43995. /**
  43996. * CustomMeshes are not supported by this gizmo
  43997. * @param mesh The mesh to replace the default mesh of the gizmo
  43998. */
  43999. setCustomMesh(mesh: Mesh): void;
  44000. }
  44001. }
  44002. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44003. import { Scene } from "babylonjs/scene";
  44004. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44005. import { Mesh } from "babylonjs/Meshes/mesh";
  44006. import { Nullable } from "babylonjs/types";
  44007. /**
  44008. * Class containing static functions to help procedurally build meshes
  44009. */
  44010. export class PolyhedronBuilder {
  44011. /**
  44012. * Creates a polyhedron mesh
  44013. * * 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
  44014. * * The parameter `size` (positive float, default 1) sets the polygon size
  44015. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44016. * * 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`
  44017. * * 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
  44018. * * 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)`)
  44019. * * 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
  44020. * * 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
  44021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44024. * @param name defines the name of the mesh
  44025. * @param options defines the options used to create the mesh
  44026. * @param scene defines the hosting scene
  44027. * @returns the polyhedron mesh
  44028. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44029. */
  44030. static CreatePolyhedron(name: string, options: {
  44031. type?: number;
  44032. size?: number;
  44033. sizeX?: number;
  44034. sizeY?: number;
  44035. sizeZ?: number;
  44036. custom?: any;
  44037. faceUV?: Vector4[];
  44038. faceColors?: Color4[];
  44039. flat?: boolean;
  44040. updatable?: boolean;
  44041. sideOrientation?: number;
  44042. frontUVs?: Vector4;
  44043. backUVs?: Vector4;
  44044. }, scene?: Nullable<Scene>): Mesh;
  44045. }
  44046. }
  44047. declare module "babylonjs/Gizmos/scaleGizmo" {
  44048. import { Observable } from "babylonjs/Misc/observable";
  44049. import { Nullable } from "babylonjs/types";
  44050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44051. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44052. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44053. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44054. /**
  44055. * Gizmo that enables scaling a mesh along 3 axis
  44056. */
  44057. export class ScaleGizmo extends Gizmo {
  44058. /**
  44059. * Internal gizmo used for interactions on the x axis
  44060. */
  44061. xGizmo: AxisScaleGizmo;
  44062. /**
  44063. * Internal gizmo used for interactions on the y axis
  44064. */
  44065. yGizmo: AxisScaleGizmo;
  44066. /**
  44067. * Internal gizmo used for interactions on the z axis
  44068. */
  44069. zGizmo: AxisScaleGizmo;
  44070. /**
  44071. * Internal gizmo used to scale all axis equally
  44072. */
  44073. uniformScaleGizmo: AxisScaleGizmo;
  44074. /** Fires an event when any of it's sub gizmos are dragged */
  44075. onDragStartObservable: Observable<{}>;
  44076. /** Fires an event when any of it's sub gizmos are released from dragging */
  44077. onDragEndObservable: Observable<{}>;
  44078. attachedMesh: Nullable<AbstractMesh>;
  44079. /**
  44080. * Creates a ScaleGizmo
  44081. * @param gizmoLayer The utility layer the gizmo will be added to
  44082. */
  44083. constructor(gizmoLayer?: UtilityLayerRenderer);
  44084. updateGizmoRotationToMatchAttachedMesh: boolean;
  44085. /**
  44086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44087. */
  44088. snapDistance: number;
  44089. /**
  44090. * Ratio for the scale of the gizmo (Default: 1)
  44091. */
  44092. scaleRatio: number;
  44093. /**
  44094. * Disposes of the gizmo
  44095. */
  44096. dispose(): void;
  44097. }
  44098. }
  44099. declare module "babylonjs/Gizmos/gizmoManager" {
  44100. import { Observable } from "babylonjs/Misc/observable";
  44101. import { Nullable } from "babylonjs/types";
  44102. import { Scene, IDisposable } from "babylonjs/scene";
  44103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44104. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44105. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44106. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44107. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44108. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44109. /**
  44110. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44111. */
  44112. export class GizmoManager implements IDisposable {
  44113. private scene;
  44114. /**
  44115. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44116. */
  44117. gizmos: {
  44118. positionGizmo: Nullable<PositionGizmo>;
  44119. rotationGizmo: Nullable<RotationGizmo>;
  44120. scaleGizmo: Nullable<ScaleGizmo>;
  44121. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44122. };
  44123. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44124. clearGizmoOnEmptyPointerEvent: boolean;
  44125. /** Fires an event when the manager is attached to a mesh */
  44126. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44127. private _gizmosEnabled;
  44128. private _pointerObserver;
  44129. private _attachedMesh;
  44130. private _boundingBoxColor;
  44131. private _defaultUtilityLayer;
  44132. private _defaultKeepDepthUtilityLayer;
  44133. /**
  44134. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44135. */
  44136. boundingBoxDragBehavior: SixDofDragBehavior;
  44137. /**
  44138. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44139. */
  44140. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44141. /**
  44142. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44143. */
  44144. usePointerToAttachGizmos: boolean;
  44145. /**
  44146. * Instatiates a gizmo manager
  44147. * @param scene the scene to overlay the gizmos on top of
  44148. */
  44149. constructor(scene: Scene);
  44150. /**
  44151. * Attaches a set of gizmos to the specified mesh
  44152. * @param mesh The mesh the gizmo's should be attached to
  44153. */
  44154. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44155. /**
  44156. * If the position gizmo is enabled
  44157. */
  44158. positionGizmoEnabled: boolean;
  44159. /**
  44160. * If the rotation gizmo is enabled
  44161. */
  44162. rotationGizmoEnabled: boolean;
  44163. /**
  44164. * If the scale gizmo is enabled
  44165. */
  44166. scaleGizmoEnabled: boolean;
  44167. /**
  44168. * If the boundingBox gizmo is enabled
  44169. */
  44170. boundingBoxGizmoEnabled: boolean;
  44171. /**
  44172. * Disposes of the gizmo manager
  44173. */
  44174. dispose(): void;
  44175. }
  44176. }
  44177. declare module "babylonjs/Lights/directionalLight" {
  44178. import { Camera } from "babylonjs/Cameras/camera";
  44179. import { Scene } from "babylonjs/scene";
  44180. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44182. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44183. import { Effect } from "babylonjs/Materials/effect";
  44184. /**
  44185. * A directional light is defined by a direction (what a surprise!).
  44186. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44187. * 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.
  44188. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44189. */
  44190. export class DirectionalLight extends ShadowLight {
  44191. private _shadowFrustumSize;
  44192. /**
  44193. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44194. */
  44195. /**
  44196. * Specifies a fix frustum size for the shadow generation.
  44197. */
  44198. shadowFrustumSize: number;
  44199. private _shadowOrthoScale;
  44200. /**
  44201. * Gets the shadow projection scale against the optimal computed one.
  44202. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44203. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44204. */
  44205. /**
  44206. * Sets the shadow projection scale against the optimal computed one.
  44207. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44208. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44209. */
  44210. shadowOrthoScale: number;
  44211. /**
  44212. * Automatically compute the projection matrix to best fit (including all the casters)
  44213. * on each frame.
  44214. */
  44215. autoUpdateExtends: boolean;
  44216. private _orthoLeft;
  44217. private _orthoRight;
  44218. private _orthoTop;
  44219. private _orthoBottom;
  44220. /**
  44221. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44222. * The directional light is emitted from everywhere in the given direction.
  44223. * It can cast shadows.
  44224. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44225. * @param name The friendly name of the light
  44226. * @param direction The direction of the light
  44227. * @param scene The scene the light belongs to
  44228. */
  44229. constructor(name: string, direction: Vector3, scene: Scene);
  44230. /**
  44231. * Returns the string "DirectionalLight".
  44232. * @return The class name
  44233. */
  44234. getClassName(): string;
  44235. /**
  44236. * Returns the integer 1.
  44237. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44238. */
  44239. getTypeID(): number;
  44240. /**
  44241. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44242. * Returns the DirectionalLight Shadow projection matrix.
  44243. */
  44244. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44245. /**
  44246. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44247. * Returns the DirectionalLight Shadow projection matrix.
  44248. */
  44249. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44250. /**
  44251. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44252. * Returns the DirectionalLight Shadow projection matrix.
  44253. */
  44254. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44255. protected _buildUniformLayout(): void;
  44256. /**
  44257. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44258. * @param effect The effect to update
  44259. * @param lightIndex The index of the light in the effect to update
  44260. * @returns The directional light
  44261. */
  44262. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44263. /**
  44264. * Gets the minZ used for shadow according to both the scene and the light.
  44265. *
  44266. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44267. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44268. * @param activeCamera The camera we are returning the min for
  44269. * @returns the depth min z
  44270. */
  44271. getDepthMinZ(activeCamera: Camera): number;
  44272. /**
  44273. * Gets the maxZ used for shadow according to both the scene and the light.
  44274. *
  44275. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44276. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44277. * @param activeCamera The camera we are returning the max for
  44278. * @returns the depth max z
  44279. */
  44280. getDepthMaxZ(activeCamera: Camera): number;
  44281. /**
  44282. * Prepares the list of defines specific to the light type.
  44283. * @param defines the list of defines
  44284. * @param lightIndex defines the index of the light for the effect
  44285. */
  44286. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44287. }
  44288. }
  44289. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44290. import { Mesh } from "babylonjs/Meshes/mesh";
  44291. /**
  44292. * Class containing static functions to help procedurally build meshes
  44293. */
  44294. export class HemisphereBuilder {
  44295. /**
  44296. * Creates a hemisphere mesh
  44297. * @param name defines the name of the mesh
  44298. * @param options defines the options used to create the mesh
  44299. * @param scene defines the hosting scene
  44300. * @returns the hemisphere mesh
  44301. */
  44302. static CreateHemisphere(name: string, options: {
  44303. segments?: number;
  44304. diameter?: number;
  44305. sideOrientation?: number;
  44306. }, scene: any): Mesh;
  44307. }
  44308. }
  44309. declare module "babylonjs/Lights/spotLight" {
  44310. import { Nullable } from "babylonjs/types";
  44311. import { Scene } from "babylonjs/scene";
  44312. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44314. import { Effect } from "babylonjs/Materials/effect";
  44315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44316. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44317. /**
  44318. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44319. * These values define a cone of light starting from the position, emitting toward the direction.
  44320. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44321. * and the exponent defines the speed of the decay of the light with distance (reach).
  44322. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44323. */
  44324. export class SpotLight extends ShadowLight {
  44325. private _angle;
  44326. private _innerAngle;
  44327. private _cosHalfAngle;
  44328. private _lightAngleScale;
  44329. private _lightAngleOffset;
  44330. /**
  44331. * Gets the cone angle of the spot light in Radians.
  44332. */
  44333. /**
  44334. * Sets the cone angle of the spot light in Radians.
  44335. */
  44336. angle: number;
  44337. /**
  44338. * Only used in gltf falloff mode, this defines the angle where
  44339. * the directional falloff will start before cutting at angle which could be seen
  44340. * as outer angle.
  44341. */
  44342. /**
  44343. * Only used in gltf falloff mode, this defines the angle where
  44344. * the directional falloff will start before cutting at angle which could be seen
  44345. * as outer angle.
  44346. */
  44347. innerAngle: number;
  44348. private _shadowAngleScale;
  44349. /**
  44350. * Allows scaling the angle of the light for shadow generation only.
  44351. */
  44352. /**
  44353. * Allows scaling the angle of the light for shadow generation only.
  44354. */
  44355. shadowAngleScale: number;
  44356. /**
  44357. * The light decay speed with the distance from the emission spot.
  44358. */
  44359. exponent: number;
  44360. private _projectionTextureMatrix;
  44361. /**
  44362. * Allows reading the projecton texture
  44363. */
  44364. readonly projectionTextureMatrix: Matrix;
  44365. protected _projectionTextureLightNear: number;
  44366. /**
  44367. * Gets the near clip of the Spotlight for texture projection.
  44368. */
  44369. /**
  44370. * Sets the near clip of the Spotlight for texture projection.
  44371. */
  44372. projectionTextureLightNear: number;
  44373. protected _projectionTextureLightFar: number;
  44374. /**
  44375. * Gets the far clip of the Spotlight for texture projection.
  44376. */
  44377. /**
  44378. * Sets the far clip of the Spotlight for texture projection.
  44379. */
  44380. projectionTextureLightFar: number;
  44381. protected _projectionTextureUpDirection: Vector3;
  44382. /**
  44383. * Gets the Up vector of the Spotlight for texture projection.
  44384. */
  44385. /**
  44386. * Sets the Up vector of the Spotlight for texture projection.
  44387. */
  44388. projectionTextureUpDirection: Vector3;
  44389. private _projectionTexture;
  44390. /**
  44391. * Gets the projection texture of the light.
  44392. */
  44393. /**
  44394. * Sets the projection texture of the light.
  44395. */
  44396. projectionTexture: Nullable<BaseTexture>;
  44397. private _projectionTextureViewLightDirty;
  44398. private _projectionTextureProjectionLightDirty;
  44399. private _projectionTextureDirty;
  44400. private _projectionTextureViewTargetVector;
  44401. private _projectionTextureViewLightMatrix;
  44402. private _projectionTextureProjectionLightMatrix;
  44403. private _projectionTextureScalingMatrix;
  44404. /**
  44405. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44406. * It can cast shadows.
  44407. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44408. * @param name The light friendly name
  44409. * @param position The position of the spot light in the scene
  44410. * @param direction The direction of the light in the scene
  44411. * @param angle The cone angle of the light in Radians
  44412. * @param exponent The light decay speed with the distance from the emission spot
  44413. * @param scene The scene the lights belongs to
  44414. */
  44415. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44416. /**
  44417. * Returns the string "SpotLight".
  44418. * @returns the class name
  44419. */
  44420. getClassName(): string;
  44421. /**
  44422. * Returns the integer 2.
  44423. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44424. */
  44425. getTypeID(): number;
  44426. /**
  44427. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44428. */
  44429. protected _setDirection(value: Vector3): void;
  44430. /**
  44431. * Overrides the position setter to recompute the projection texture view light Matrix.
  44432. */
  44433. protected _setPosition(value: Vector3): void;
  44434. /**
  44435. * 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.
  44436. * Returns the SpotLight.
  44437. */
  44438. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44439. protected _computeProjectionTextureViewLightMatrix(): void;
  44440. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44441. /**
  44442. * Main function for light texture projection matrix computing.
  44443. */
  44444. protected _computeProjectionTextureMatrix(): void;
  44445. protected _buildUniformLayout(): void;
  44446. private _computeAngleValues;
  44447. /**
  44448. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44449. * @param effect The effect to update
  44450. * @param lightIndex The index of the light in the effect to update
  44451. * @returns The spot light
  44452. */
  44453. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44454. /**
  44455. * Disposes the light and the associated resources.
  44456. */
  44457. dispose(): void;
  44458. /**
  44459. * Prepares the list of defines specific to the light type.
  44460. * @param defines the list of defines
  44461. * @param lightIndex defines the index of the light for the effect
  44462. */
  44463. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44464. }
  44465. }
  44466. declare module "babylonjs/Gizmos/lightGizmo" {
  44467. import { Nullable } from "babylonjs/types";
  44468. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44470. import { Light } from "babylonjs/Lights/light";
  44471. /**
  44472. * Gizmo that enables viewing a light
  44473. */
  44474. export class LightGizmo extends Gizmo {
  44475. private _lightMesh;
  44476. private _material;
  44477. /**
  44478. * Creates a LightGizmo
  44479. * @param gizmoLayer The utility layer the gizmo will be added to
  44480. */
  44481. constructor(gizmoLayer?: UtilityLayerRenderer);
  44482. private _light;
  44483. /**
  44484. * The light that the gizmo is attached to
  44485. */
  44486. light: Nullable<Light>;
  44487. /**
  44488. * @hidden
  44489. * Updates the gizmo to match the attached mesh's position/rotation
  44490. */
  44491. protected _update(): void;
  44492. private static _Scale;
  44493. /**
  44494. * Creates the lines for a light mesh
  44495. */
  44496. private static _createLightLines;
  44497. private static _CreateHemisphericLightMesh;
  44498. private static _CreatePointLightMesh;
  44499. private static _CreateSpotLightMesh;
  44500. private static _CreateDirectionalLightMesh;
  44501. }
  44502. }
  44503. declare module "babylonjs/Gizmos/index" {
  44504. export * from "babylonjs/Gizmos/axisDragGizmo";
  44505. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44506. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44507. export * from "babylonjs/Gizmos/gizmo";
  44508. export * from "babylonjs/Gizmos/gizmoManager";
  44509. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44510. export * from "babylonjs/Gizmos/positionGizmo";
  44511. export * from "babylonjs/Gizmos/rotationGizmo";
  44512. export * from "babylonjs/Gizmos/scaleGizmo";
  44513. export * from "babylonjs/Gizmos/lightGizmo";
  44514. }
  44515. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44516. /** @hidden */
  44517. export var backgroundFragmentDeclaration: {
  44518. name: string;
  44519. shader: string;
  44520. };
  44521. }
  44522. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44523. /** @hidden */
  44524. export var backgroundUboDeclaration: {
  44525. name: string;
  44526. shader: string;
  44527. };
  44528. }
  44529. declare module "babylonjs/Shaders/background.fragment" {
  44530. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44531. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44532. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44533. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44534. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44535. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44536. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44537. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44538. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44539. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44540. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44541. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44543. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44544. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44545. /** @hidden */
  44546. export var backgroundPixelShader: {
  44547. name: string;
  44548. shader: string;
  44549. };
  44550. }
  44551. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44552. /** @hidden */
  44553. export var backgroundVertexDeclaration: {
  44554. name: string;
  44555. shader: string;
  44556. };
  44557. }
  44558. declare module "babylonjs/Shaders/background.vertex" {
  44559. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44560. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44562. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44563. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44564. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44565. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44566. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44567. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44568. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44569. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44571. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44572. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44573. /** @hidden */
  44574. export var backgroundVertexShader: {
  44575. name: string;
  44576. shader: string;
  44577. };
  44578. }
  44579. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44580. import { Nullable, int, float } from "babylonjs/types";
  44581. import { Scene } from "babylonjs/scene";
  44582. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44583. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44585. import { Mesh } from "babylonjs/Meshes/mesh";
  44586. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44587. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44588. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44590. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44591. import "babylonjs/Shaders/background.fragment";
  44592. import "babylonjs/Shaders/background.vertex";
  44593. /**
  44594. * Background material used to create an efficient environement around your scene.
  44595. */
  44596. export class BackgroundMaterial extends PushMaterial {
  44597. /**
  44598. * Standard reflectance value at parallel view angle.
  44599. */
  44600. static StandardReflectance0: number;
  44601. /**
  44602. * Standard reflectance value at grazing angle.
  44603. */
  44604. static StandardReflectance90: number;
  44605. protected _primaryColor: Color3;
  44606. /**
  44607. * Key light Color (multiply against the environement texture)
  44608. */
  44609. primaryColor: Color3;
  44610. protected __perceptualColor: Nullable<Color3>;
  44611. /**
  44612. * Experimental Internal Use Only.
  44613. *
  44614. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44615. * This acts as a helper to set the primary color to a more "human friendly" value.
  44616. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44617. * output color as close as possible from the chosen value.
  44618. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44619. * part of lighting setup.)
  44620. */
  44621. _perceptualColor: Nullable<Color3>;
  44622. protected _primaryColorShadowLevel: float;
  44623. /**
  44624. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44625. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44626. */
  44627. primaryColorShadowLevel: float;
  44628. protected _primaryColorHighlightLevel: float;
  44629. /**
  44630. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44631. * The primary color is used at the level chosen to define what the white area would look.
  44632. */
  44633. primaryColorHighlightLevel: float;
  44634. protected _reflectionTexture: Nullable<BaseTexture>;
  44635. /**
  44636. * Reflection Texture used in the material.
  44637. * Should be author in a specific way for the best result (refer to the documentation).
  44638. */
  44639. reflectionTexture: Nullable<BaseTexture>;
  44640. protected _reflectionBlur: float;
  44641. /**
  44642. * Reflection Texture level of blur.
  44643. *
  44644. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44645. * texture twice.
  44646. */
  44647. reflectionBlur: float;
  44648. protected _diffuseTexture: Nullable<BaseTexture>;
  44649. /**
  44650. * Diffuse Texture used in the material.
  44651. * Should be author in a specific way for the best result (refer to the documentation).
  44652. */
  44653. diffuseTexture: Nullable<BaseTexture>;
  44654. protected _shadowLights: Nullable<IShadowLight[]>;
  44655. /**
  44656. * Specify the list of lights casting shadow on the material.
  44657. * All scene shadow lights will be included if null.
  44658. */
  44659. shadowLights: Nullable<IShadowLight[]>;
  44660. protected _shadowLevel: float;
  44661. /**
  44662. * Helps adjusting the shadow to a softer level if required.
  44663. * 0 means black shadows and 1 means no shadows.
  44664. */
  44665. shadowLevel: float;
  44666. protected _sceneCenter: Vector3;
  44667. /**
  44668. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44669. * It is usually zero but might be interesting to modify according to your setup.
  44670. */
  44671. sceneCenter: Vector3;
  44672. protected _opacityFresnel: boolean;
  44673. /**
  44674. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44675. * This helps ensuring a nice transition when the camera goes under the ground.
  44676. */
  44677. opacityFresnel: boolean;
  44678. protected _reflectionFresnel: boolean;
  44679. /**
  44680. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44681. * This helps adding a mirror texture on the ground.
  44682. */
  44683. reflectionFresnel: boolean;
  44684. protected _reflectionFalloffDistance: number;
  44685. /**
  44686. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44687. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44688. */
  44689. reflectionFalloffDistance: number;
  44690. protected _reflectionAmount: number;
  44691. /**
  44692. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44693. */
  44694. reflectionAmount: number;
  44695. protected _reflectionReflectance0: number;
  44696. /**
  44697. * This specifies the weight of the reflection at grazing angle.
  44698. */
  44699. reflectionReflectance0: number;
  44700. protected _reflectionReflectance90: number;
  44701. /**
  44702. * This specifies the weight of the reflection at a perpendicular point of view.
  44703. */
  44704. reflectionReflectance90: number;
  44705. /**
  44706. * Sets the reflection reflectance fresnel values according to the default standard
  44707. * empirically know to work well :-)
  44708. */
  44709. reflectionStandardFresnelWeight: number;
  44710. protected _useRGBColor: boolean;
  44711. /**
  44712. * Helps to directly use the maps channels instead of their level.
  44713. */
  44714. useRGBColor: boolean;
  44715. protected _enableNoise: boolean;
  44716. /**
  44717. * This helps reducing the banding effect that could occur on the background.
  44718. */
  44719. enableNoise: boolean;
  44720. /**
  44721. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44722. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44723. * Recommended to be keep at 1.0 except for special cases.
  44724. */
  44725. fovMultiplier: number;
  44726. private _fovMultiplier;
  44727. /**
  44728. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44729. */
  44730. useEquirectangularFOV: boolean;
  44731. private _maxSimultaneousLights;
  44732. /**
  44733. * Number of Simultaneous lights allowed on the material.
  44734. */
  44735. maxSimultaneousLights: int;
  44736. /**
  44737. * Default configuration related to image processing available in the Background Material.
  44738. */
  44739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44740. /**
  44741. * Keep track of the image processing observer to allow dispose and replace.
  44742. */
  44743. private _imageProcessingObserver;
  44744. /**
  44745. * Attaches a new image processing configuration to the PBR Material.
  44746. * @param configuration (if null the scene configuration will be use)
  44747. */
  44748. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44749. /**
  44750. * Gets the image processing configuration used either in this material.
  44751. */
  44752. /**
  44753. * Sets the Default image processing configuration used either in the this material.
  44754. *
  44755. * If sets to null, the scene one is in use.
  44756. */
  44757. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44758. /**
  44759. * Gets wether the color curves effect is enabled.
  44760. */
  44761. /**
  44762. * Sets wether the color curves effect is enabled.
  44763. */
  44764. cameraColorCurvesEnabled: boolean;
  44765. /**
  44766. * Gets wether the color grading effect is enabled.
  44767. */
  44768. /**
  44769. * Gets wether the color grading effect is enabled.
  44770. */
  44771. cameraColorGradingEnabled: boolean;
  44772. /**
  44773. * Gets wether tonemapping is enabled or not.
  44774. */
  44775. /**
  44776. * Sets wether tonemapping is enabled or not
  44777. */
  44778. cameraToneMappingEnabled: boolean;
  44779. /**
  44780. * The camera exposure used on this material.
  44781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44782. * This corresponds to a photographic exposure.
  44783. */
  44784. /**
  44785. * The camera exposure used on this material.
  44786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44787. * This corresponds to a photographic exposure.
  44788. */
  44789. cameraExposure: float;
  44790. /**
  44791. * Gets The camera contrast used on this material.
  44792. */
  44793. /**
  44794. * Sets The camera contrast used on this material.
  44795. */
  44796. cameraContrast: float;
  44797. /**
  44798. * Gets the Color Grading 2D Lookup Texture.
  44799. */
  44800. /**
  44801. * Sets the Color Grading 2D Lookup Texture.
  44802. */
  44803. cameraColorGradingTexture: Nullable<BaseTexture>;
  44804. /**
  44805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44807. * 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;
  44808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44809. */
  44810. /**
  44811. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44812. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44813. * 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;
  44814. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44815. */
  44816. cameraColorCurves: Nullable<ColorCurves>;
  44817. /**
  44818. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44819. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44820. */
  44821. switchToBGR: boolean;
  44822. private _renderTargets;
  44823. private _reflectionControls;
  44824. private _white;
  44825. private _primaryShadowColor;
  44826. private _primaryHighlightColor;
  44827. /**
  44828. * Instantiates a Background Material in the given scene
  44829. * @param name The friendly name of the material
  44830. * @param scene The scene to add the material to
  44831. */
  44832. constructor(name: string, scene: Scene);
  44833. /**
  44834. * Gets a boolean indicating that current material needs to register RTT
  44835. */
  44836. readonly hasRenderTargetTextures: boolean;
  44837. /**
  44838. * The entire material has been created in order to prevent overdraw.
  44839. * @returns false
  44840. */
  44841. needAlphaTesting(): boolean;
  44842. /**
  44843. * The entire material has been created in order to prevent overdraw.
  44844. * @returns true if blending is enable
  44845. */
  44846. needAlphaBlending(): boolean;
  44847. /**
  44848. * Checks wether the material is ready to be rendered for a given mesh.
  44849. * @param mesh The mesh to render
  44850. * @param subMesh The submesh to check against
  44851. * @param useInstances Specify wether or not the material is used with instances
  44852. * @returns true if all the dependencies are ready (Textures, Effects...)
  44853. */
  44854. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44855. /**
  44856. * Compute the primary color according to the chosen perceptual color.
  44857. */
  44858. private _computePrimaryColorFromPerceptualColor;
  44859. /**
  44860. * Compute the highlights and shadow colors according to their chosen levels.
  44861. */
  44862. private _computePrimaryColors;
  44863. /**
  44864. * Build the uniform buffer used in the material.
  44865. */
  44866. buildUniformLayout(): void;
  44867. /**
  44868. * Unbind the material.
  44869. */
  44870. unbind(): void;
  44871. /**
  44872. * Bind only the world matrix to the material.
  44873. * @param world The world matrix to bind.
  44874. */
  44875. bindOnlyWorldMatrix(world: Matrix): void;
  44876. /**
  44877. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44878. * @param world The world matrix to bind.
  44879. * @param subMesh The submesh to bind for.
  44880. */
  44881. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44882. /**
  44883. * Dispose the material.
  44884. * @param forceDisposeEffect Force disposal of the associated effect.
  44885. * @param forceDisposeTextures Force disposal of the associated textures.
  44886. */
  44887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44888. /**
  44889. * Clones the material.
  44890. * @param name The cloned name.
  44891. * @returns The cloned material.
  44892. */
  44893. clone(name: string): BackgroundMaterial;
  44894. /**
  44895. * Serializes the current material to its JSON representation.
  44896. * @returns The JSON representation.
  44897. */
  44898. serialize(): any;
  44899. /**
  44900. * Gets the class name of the material
  44901. * @returns "BackgroundMaterial"
  44902. */
  44903. getClassName(): string;
  44904. /**
  44905. * Parse a JSON input to create back a background material.
  44906. * @param source The JSON data to parse
  44907. * @param scene The scene to create the parsed material in
  44908. * @param rootUrl The root url of the assets the material depends upon
  44909. * @returns the instantiated BackgroundMaterial.
  44910. */
  44911. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44912. }
  44913. }
  44914. declare module "babylonjs/Helpers/environmentHelper" {
  44915. import { Observable } from "babylonjs/Misc/observable";
  44916. import { Nullable } from "babylonjs/types";
  44917. import { Scene } from "babylonjs/scene";
  44918. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44920. import { Mesh } from "babylonjs/Meshes/mesh";
  44921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44922. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44923. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44924. import "babylonjs/Meshes/Builders/planeBuilder";
  44925. import "babylonjs/Meshes/Builders/boxBuilder";
  44926. /**
  44927. * Represents the different options available during the creation of
  44928. * a Environment helper.
  44929. *
  44930. * This can control the default ground, skybox and image processing setup of your scene.
  44931. */
  44932. export interface IEnvironmentHelperOptions {
  44933. /**
  44934. * Specifies wether or not to create a ground.
  44935. * True by default.
  44936. */
  44937. createGround: boolean;
  44938. /**
  44939. * Specifies the ground size.
  44940. * 15 by default.
  44941. */
  44942. groundSize: number;
  44943. /**
  44944. * The texture used on the ground for the main color.
  44945. * Comes from the BabylonJS CDN by default.
  44946. *
  44947. * Remarks: Can be either a texture or a url.
  44948. */
  44949. groundTexture: string | BaseTexture;
  44950. /**
  44951. * The color mixed in the ground texture by default.
  44952. * BabylonJS clearColor by default.
  44953. */
  44954. groundColor: Color3;
  44955. /**
  44956. * Specifies the ground opacity.
  44957. * 1 by default.
  44958. */
  44959. groundOpacity: number;
  44960. /**
  44961. * Enables the ground to receive shadows.
  44962. * True by default.
  44963. */
  44964. enableGroundShadow: boolean;
  44965. /**
  44966. * Helps preventing the shadow to be fully black on the ground.
  44967. * 0.5 by default.
  44968. */
  44969. groundShadowLevel: number;
  44970. /**
  44971. * Creates a mirror texture attach to the ground.
  44972. * false by default.
  44973. */
  44974. enableGroundMirror: boolean;
  44975. /**
  44976. * Specifies the ground mirror size ratio.
  44977. * 0.3 by default as the default kernel is 64.
  44978. */
  44979. groundMirrorSizeRatio: number;
  44980. /**
  44981. * Specifies the ground mirror blur kernel size.
  44982. * 64 by default.
  44983. */
  44984. groundMirrorBlurKernel: number;
  44985. /**
  44986. * Specifies the ground mirror visibility amount.
  44987. * 1 by default
  44988. */
  44989. groundMirrorAmount: number;
  44990. /**
  44991. * Specifies the ground mirror reflectance weight.
  44992. * This uses the standard weight of the background material to setup the fresnel effect
  44993. * of the mirror.
  44994. * 1 by default.
  44995. */
  44996. groundMirrorFresnelWeight: number;
  44997. /**
  44998. * Specifies the ground mirror Falloff distance.
  44999. * This can helps reducing the size of the reflection.
  45000. * 0 by Default.
  45001. */
  45002. groundMirrorFallOffDistance: number;
  45003. /**
  45004. * Specifies the ground mirror texture type.
  45005. * Unsigned Int by Default.
  45006. */
  45007. groundMirrorTextureType: number;
  45008. /**
  45009. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45010. * the shown objects.
  45011. */
  45012. groundYBias: number;
  45013. /**
  45014. * Specifies wether or not to create a skybox.
  45015. * True by default.
  45016. */
  45017. createSkybox: boolean;
  45018. /**
  45019. * Specifies the skybox size.
  45020. * 20 by default.
  45021. */
  45022. skyboxSize: number;
  45023. /**
  45024. * The texture used on the skybox for the main color.
  45025. * Comes from the BabylonJS CDN by default.
  45026. *
  45027. * Remarks: Can be either a texture or a url.
  45028. */
  45029. skyboxTexture: string | BaseTexture;
  45030. /**
  45031. * The color mixed in the skybox texture by default.
  45032. * BabylonJS clearColor by default.
  45033. */
  45034. skyboxColor: Color3;
  45035. /**
  45036. * The background rotation around the Y axis of the scene.
  45037. * This helps aligning the key lights of your scene with the background.
  45038. * 0 by default.
  45039. */
  45040. backgroundYRotation: number;
  45041. /**
  45042. * Compute automatically the size of the elements to best fit with the scene.
  45043. */
  45044. sizeAuto: boolean;
  45045. /**
  45046. * Default position of the rootMesh if autoSize is not true.
  45047. */
  45048. rootPosition: Vector3;
  45049. /**
  45050. * Sets up the image processing in the scene.
  45051. * true by default.
  45052. */
  45053. setupImageProcessing: boolean;
  45054. /**
  45055. * The texture used as your environment texture in the scene.
  45056. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45057. *
  45058. * Remarks: Can be either a texture or a url.
  45059. */
  45060. environmentTexture: string | BaseTexture;
  45061. /**
  45062. * The value of the exposure to apply to the scene.
  45063. * 0.6 by default if setupImageProcessing is true.
  45064. */
  45065. cameraExposure: number;
  45066. /**
  45067. * The value of the contrast to apply to the scene.
  45068. * 1.6 by default if setupImageProcessing is true.
  45069. */
  45070. cameraContrast: number;
  45071. /**
  45072. * Specifies wether or not tonemapping should be enabled in the scene.
  45073. * true by default if setupImageProcessing is true.
  45074. */
  45075. toneMappingEnabled: boolean;
  45076. }
  45077. /**
  45078. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45079. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45080. * It also helps with the default setup of your imageProcessing configuration.
  45081. */
  45082. export class EnvironmentHelper {
  45083. /**
  45084. * Default ground texture URL.
  45085. */
  45086. private static _groundTextureCDNUrl;
  45087. /**
  45088. * Default skybox texture URL.
  45089. */
  45090. private static _skyboxTextureCDNUrl;
  45091. /**
  45092. * Default environment texture URL.
  45093. */
  45094. private static _environmentTextureCDNUrl;
  45095. /**
  45096. * Creates the default options for the helper.
  45097. */
  45098. private static _getDefaultOptions;
  45099. private _rootMesh;
  45100. /**
  45101. * Gets the root mesh created by the helper.
  45102. */
  45103. readonly rootMesh: Mesh;
  45104. private _skybox;
  45105. /**
  45106. * Gets the skybox created by the helper.
  45107. */
  45108. readonly skybox: Nullable<Mesh>;
  45109. private _skyboxTexture;
  45110. /**
  45111. * Gets the skybox texture created by the helper.
  45112. */
  45113. readonly skyboxTexture: Nullable<BaseTexture>;
  45114. private _skyboxMaterial;
  45115. /**
  45116. * Gets the skybox material created by the helper.
  45117. */
  45118. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45119. private _ground;
  45120. /**
  45121. * Gets the ground mesh created by the helper.
  45122. */
  45123. readonly ground: Nullable<Mesh>;
  45124. private _groundTexture;
  45125. /**
  45126. * Gets the ground texture created by the helper.
  45127. */
  45128. readonly groundTexture: Nullable<BaseTexture>;
  45129. private _groundMirror;
  45130. /**
  45131. * Gets the ground mirror created by the helper.
  45132. */
  45133. readonly groundMirror: Nullable<MirrorTexture>;
  45134. /**
  45135. * Gets the ground mirror render list to helps pushing the meshes
  45136. * you wish in the ground reflection.
  45137. */
  45138. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45139. private _groundMaterial;
  45140. /**
  45141. * Gets the ground material created by the helper.
  45142. */
  45143. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45144. /**
  45145. * Stores the creation options.
  45146. */
  45147. private readonly _scene;
  45148. private _options;
  45149. /**
  45150. * This observable will be notified with any error during the creation of the environment,
  45151. * mainly texture creation errors.
  45152. */
  45153. onErrorObservable: Observable<{
  45154. message?: string;
  45155. exception?: any;
  45156. }>;
  45157. /**
  45158. * constructor
  45159. * @param options Defines the options we want to customize the helper
  45160. * @param scene The scene to add the material to
  45161. */
  45162. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45163. /**
  45164. * Updates the background according to the new options
  45165. * @param options
  45166. */
  45167. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45168. /**
  45169. * Sets the primary color of all the available elements.
  45170. * @param color the main color to affect to the ground and the background
  45171. */
  45172. setMainColor(color: Color3): void;
  45173. /**
  45174. * Setup the image processing according to the specified options.
  45175. */
  45176. private _setupImageProcessing;
  45177. /**
  45178. * Setup the environment texture according to the specified options.
  45179. */
  45180. private _setupEnvironmentTexture;
  45181. /**
  45182. * Setup the background according to the specified options.
  45183. */
  45184. private _setupBackground;
  45185. /**
  45186. * Get the scene sizes according to the setup.
  45187. */
  45188. private _getSceneSize;
  45189. /**
  45190. * Setup the ground according to the specified options.
  45191. */
  45192. private _setupGround;
  45193. /**
  45194. * Setup the ground material according to the specified options.
  45195. */
  45196. private _setupGroundMaterial;
  45197. /**
  45198. * Setup the ground diffuse texture according to the specified options.
  45199. */
  45200. private _setupGroundDiffuseTexture;
  45201. /**
  45202. * Setup the ground mirror texture according to the specified options.
  45203. */
  45204. private _setupGroundMirrorTexture;
  45205. /**
  45206. * Setup the ground to receive the mirror texture.
  45207. */
  45208. private _setupMirrorInGroundMaterial;
  45209. /**
  45210. * Setup the skybox according to the specified options.
  45211. */
  45212. private _setupSkybox;
  45213. /**
  45214. * Setup the skybox material according to the specified options.
  45215. */
  45216. private _setupSkyboxMaterial;
  45217. /**
  45218. * Setup the skybox reflection texture according to the specified options.
  45219. */
  45220. private _setupSkyboxReflectionTexture;
  45221. private _errorHandler;
  45222. /**
  45223. * Dispose all the elements created by the Helper.
  45224. */
  45225. dispose(): void;
  45226. }
  45227. }
  45228. declare module "babylonjs/Helpers/photoDome" {
  45229. import { Observable } from "babylonjs/Misc/observable";
  45230. import { Nullable } from "babylonjs/types";
  45231. import { Scene } from "babylonjs/scene";
  45232. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45233. import { Mesh } from "babylonjs/Meshes/mesh";
  45234. import { Texture } from "babylonjs/Materials/Textures/texture";
  45235. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45236. import "babylonjs/Meshes/Builders/sphereBuilder";
  45237. /**
  45238. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45239. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45240. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45241. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45242. */
  45243. export class PhotoDome extends TransformNode {
  45244. private _useDirectMapping;
  45245. /**
  45246. * The texture being displayed on the sphere
  45247. */
  45248. protected _photoTexture: Texture;
  45249. /**
  45250. * Gets or sets the texture being displayed on the sphere
  45251. */
  45252. photoTexture: Texture;
  45253. /**
  45254. * Observable raised when an error occured while loading the 360 image
  45255. */
  45256. onLoadErrorObservable: Observable<string>;
  45257. /**
  45258. * The skybox material
  45259. */
  45260. protected _material: BackgroundMaterial;
  45261. /**
  45262. * The surface used for the skybox
  45263. */
  45264. protected _mesh: Mesh;
  45265. /**
  45266. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45267. * Also see the options.resolution property.
  45268. */
  45269. fovMultiplier: number;
  45270. /**
  45271. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45272. * @param name Element's name, child elements will append suffixes for their own names.
  45273. * @param urlsOfPhoto defines the url of the photo to display
  45274. * @param options defines an object containing optional or exposed sub element properties
  45275. * @param onError defines a callback called when an error occured while loading the texture
  45276. */
  45277. constructor(name: string, urlOfPhoto: string, options: {
  45278. resolution?: number;
  45279. size?: number;
  45280. useDirectMapping?: boolean;
  45281. faceForward?: boolean;
  45282. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45283. /**
  45284. * Releases resources associated with this node.
  45285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45287. */
  45288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45289. }
  45290. }
  45291. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45292. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45293. /** @hidden */
  45294. export var rgbdDecodePixelShader: {
  45295. name: string;
  45296. shader: string;
  45297. };
  45298. }
  45299. declare module "babylonjs/Misc/brdfTextureTools" {
  45300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45301. import { Scene } from "babylonjs/scene";
  45302. import "babylonjs/Shaders/rgbdDecode.fragment";
  45303. /**
  45304. * Class used to host texture specific utilities
  45305. */
  45306. export class BRDFTextureTools {
  45307. /**
  45308. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45309. * @param texture the texture to expand.
  45310. */
  45311. private static _ExpandDefaultBRDFTexture;
  45312. /**
  45313. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45314. * @param scene defines the hosting scene
  45315. * @returns the environment BRDF texture
  45316. */
  45317. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45318. private static _environmentBRDFBase64Texture;
  45319. }
  45320. }
  45321. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45322. import { Nullable } from "babylonjs/types";
  45323. import { IAnimatable } from "babylonjs/Misc/tools";
  45324. import { Color3 } from "babylonjs/Maths/math";
  45325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45326. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45327. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45328. import { Engine } from "babylonjs/Engines/engine";
  45329. import { Scene } from "babylonjs/scene";
  45330. /**
  45331. * @hidden
  45332. */
  45333. export interface IMaterialClearCoatDefines {
  45334. CLEARCOAT: boolean;
  45335. CLEARCOAT_DEFAULTIOR: boolean;
  45336. CLEARCOAT_TEXTURE: boolean;
  45337. CLEARCOAT_TEXTUREDIRECTUV: number;
  45338. CLEARCOAT_BUMP: boolean;
  45339. CLEARCOAT_BUMPDIRECTUV: number;
  45340. CLEARCOAT_TINT: boolean;
  45341. CLEARCOAT_TINT_TEXTURE: boolean;
  45342. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45343. /** @hidden */
  45344. _areTexturesDirty: boolean;
  45345. }
  45346. /**
  45347. * Define the code related to the clear coat parameters of the pbr material.
  45348. */
  45349. export class PBRClearCoatConfiguration {
  45350. /**
  45351. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45352. * The default fits with a polyurethane material.
  45353. */
  45354. private static readonly _DefaultIndiceOfRefraction;
  45355. private _isEnabled;
  45356. /**
  45357. * Defines if the clear coat is enabled in the material.
  45358. */
  45359. isEnabled: boolean;
  45360. /**
  45361. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45362. */
  45363. intensity: number;
  45364. /**
  45365. * Defines the clear coat layer roughness.
  45366. */
  45367. roughness: number;
  45368. private _indiceOfRefraction;
  45369. /**
  45370. * Defines the indice of refraction of the clear coat.
  45371. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45372. * The default fits with a polyurethane material.
  45373. * Changing the default value is more performance intensive.
  45374. */
  45375. indiceOfRefraction: number;
  45376. private _texture;
  45377. /**
  45378. * Stores the clear coat values in a texture.
  45379. */
  45380. texture: Nullable<BaseTexture>;
  45381. private _bumpTexture;
  45382. /**
  45383. * Define the clear coat specific bump texture.
  45384. */
  45385. bumpTexture: Nullable<BaseTexture>;
  45386. private _isTintEnabled;
  45387. /**
  45388. * Defines if the clear coat tint is enabled in the material.
  45389. */
  45390. isTintEnabled: boolean;
  45391. /**
  45392. * Defines the clear coat tint of the material.
  45393. * This is only use if tint is enabled
  45394. */
  45395. tintColor: Color3;
  45396. /**
  45397. * Defines the distance at which the tint color should be found in the
  45398. * clear coat media.
  45399. * This is only use if tint is enabled
  45400. */
  45401. tintColorAtDistance: number;
  45402. /**
  45403. * Defines the clear coat layer thickness.
  45404. * This is only use if tint is enabled
  45405. */
  45406. tintThickness: number;
  45407. private _tintTexture;
  45408. /**
  45409. * Stores the clear tint values in a texture.
  45410. * rgb is tint
  45411. * a is a thickness factor
  45412. */
  45413. tintTexture: Nullable<BaseTexture>;
  45414. /** @hidden */
  45415. private _internalMarkAllSubMeshesAsTexturesDirty;
  45416. /** @hidden */
  45417. _markAllSubMeshesAsTexturesDirty(): void;
  45418. /**
  45419. * Instantiate a new istance of clear coat configuration.
  45420. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45421. */
  45422. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45423. /**
  45424. * Gets wehter the submesh is ready to be used or not.
  45425. * @param defines the list of "defines" to update.
  45426. * @param scene defines the scene the material belongs to.
  45427. * @param engine defines the engine the material belongs to.
  45428. * @param disableBumpMap defines wether the material disables bump or not.
  45429. * @returns - boolean indicating that the submesh is ready or not.
  45430. */
  45431. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45432. /**
  45433. * Checks to see if a texture is used in the material.
  45434. * @param defines the list of "defines" to update.
  45435. * @param scene defines the scene to the material belongs to.
  45436. */
  45437. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45438. /**
  45439. * Binds the material data.
  45440. * @param uniformBuffer defines the Uniform buffer to fill in.
  45441. * @param scene defines the scene the material belongs to.
  45442. * @param engine defines the engine the material belongs to.
  45443. * @param disableBumpMap defines wether the material disables bump or not.
  45444. * @param isFrozen defines wether the material is frozen or not.
  45445. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45446. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45447. */
  45448. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45449. /**
  45450. * Checks to see if a texture is used in the material.
  45451. * @param texture - Base texture to use.
  45452. * @returns - Boolean specifying if a texture is used in the material.
  45453. */
  45454. hasTexture(texture: BaseTexture): boolean;
  45455. /**
  45456. * Returns an array of the actively used textures.
  45457. * @param activeTextures Array of BaseTextures
  45458. */
  45459. getActiveTextures(activeTextures: BaseTexture[]): void;
  45460. /**
  45461. * Returns the animatable textures.
  45462. * @param animatables Array of animatable textures.
  45463. */
  45464. getAnimatables(animatables: IAnimatable[]): void;
  45465. /**
  45466. * Disposes the resources of the material.
  45467. * @param forceDisposeTextures - Forces the disposal of all textures.
  45468. */
  45469. dispose(forceDisposeTextures?: boolean): void;
  45470. /**
  45471. * Get the current class name of the texture useful for serialization or dynamic coding.
  45472. * @returns "PBRClearCoatConfiguration"
  45473. */
  45474. getClassName(): string;
  45475. /**
  45476. * Add fallbacks to the effect fallbacks list.
  45477. * @param defines defines the Base texture to use.
  45478. * @param fallbacks defines the current fallback list.
  45479. * @param currentRank defines the current fallback rank.
  45480. * @returns the new fallback rank.
  45481. */
  45482. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45483. /**
  45484. * Add the required uniforms to the current list.
  45485. * @param uniforms defines the current uniform list.
  45486. */
  45487. static AddUniforms(uniforms: string[]): void;
  45488. /**
  45489. * Add the required samplers to the current list.
  45490. * @param samplers defines the current sampler list.
  45491. */
  45492. static AddSamplers(samplers: string[]): void;
  45493. /**
  45494. * Add the required uniforms to the current buffer.
  45495. * @param uniformBuffer defines the current uniform buffer.
  45496. */
  45497. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45498. /**
  45499. * Makes a duplicate of the current configuration into another one.
  45500. * @param clearCoatConfiguration define the config where to copy the info
  45501. */
  45502. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45503. /**
  45504. * Serializes this clear coat configuration.
  45505. * @returns - An object with the serialized config.
  45506. */
  45507. serialize(): any;
  45508. /**
  45509. * Parses a Clear Coat Configuration from a serialized object.
  45510. * @param source - Serialized object.
  45511. */
  45512. parse(source: any): void;
  45513. }
  45514. }
  45515. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45516. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45519. import { Vector2 } from "babylonjs/Maths/math";
  45520. import { Scene } from "babylonjs/scene";
  45521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45522. import { IAnimatable } from "babylonjs/Misc/tools";
  45523. import { Nullable } from "babylonjs/types";
  45524. /**
  45525. * @hidden
  45526. */
  45527. export interface IMaterialAnisotropicDefines {
  45528. ANISOTROPIC: boolean;
  45529. ANISOTROPIC_TEXTURE: boolean;
  45530. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45531. MAINUV1: boolean;
  45532. _areTexturesDirty: boolean;
  45533. _needUVs: boolean;
  45534. }
  45535. /**
  45536. * Define the code related to the anisotropic parameters of the pbr material.
  45537. */
  45538. export class PBRAnisotropicConfiguration {
  45539. private _isEnabled;
  45540. /**
  45541. * Defines if the anisotropy is enabled in the material.
  45542. */
  45543. isEnabled: boolean;
  45544. /**
  45545. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45546. */
  45547. intensity: number;
  45548. /**
  45549. * Defines if the effect is along the tangents, bitangents or in between.
  45550. * By default, the effect is "strectching" the highlights along the tangents.
  45551. */
  45552. direction: Vector2;
  45553. private _texture;
  45554. /**
  45555. * Stores the anisotropy values in a texture.
  45556. * rg is direction (like normal from -1 to 1)
  45557. * b is a intensity
  45558. */
  45559. texture: Nullable<BaseTexture>;
  45560. /** @hidden */
  45561. private _internalMarkAllSubMeshesAsTexturesDirty;
  45562. /** @hidden */
  45563. _markAllSubMeshesAsTexturesDirty(): void;
  45564. /**
  45565. * Instantiate a new istance of anisotropy configuration.
  45566. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45567. */
  45568. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45569. /**
  45570. * Specifies that the submesh is ready to be used.
  45571. * @param defines the list of "defines" to update.
  45572. * @param scene defines the scene the material belongs to.
  45573. * @returns - boolean indicating that the submesh is ready or not.
  45574. */
  45575. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45576. /**
  45577. * Checks to see if a texture is used in the material.
  45578. * @param defines the list of "defines" to update.
  45579. * @param mesh the mesh we are preparing the defines for.
  45580. * @param scene defines the scene the material belongs to.
  45581. */
  45582. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45583. /**
  45584. * Binds the material data.
  45585. * @param uniformBuffer defines the Uniform buffer to fill in.
  45586. * @param scene defines the scene the material belongs to.
  45587. * @param isFrozen defines wether the material is frozen or not.
  45588. */
  45589. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45590. /**
  45591. * Checks to see if a texture is used in the material.
  45592. * @param texture - Base texture to use.
  45593. * @returns - Boolean specifying if a texture is used in the material.
  45594. */
  45595. hasTexture(texture: BaseTexture): boolean;
  45596. /**
  45597. * Returns an array of the actively used textures.
  45598. * @param activeTextures Array of BaseTextures
  45599. */
  45600. getActiveTextures(activeTextures: BaseTexture[]): void;
  45601. /**
  45602. * Returns the animatable textures.
  45603. * @param animatables Array of animatable textures.
  45604. */
  45605. getAnimatables(animatables: IAnimatable[]): void;
  45606. /**
  45607. * Disposes the resources of the material.
  45608. * @param forceDisposeTextures - Forces the disposal of all textures.
  45609. */
  45610. dispose(forceDisposeTextures?: boolean): void;
  45611. /**
  45612. * Get the current class name of the texture useful for serialization or dynamic coding.
  45613. * @returns "PBRAnisotropicConfiguration"
  45614. */
  45615. getClassName(): string;
  45616. /**
  45617. * Add fallbacks to the effect fallbacks list.
  45618. * @param defines defines the Base texture to use.
  45619. * @param fallbacks defines the current fallback list.
  45620. * @param currentRank defines the current fallback rank.
  45621. * @returns the new fallback rank.
  45622. */
  45623. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45624. /**
  45625. * Add the required uniforms to the current list.
  45626. * @param uniforms defines the current uniform list.
  45627. */
  45628. static AddUniforms(uniforms: string[]): void;
  45629. /**
  45630. * Add the required uniforms to the current buffer.
  45631. * @param uniformBuffer defines the current uniform buffer.
  45632. */
  45633. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45634. /**
  45635. * Add the required samplers to the current list.
  45636. * @param samplers defines the current sampler list.
  45637. */
  45638. static AddSamplers(samplers: string[]): void;
  45639. /**
  45640. * Makes a duplicate of the current configuration into another one.
  45641. * @param anisotropicConfiguration define the config where to copy the info
  45642. */
  45643. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45644. /**
  45645. * Serializes this anisotropy configuration.
  45646. * @returns - An object with the serialized config.
  45647. */
  45648. serialize(): any;
  45649. /**
  45650. * Parses a anisotropy Configuration from a serialized object.
  45651. * @param source - Serialized object.
  45652. */
  45653. parse(source: any): void;
  45654. }
  45655. }
  45656. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45657. /**
  45658. * @hidden
  45659. */
  45660. export interface IMaterialBRDFDefines {
  45661. BRDF_V_HEIGHT_CORRELATED: boolean;
  45662. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45663. /** @hidden */
  45664. _areMiscDirty: boolean;
  45665. }
  45666. /**
  45667. * Define the code related to the BRDF parameters of the pbr material.
  45668. */
  45669. export class PBRBRDFConfiguration {
  45670. /**
  45671. * Default value used for the energy conservation.
  45672. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45673. */
  45674. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45675. /**
  45676. * Default value used for the Smith Visibility Height Correlated mode.
  45677. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45678. */
  45679. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45680. private _useEnergyConservation;
  45681. /**
  45682. * Defines if the material uses energy conservation.
  45683. */
  45684. useEnergyConservation: boolean;
  45685. private _useSmithVisibilityHeightCorrelated;
  45686. /**
  45687. * LEGACY Mode set to false
  45688. * Defines if the material uses height smith correlated visibility term.
  45689. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45690. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45691. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45692. * Not relying on height correlated will also disable energy conservation.
  45693. */
  45694. useSmithVisibilityHeightCorrelated: boolean;
  45695. /** @hidden */
  45696. private _internalMarkAllSubMeshesAsMiscDirty;
  45697. /** @hidden */
  45698. _markAllSubMeshesAsMiscDirty(): void;
  45699. /**
  45700. * Instantiate a new istance of clear coat configuration.
  45701. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45702. */
  45703. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45704. /**
  45705. * Checks to see if a texture is used in the material.
  45706. * @param defines the list of "defines" to update.
  45707. */
  45708. prepareDefines(defines: IMaterialBRDFDefines): void;
  45709. /**
  45710. * Get the current class name of the texture useful for serialization or dynamic coding.
  45711. * @returns "PBRClearCoatConfiguration"
  45712. */
  45713. getClassName(): string;
  45714. /**
  45715. * Makes a duplicate of the current configuration into another one.
  45716. * @param brdfConfiguration define the config where to copy the info
  45717. */
  45718. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45719. /**
  45720. * Serializes this BRDF configuration.
  45721. * @returns - An object with the serialized config.
  45722. */
  45723. serialize(): any;
  45724. /**
  45725. * Parses a BRDF Configuration from a serialized object.
  45726. * @param source - Serialized object.
  45727. */
  45728. parse(source: any): void;
  45729. }
  45730. }
  45731. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45732. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45733. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45734. import { Color3 } from "babylonjs/Maths/math";
  45735. import { Scene } from "babylonjs/scene";
  45736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45737. import { IAnimatable } from "babylonjs/Misc/tools";
  45738. import { Nullable } from "babylonjs/types";
  45739. /**
  45740. * @hidden
  45741. */
  45742. export interface IMaterialSheenDefines {
  45743. SHEEN: boolean;
  45744. SHEEN_TEXTURE: boolean;
  45745. SHEEN_TEXTUREDIRECTUV: number;
  45746. SHEEN_LINKWITHALBEDO: boolean;
  45747. /** @hidden */
  45748. _areTexturesDirty: boolean;
  45749. }
  45750. /**
  45751. * Define the code related to the Sheen parameters of the pbr material.
  45752. */
  45753. export class PBRSheenConfiguration {
  45754. private _isEnabled;
  45755. /**
  45756. * Defines if the material uses sheen.
  45757. */
  45758. isEnabled: boolean;
  45759. private _linkSheenWithAlbedo;
  45760. /**
  45761. * Defines if the sheen is linked to the sheen color.
  45762. */
  45763. linkSheenWithAlbedo: boolean;
  45764. /**
  45765. * Defines the sheen intensity.
  45766. */
  45767. intensity: number;
  45768. /**
  45769. * Defines the sheen color.
  45770. */
  45771. color: Color3;
  45772. private _texture;
  45773. /**
  45774. * Stores the sheen tint values in a texture.
  45775. * rgb is tint
  45776. * a is a intensity
  45777. */
  45778. texture: Nullable<BaseTexture>;
  45779. /** @hidden */
  45780. private _internalMarkAllSubMeshesAsTexturesDirty;
  45781. /** @hidden */
  45782. _markAllSubMeshesAsTexturesDirty(): void;
  45783. /**
  45784. * Instantiate a new istance of clear coat configuration.
  45785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45786. */
  45787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45788. /**
  45789. * Specifies that the submesh is ready to be used.
  45790. * @param defines the list of "defines" to update.
  45791. * @param scene defines the scene the material belongs to.
  45792. * @returns - boolean indicating that the submesh is ready or not.
  45793. */
  45794. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45795. /**
  45796. * Checks to see if a texture is used in the material.
  45797. * @param defines the list of "defines" to update.
  45798. * @param scene defines the scene the material belongs to.
  45799. */
  45800. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45801. /**
  45802. * Binds the material data.
  45803. * @param uniformBuffer defines the Uniform buffer to fill in.
  45804. * @param scene defines the scene the material belongs to.
  45805. * @param isFrozen defines wether the material is frozen or not.
  45806. */
  45807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45808. /**
  45809. * Checks to see if a texture is used in the material.
  45810. * @param texture - Base texture to use.
  45811. * @returns - Boolean specifying if a texture is used in the material.
  45812. */
  45813. hasTexture(texture: BaseTexture): boolean;
  45814. /**
  45815. * Returns an array of the actively used textures.
  45816. * @param activeTextures Array of BaseTextures
  45817. */
  45818. getActiveTextures(activeTextures: BaseTexture[]): void;
  45819. /**
  45820. * Returns the animatable textures.
  45821. * @param animatables Array of animatable textures.
  45822. */
  45823. getAnimatables(animatables: IAnimatable[]): void;
  45824. /**
  45825. * Disposes the resources of the material.
  45826. * @param forceDisposeTextures - Forces the disposal of all textures.
  45827. */
  45828. dispose(forceDisposeTextures?: boolean): void;
  45829. /**
  45830. * Get the current class name of the texture useful for serialization or dynamic coding.
  45831. * @returns "PBRSheenConfiguration"
  45832. */
  45833. getClassName(): string;
  45834. /**
  45835. * Add fallbacks to the effect fallbacks list.
  45836. * @param defines defines the Base texture to use.
  45837. * @param fallbacks defines the current fallback list.
  45838. * @param currentRank defines the current fallback rank.
  45839. * @returns the new fallback rank.
  45840. */
  45841. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45842. /**
  45843. * Add the required uniforms to the current list.
  45844. * @param uniforms defines the current uniform list.
  45845. */
  45846. static AddUniforms(uniforms: string[]): void;
  45847. /**
  45848. * Add the required uniforms to the current buffer.
  45849. * @param uniformBuffer defines the current uniform buffer.
  45850. */
  45851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45852. /**
  45853. * Add the required samplers to the current list.
  45854. * @param samplers defines the current sampler list.
  45855. */
  45856. static AddSamplers(samplers: string[]): void;
  45857. /**
  45858. * Makes a duplicate of the current configuration into another one.
  45859. * @param sheenConfiguration define the config where to copy the info
  45860. */
  45861. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45862. /**
  45863. * Serializes this BRDF configuration.
  45864. * @returns - An object with the serialized config.
  45865. */
  45866. serialize(): any;
  45867. /**
  45868. * Parses a Sheen Configuration from a serialized object.
  45869. * @param source - Serialized object.
  45870. */
  45871. parse(source: any): void;
  45872. }
  45873. }
  45874. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45875. import { Nullable } from "babylonjs/types";
  45876. import { IAnimatable } from "babylonjs/Misc/tools";
  45877. import { Color3 } from "babylonjs/Maths/math";
  45878. import { SmartArray } from "babylonjs/Misc/smartArray";
  45879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45881. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45882. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45883. import { Engine } from "babylonjs/Engines/engine";
  45884. import { Scene } from "babylonjs/scene";
  45885. /**
  45886. * @hidden
  45887. */
  45888. export interface IMaterialSubSurfaceDefines {
  45889. SUBSURFACE: boolean;
  45890. SS_REFRACTION: boolean;
  45891. SS_TRANSLUCENCY: boolean;
  45892. SS_SCATERRING: boolean;
  45893. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45894. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45895. SS_REFRACTIONMAP_3D: boolean;
  45896. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45897. SS_LODINREFRACTIONALPHA: boolean;
  45898. SS_GAMMAREFRACTION: boolean;
  45899. SS_RGBDREFRACTION: boolean;
  45900. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45901. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45902. /** @hidden */
  45903. _areTexturesDirty: boolean;
  45904. }
  45905. /**
  45906. * Define the code related to the sub surface parameters of the pbr material.
  45907. */
  45908. export class PBRSubSurfaceConfiguration {
  45909. private _isRefractionEnabled;
  45910. /**
  45911. * Defines if the refraction is enabled in the material.
  45912. */
  45913. isRefractionEnabled: boolean;
  45914. private _isTranslucencyEnabled;
  45915. /**
  45916. * Defines if the translucency is enabled in the material.
  45917. */
  45918. isTranslucencyEnabled: boolean;
  45919. private _isScatteringEnabled;
  45920. /**
  45921. * Defines the refraction intensity of the material.
  45922. * The refraction when enabled replaces the Diffuse part of the material.
  45923. * The intensity helps transitionning between diffuse and refraction.
  45924. */
  45925. refractionIntensity: number;
  45926. /**
  45927. * Defines the translucency intensity of the material.
  45928. * When translucency has been enabled, this defines how much of the "translucency"
  45929. * is addded to the diffuse part of the material.
  45930. */
  45931. translucencyIntensity: number;
  45932. /**
  45933. * Defines the scattering intensity of the material.
  45934. * When scattering has been enabled, this defines how much of the "scattered light"
  45935. * is addded to the diffuse part of the material.
  45936. */
  45937. scatteringIntensity: number;
  45938. private _thicknessTexture;
  45939. /**
  45940. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45941. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45942. * 0 would mean minimumThickness
  45943. * 1 would mean maximumThickness
  45944. * The other channels might be use as a mask to vary the different effects intensity.
  45945. */
  45946. thicknessTexture: Nullable<BaseTexture>;
  45947. private _refractionTexture;
  45948. /**
  45949. * Defines the texture to use for refraction.
  45950. */
  45951. refractionTexture: Nullable<BaseTexture>;
  45952. private _indexOfRefraction;
  45953. /**
  45954. * Defines the indice of refraction used in the material.
  45955. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45956. */
  45957. indexOfRefraction: number;
  45958. private _invertRefractionY;
  45959. /**
  45960. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45961. */
  45962. invertRefractionY: boolean;
  45963. private _linkRefractionWithTransparency;
  45964. /**
  45965. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45966. * Materials half opaque for instance using refraction could benefit from this control.
  45967. */
  45968. linkRefractionWithTransparency: boolean;
  45969. /**
  45970. * Defines the minimum thickness stored in the thickness map.
  45971. * If no thickness map is defined, this value will be used to simulate thickness.
  45972. */
  45973. minimumThickness: number;
  45974. /**
  45975. * Defines the maximum thickness stored in the thickness map.
  45976. */
  45977. maximumThickness: number;
  45978. /**
  45979. * Defines the volume tint of the material.
  45980. * This is used for both translucency and scattering.
  45981. */
  45982. tintColor: Color3;
  45983. /**
  45984. * Defines the distance at which the tint color should be found in the media.
  45985. * This is used for refraction only.
  45986. */
  45987. tintColorAtDistance: number;
  45988. /**
  45989. * Defines how far each channel transmit through the media.
  45990. * It is defined as a color to simplify it selection.
  45991. */
  45992. diffusionDistance: Color3;
  45993. private _useMaskFromThicknessTexture;
  45994. /**
  45995. * Stores the intensity of the different subsurface effects in the thickness texture.
  45996. * * the green channel is the translucency intensity.
  45997. * * the blue channel is the scattering intensity.
  45998. * * the alpha channel is the refraction intensity.
  45999. */
  46000. useMaskFromThicknessTexture: boolean;
  46001. /** @hidden */
  46002. private _internalMarkAllSubMeshesAsTexturesDirty;
  46003. /** @hidden */
  46004. _markAllSubMeshesAsTexturesDirty(): void;
  46005. /**
  46006. * Instantiate a new istance of sub surface configuration.
  46007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46008. */
  46009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46010. /**
  46011. * Gets wehter the submesh is ready to be used or not.
  46012. * @param defines the list of "defines" to update.
  46013. * @param scene defines the scene the material belongs to.
  46014. * @returns - boolean indicating that the submesh is ready or not.
  46015. */
  46016. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46017. /**
  46018. * Checks to see if a texture is used in the material.
  46019. * @param defines the list of "defines" to update.
  46020. * @param scene defines the scene to the material belongs to.
  46021. */
  46022. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46023. /**
  46024. * Binds the material data.
  46025. * @param uniformBuffer defines the Uniform buffer to fill in.
  46026. * @param scene defines the scene the material belongs to.
  46027. * @param engine defines the engine the material belongs to.
  46028. * @param isFrozen defines wether the material is frozen or not.
  46029. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46030. */
  46031. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46032. /**
  46033. * Unbinds the material from the mesh.
  46034. * @param activeEffect defines the effect that should be unbound from.
  46035. * @returns true if unbound, otherwise false
  46036. */
  46037. unbind(activeEffect: Effect): boolean;
  46038. /**
  46039. * Returns the texture used for refraction or null if none is used.
  46040. * @param scene defines the scene the material belongs to.
  46041. * @returns - Refraction texture if present. If no refraction texture and refraction
  46042. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46043. */
  46044. private _getRefractionTexture;
  46045. /**
  46046. * Returns true if alpha blending should be disabled.
  46047. */
  46048. readonly disableAlphaBlending: boolean;
  46049. /**
  46050. * Fills the list of render target textures.
  46051. * @param renderTargets the list of render targets to update
  46052. */
  46053. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46054. /**
  46055. * Checks to see if a texture is used in the material.
  46056. * @param texture - Base texture to use.
  46057. * @returns - Boolean specifying if a texture is used in the material.
  46058. */
  46059. hasTexture(texture: BaseTexture): boolean;
  46060. /**
  46061. * Gets a boolean indicating that current material needs to register RTT
  46062. * @returns true if this uses a render target otherwise false.
  46063. */
  46064. hasRenderTargetTextures(): boolean;
  46065. /**
  46066. * Returns an array of the actively used textures.
  46067. * @param activeTextures Array of BaseTextures
  46068. */
  46069. getActiveTextures(activeTextures: BaseTexture[]): void;
  46070. /**
  46071. * Returns the animatable textures.
  46072. * @param animatables Array of animatable textures.
  46073. */
  46074. getAnimatables(animatables: IAnimatable[]): void;
  46075. /**
  46076. * Disposes the resources of the material.
  46077. * @param forceDisposeTextures - Forces the disposal of all textures.
  46078. */
  46079. dispose(forceDisposeTextures?: boolean): void;
  46080. /**
  46081. * Get the current class name of the texture useful for serialization or dynamic coding.
  46082. * @returns "PBRSubSurfaceConfiguration"
  46083. */
  46084. getClassName(): string;
  46085. /**
  46086. * Add fallbacks to the effect fallbacks list.
  46087. * @param defines defines the Base texture to use.
  46088. * @param fallbacks defines the current fallback list.
  46089. * @param currentRank defines the current fallback rank.
  46090. * @returns the new fallback rank.
  46091. */
  46092. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46093. /**
  46094. * Add the required uniforms to the current list.
  46095. * @param uniforms defines the current uniform list.
  46096. */
  46097. static AddUniforms(uniforms: string[]): void;
  46098. /**
  46099. * Add the required samplers to the current list.
  46100. * @param samplers defines the current sampler list.
  46101. */
  46102. static AddSamplers(samplers: string[]): void;
  46103. /**
  46104. * Add the required uniforms to the current buffer.
  46105. * @param uniformBuffer defines the current uniform buffer.
  46106. */
  46107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46108. /**
  46109. * Makes a duplicate of the current configuration into another one.
  46110. * @param configuration define the config where to copy the info
  46111. */
  46112. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46113. /**
  46114. * Serializes this Sub Surface configuration.
  46115. * @returns - An object with the serialized config.
  46116. */
  46117. serialize(): any;
  46118. /**
  46119. * Parses a Sub Surface Configuration from a serialized object.
  46120. * @param source - Serialized object.
  46121. */
  46122. parse(source: any): void;
  46123. }
  46124. }
  46125. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46126. /** @hidden */
  46127. export var pbrFragmentDeclaration: {
  46128. name: string;
  46129. shader: string;
  46130. };
  46131. }
  46132. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46133. /** @hidden */
  46134. export var pbrUboDeclaration: {
  46135. name: string;
  46136. shader: string;
  46137. };
  46138. }
  46139. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46140. /** @hidden */
  46141. export var pbrFragmentExtraDeclaration: {
  46142. name: string;
  46143. shader: string;
  46144. };
  46145. }
  46146. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46147. /** @hidden */
  46148. export var pbrFragmentSamplersDeclaration: {
  46149. name: string;
  46150. shader: string;
  46151. };
  46152. }
  46153. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46154. /** @hidden */
  46155. export var pbrHelperFunctions: {
  46156. name: string;
  46157. shader: string;
  46158. };
  46159. }
  46160. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46161. /** @hidden */
  46162. export var harmonicsFunctions: {
  46163. name: string;
  46164. shader: string;
  46165. };
  46166. }
  46167. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46168. /** @hidden */
  46169. export var pbrDirectLightingSetupFunctions: {
  46170. name: string;
  46171. shader: string;
  46172. };
  46173. }
  46174. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46175. /** @hidden */
  46176. export var pbrDirectLightingFalloffFunctions: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46182. /** @hidden */
  46183. export var pbrBRDFFunctions: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46189. /** @hidden */
  46190. export var pbrDirectLightingFunctions: {
  46191. name: string;
  46192. shader: string;
  46193. };
  46194. }
  46195. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46196. /** @hidden */
  46197. export var pbrIBLFunctions: {
  46198. name: string;
  46199. shader: string;
  46200. };
  46201. }
  46202. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46203. /** @hidden */
  46204. export var pbrDebug: {
  46205. name: string;
  46206. shader: string;
  46207. };
  46208. }
  46209. declare module "babylonjs/Shaders/pbr.fragment" {
  46210. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46211. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46212. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46213. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46214. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46215. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46216. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46218. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46219. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46221. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46222. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46223. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46224. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46225. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46226. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46227. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46228. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46229. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46230. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46231. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46232. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46233. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46234. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46235. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46236. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46237. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46238. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46239. /** @hidden */
  46240. export var pbrPixelShader: {
  46241. name: string;
  46242. shader: string;
  46243. };
  46244. }
  46245. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46246. /** @hidden */
  46247. export var pbrVertexDeclaration: {
  46248. name: string;
  46249. shader: string;
  46250. };
  46251. }
  46252. declare module "babylonjs/Shaders/pbr.vertex" {
  46253. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46254. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46255. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46256. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46257. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46258. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46259. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46260. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46261. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46262. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46263. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46264. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46266. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46267. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46268. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46269. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46270. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46271. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46272. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46273. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46274. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46275. /** @hidden */
  46276. export var pbrVertexShader: {
  46277. name: string;
  46278. shader: string;
  46279. };
  46280. }
  46281. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46282. import { IAnimatable } from "babylonjs/Misc/tools";
  46283. import { Nullable } from "babylonjs/types";
  46284. import { Scene } from "babylonjs/scene";
  46285. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46286. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46288. import { Mesh } from "babylonjs/Meshes/mesh";
  46289. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46290. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46291. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46292. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46293. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46294. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46295. import { Material } from "babylonjs/Materials/material";
  46296. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46297. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46299. import "babylonjs/Shaders/pbr.fragment";
  46300. import "babylonjs/Shaders/pbr.vertex";
  46301. /**
  46302. * Manages the defines for the PBR Material.
  46303. * @hidden
  46304. */
  46305. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46306. PBR: boolean;
  46307. MAINUV1: boolean;
  46308. MAINUV2: boolean;
  46309. UV1: boolean;
  46310. UV2: boolean;
  46311. ALBEDO: boolean;
  46312. ALBEDODIRECTUV: number;
  46313. VERTEXCOLOR: boolean;
  46314. AMBIENT: boolean;
  46315. AMBIENTDIRECTUV: number;
  46316. AMBIENTINGRAYSCALE: boolean;
  46317. OPACITY: boolean;
  46318. VERTEXALPHA: boolean;
  46319. OPACITYDIRECTUV: number;
  46320. OPACITYRGB: boolean;
  46321. ALPHATEST: boolean;
  46322. DEPTHPREPASS: boolean;
  46323. ALPHABLEND: boolean;
  46324. ALPHAFROMALBEDO: boolean;
  46325. ALPHATESTVALUE: string;
  46326. SPECULAROVERALPHA: boolean;
  46327. RADIANCEOVERALPHA: boolean;
  46328. ALPHAFRESNEL: boolean;
  46329. LINEARALPHAFRESNEL: boolean;
  46330. PREMULTIPLYALPHA: boolean;
  46331. EMISSIVE: boolean;
  46332. EMISSIVEDIRECTUV: number;
  46333. REFLECTIVITY: boolean;
  46334. REFLECTIVITYDIRECTUV: number;
  46335. SPECULARTERM: boolean;
  46336. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46337. MICROSURFACEAUTOMATIC: boolean;
  46338. LODBASEDMICROSFURACE: boolean;
  46339. MICROSURFACEMAP: boolean;
  46340. MICROSURFACEMAPDIRECTUV: number;
  46341. METALLICWORKFLOW: boolean;
  46342. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46343. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46344. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46345. AOSTOREINMETALMAPRED: boolean;
  46346. ENVIRONMENTBRDF: boolean;
  46347. ENVIRONMENTBRDF_RGBD: boolean;
  46348. NORMAL: boolean;
  46349. TANGENT: boolean;
  46350. BUMP: boolean;
  46351. BUMPDIRECTUV: number;
  46352. OBJECTSPACE_NORMALMAP: boolean;
  46353. PARALLAX: boolean;
  46354. PARALLAXOCCLUSION: boolean;
  46355. NORMALXYSCALE: boolean;
  46356. LIGHTMAP: boolean;
  46357. LIGHTMAPDIRECTUV: number;
  46358. USELIGHTMAPASSHADOWMAP: boolean;
  46359. GAMMALIGHTMAP: boolean;
  46360. REFLECTION: boolean;
  46361. REFLECTIONMAP_3D: boolean;
  46362. REFLECTIONMAP_SPHERICAL: boolean;
  46363. REFLECTIONMAP_PLANAR: boolean;
  46364. REFLECTIONMAP_CUBIC: boolean;
  46365. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46366. REFLECTIONMAP_PROJECTION: boolean;
  46367. REFLECTIONMAP_SKYBOX: boolean;
  46368. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46369. REFLECTIONMAP_EXPLICIT: boolean;
  46370. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46371. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46372. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46373. INVERTCUBICMAP: boolean;
  46374. USESPHERICALFROMREFLECTIONMAP: boolean;
  46375. USESPHERICALINVERTEX: boolean;
  46376. REFLECTIONMAP_OPPOSITEZ: boolean;
  46377. LODINREFLECTIONALPHA: boolean;
  46378. GAMMAREFLECTION: boolean;
  46379. RGBDREFLECTION: boolean;
  46380. RADIANCEOCCLUSION: boolean;
  46381. HORIZONOCCLUSION: boolean;
  46382. INSTANCES: boolean;
  46383. NUM_BONE_INFLUENCERS: number;
  46384. BonesPerMesh: number;
  46385. BONETEXTURE: boolean;
  46386. NONUNIFORMSCALING: boolean;
  46387. MORPHTARGETS: boolean;
  46388. MORPHTARGETS_NORMAL: boolean;
  46389. MORPHTARGETS_TANGENT: boolean;
  46390. NUM_MORPH_INFLUENCERS: number;
  46391. IMAGEPROCESSING: boolean;
  46392. VIGNETTE: boolean;
  46393. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46394. VIGNETTEBLENDMODEOPAQUE: boolean;
  46395. TONEMAPPING: boolean;
  46396. TONEMAPPING_ACES: boolean;
  46397. CONTRAST: boolean;
  46398. COLORCURVES: boolean;
  46399. COLORGRADING: boolean;
  46400. COLORGRADING3D: boolean;
  46401. SAMPLER3DGREENDEPTH: boolean;
  46402. SAMPLER3DBGRMAP: boolean;
  46403. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46404. EXPOSURE: boolean;
  46405. MULTIVIEW: boolean;
  46406. USEPHYSICALLIGHTFALLOFF: boolean;
  46407. USEGLTFLIGHTFALLOFF: boolean;
  46408. TWOSIDEDLIGHTING: boolean;
  46409. SHADOWFLOAT: boolean;
  46410. CLIPPLANE: boolean;
  46411. CLIPPLANE2: boolean;
  46412. CLIPPLANE3: boolean;
  46413. CLIPPLANE4: boolean;
  46414. POINTSIZE: boolean;
  46415. FOG: boolean;
  46416. LOGARITHMICDEPTH: boolean;
  46417. FORCENORMALFORWARD: boolean;
  46418. SPECULARAA: boolean;
  46419. CLEARCOAT: boolean;
  46420. CLEARCOAT_DEFAULTIOR: boolean;
  46421. CLEARCOAT_TEXTURE: boolean;
  46422. CLEARCOAT_TEXTUREDIRECTUV: number;
  46423. CLEARCOAT_BUMP: boolean;
  46424. CLEARCOAT_BUMPDIRECTUV: number;
  46425. CLEARCOAT_TINT: boolean;
  46426. CLEARCOAT_TINT_TEXTURE: boolean;
  46427. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46428. ANISOTROPIC: boolean;
  46429. ANISOTROPIC_TEXTURE: boolean;
  46430. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46431. BRDF_V_HEIGHT_CORRELATED: boolean;
  46432. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46433. SHEEN: boolean;
  46434. SHEEN_TEXTURE: boolean;
  46435. SHEEN_TEXTUREDIRECTUV: number;
  46436. SHEEN_LINKWITHALBEDO: boolean;
  46437. SUBSURFACE: boolean;
  46438. SS_REFRACTION: boolean;
  46439. SS_TRANSLUCENCY: boolean;
  46440. SS_SCATERRING: boolean;
  46441. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46442. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46443. SS_REFRACTIONMAP_3D: boolean;
  46444. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46445. SS_LODINREFRACTIONALPHA: boolean;
  46446. SS_GAMMAREFRACTION: boolean;
  46447. SS_RGBDREFRACTION: boolean;
  46448. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46449. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46450. UNLIT: boolean;
  46451. DEBUGMODE: number;
  46452. /**
  46453. * Initializes the PBR Material defines.
  46454. */
  46455. constructor();
  46456. /**
  46457. * Resets the PBR Material defines.
  46458. */
  46459. reset(): void;
  46460. }
  46461. /**
  46462. * The Physically based material base class of BJS.
  46463. *
  46464. * This offers the main features of a standard PBR material.
  46465. * For more information, please refer to the documentation :
  46466. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46467. */
  46468. export abstract class PBRBaseMaterial extends PushMaterial {
  46469. /**
  46470. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46471. */
  46472. static readonly PBRMATERIAL_OPAQUE: number;
  46473. /**
  46474. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46475. */
  46476. static readonly PBRMATERIAL_ALPHATEST: number;
  46477. /**
  46478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46479. */
  46480. static readonly PBRMATERIAL_ALPHABLEND: number;
  46481. /**
  46482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46483. * They are also discarded below the alpha cutoff threshold to improve performances.
  46484. */
  46485. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46486. /**
  46487. * Defines the default value of how much AO map is occluding the analytical lights
  46488. * (point spot...).
  46489. */
  46490. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46491. /**
  46492. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46493. */
  46494. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46495. /**
  46496. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46497. * to enhance interoperability with other engines.
  46498. */
  46499. static readonly LIGHTFALLOFF_GLTF: number;
  46500. /**
  46501. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46502. * to enhance interoperability with other materials.
  46503. */
  46504. static readonly LIGHTFALLOFF_STANDARD: number;
  46505. /**
  46506. * Intensity of the direct lights e.g. the four lights available in your scene.
  46507. * This impacts both the direct diffuse and specular highlights.
  46508. */
  46509. protected _directIntensity: number;
  46510. /**
  46511. * Intensity of the emissive part of the material.
  46512. * This helps controlling the emissive effect without modifying the emissive color.
  46513. */
  46514. protected _emissiveIntensity: number;
  46515. /**
  46516. * Intensity of the environment e.g. how much the environment will light the object
  46517. * either through harmonics for rough material or through the refelction for shiny ones.
  46518. */
  46519. protected _environmentIntensity: number;
  46520. /**
  46521. * This is a special control allowing the reduction of the specular highlights coming from the
  46522. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46523. */
  46524. protected _specularIntensity: number;
  46525. /**
  46526. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46527. */
  46528. private _lightingInfos;
  46529. /**
  46530. * Debug Control allowing disabling the bump map on this material.
  46531. */
  46532. protected _disableBumpMap: boolean;
  46533. /**
  46534. * AKA Diffuse Texture in standard nomenclature.
  46535. */
  46536. protected _albedoTexture: BaseTexture;
  46537. /**
  46538. * AKA Occlusion Texture in other nomenclature.
  46539. */
  46540. protected _ambientTexture: BaseTexture;
  46541. /**
  46542. * AKA Occlusion Texture Intensity in other nomenclature.
  46543. */
  46544. protected _ambientTextureStrength: number;
  46545. /**
  46546. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46547. * 1 means it completely occludes it
  46548. * 0 mean it has no impact
  46549. */
  46550. protected _ambientTextureImpactOnAnalyticalLights: number;
  46551. /**
  46552. * Stores the alpha values in a texture.
  46553. */
  46554. protected _opacityTexture: BaseTexture;
  46555. /**
  46556. * Stores the reflection values in a texture.
  46557. */
  46558. protected _reflectionTexture: BaseTexture;
  46559. /**
  46560. * Stores the emissive values in a texture.
  46561. */
  46562. protected _emissiveTexture: BaseTexture;
  46563. /**
  46564. * AKA Specular texture in other nomenclature.
  46565. */
  46566. protected _reflectivityTexture: BaseTexture;
  46567. /**
  46568. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46569. */
  46570. protected _metallicTexture: BaseTexture;
  46571. /**
  46572. * Specifies the metallic scalar of the metallic/roughness workflow.
  46573. * Can also be used to scale the metalness values of the metallic texture.
  46574. */
  46575. protected _metallic: Nullable<number>;
  46576. /**
  46577. * Specifies the roughness scalar of the metallic/roughness workflow.
  46578. * Can also be used to scale the roughness values of the metallic texture.
  46579. */
  46580. protected _roughness: Nullable<number>;
  46581. /**
  46582. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46583. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46584. */
  46585. protected _microSurfaceTexture: BaseTexture;
  46586. /**
  46587. * Stores surface normal data used to displace a mesh in a texture.
  46588. */
  46589. protected _bumpTexture: BaseTexture;
  46590. /**
  46591. * Stores the pre-calculated light information of a mesh in a texture.
  46592. */
  46593. protected _lightmapTexture: BaseTexture;
  46594. /**
  46595. * The color of a material in ambient lighting.
  46596. */
  46597. protected _ambientColor: Color3;
  46598. /**
  46599. * AKA Diffuse Color in other nomenclature.
  46600. */
  46601. protected _albedoColor: Color3;
  46602. /**
  46603. * AKA Specular Color in other nomenclature.
  46604. */
  46605. protected _reflectivityColor: Color3;
  46606. /**
  46607. * The color applied when light is reflected from a material.
  46608. */
  46609. protected _reflectionColor: Color3;
  46610. /**
  46611. * The color applied when light is emitted from a material.
  46612. */
  46613. protected _emissiveColor: Color3;
  46614. /**
  46615. * AKA Glossiness in other nomenclature.
  46616. */
  46617. protected _microSurface: number;
  46618. /**
  46619. * Specifies that the material will use the light map as a show map.
  46620. */
  46621. protected _useLightmapAsShadowmap: boolean;
  46622. /**
  46623. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46624. * makes the reflect vector face the model (under horizon).
  46625. */
  46626. protected _useHorizonOcclusion: boolean;
  46627. /**
  46628. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46629. * too much the area relying on ambient texture to define their ambient occlusion.
  46630. */
  46631. protected _useRadianceOcclusion: boolean;
  46632. /**
  46633. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46634. */
  46635. protected _useAlphaFromAlbedoTexture: boolean;
  46636. /**
  46637. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46638. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46639. */
  46640. protected _useSpecularOverAlpha: boolean;
  46641. /**
  46642. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46643. */
  46644. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46645. /**
  46646. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46647. */
  46648. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46649. /**
  46650. * Specifies if the metallic texture contains the roughness information in its green channel.
  46651. */
  46652. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46653. /**
  46654. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46655. */
  46656. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46657. /**
  46658. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46659. */
  46660. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46661. /**
  46662. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46663. */
  46664. protected _useAmbientInGrayScale: boolean;
  46665. /**
  46666. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46667. * The material will try to infer what glossiness each pixel should be.
  46668. */
  46669. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46670. /**
  46671. * Defines the falloff type used in this material.
  46672. * It by default is Physical.
  46673. */
  46674. protected _lightFalloff: number;
  46675. /**
  46676. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46677. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46678. */
  46679. protected _useRadianceOverAlpha: boolean;
  46680. /**
  46681. * Allows using an object space normal map (instead of tangent space).
  46682. */
  46683. protected _useObjectSpaceNormalMap: boolean;
  46684. /**
  46685. * Allows using the bump map in parallax mode.
  46686. */
  46687. protected _useParallax: boolean;
  46688. /**
  46689. * Allows using the bump map in parallax occlusion mode.
  46690. */
  46691. protected _useParallaxOcclusion: boolean;
  46692. /**
  46693. * Controls the scale bias of the parallax mode.
  46694. */
  46695. protected _parallaxScaleBias: number;
  46696. /**
  46697. * If sets to true, disables all the lights affecting the material.
  46698. */
  46699. protected _disableLighting: boolean;
  46700. /**
  46701. * Number of Simultaneous lights allowed on the material.
  46702. */
  46703. protected _maxSimultaneousLights: number;
  46704. /**
  46705. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46706. */
  46707. protected _invertNormalMapX: boolean;
  46708. /**
  46709. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46710. */
  46711. protected _invertNormalMapY: boolean;
  46712. /**
  46713. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46714. */
  46715. protected _twoSidedLighting: boolean;
  46716. /**
  46717. * Defines the alpha limits in alpha test mode.
  46718. */
  46719. protected _alphaCutOff: number;
  46720. /**
  46721. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46722. */
  46723. protected _forceAlphaTest: boolean;
  46724. /**
  46725. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46726. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46727. */
  46728. protected _useAlphaFresnel: boolean;
  46729. /**
  46730. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46731. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46732. */
  46733. protected _useLinearAlphaFresnel: boolean;
  46734. /**
  46735. * The transparency mode of the material.
  46736. */
  46737. protected _transparencyMode: Nullable<number>;
  46738. /**
  46739. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46740. * from cos thetav and roughness:
  46741. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46742. */
  46743. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46744. /**
  46745. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46746. */
  46747. protected _forceIrradianceInFragment: boolean;
  46748. /**
  46749. * Force normal to face away from face.
  46750. */
  46751. protected _forceNormalForward: boolean;
  46752. /**
  46753. * Enables specular anti aliasing in the PBR shader.
  46754. * It will both interacts on the Geometry for analytical and IBL lighting.
  46755. * It also prefilter the roughness map based on the bump values.
  46756. */
  46757. protected _enableSpecularAntiAliasing: boolean;
  46758. /**
  46759. * Default configuration related to image processing available in the PBR Material.
  46760. */
  46761. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46762. /**
  46763. * Keep track of the image processing observer to allow dispose and replace.
  46764. */
  46765. private _imageProcessingObserver;
  46766. /**
  46767. * Attaches a new image processing configuration to the PBR Material.
  46768. * @param configuration
  46769. */
  46770. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46771. /**
  46772. * Stores the available render targets.
  46773. */
  46774. private _renderTargets;
  46775. /**
  46776. * Sets the global ambient color for the material used in lighting calculations.
  46777. */
  46778. private _globalAmbientColor;
  46779. /**
  46780. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46781. */
  46782. private _useLogarithmicDepth;
  46783. /**
  46784. * If set to true, no lighting calculations will be applied.
  46785. */
  46786. private _unlit;
  46787. private _debugMode;
  46788. /**
  46789. * @hidden
  46790. * This is reserved for the inspector.
  46791. * Defines the material debug mode.
  46792. * It helps seeing only some components of the material while troubleshooting.
  46793. */
  46794. debugMode: number;
  46795. /**
  46796. * @hidden
  46797. * This is reserved for the inspector.
  46798. * Specify from where on screen the debug mode should start.
  46799. * The value goes from -1 (full screen) to 1 (not visible)
  46800. * It helps with side by side comparison against the final render
  46801. * This defaults to -1
  46802. */
  46803. private debugLimit;
  46804. /**
  46805. * @hidden
  46806. * This is reserved for the inspector.
  46807. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46808. * You can use the factor to better multiply the final value.
  46809. */
  46810. private debugFactor;
  46811. /**
  46812. * Defines the clear coat layer parameters for the material.
  46813. */
  46814. readonly clearCoat: PBRClearCoatConfiguration;
  46815. /**
  46816. * Defines the anisotropic parameters for the material.
  46817. */
  46818. readonly anisotropy: PBRAnisotropicConfiguration;
  46819. /**
  46820. * Defines the BRDF parameters for the material.
  46821. */
  46822. readonly brdf: PBRBRDFConfiguration;
  46823. /**
  46824. * Defines the Sheen parameters for the material.
  46825. */
  46826. readonly sheen: PBRSheenConfiguration;
  46827. /**
  46828. * Defines the SubSurface parameters for the material.
  46829. */
  46830. readonly subSurface: PBRSubSurfaceConfiguration;
  46831. /**
  46832. * Custom callback helping to override the default shader used in the material.
  46833. */
  46834. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46835. /**
  46836. * Instantiates a new PBRMaterial instance.
  46837. *
  46838. * @param name The material name
  46839. * @param scene The scene the material will be use in.
  46840. */
  46841. constructor(name: string, scene: Scene);
  46842. /**
  46843. * Gets a boolean indicating that current material needs to register RTT
  46844. */
  46845. readonly hasRenderTargetTextures: boolean;
  46846. /**
  46847. * Gets the name of the material class.
  46848. */
  46849. getClassName(): string;
  46850. /**
  46851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46852. */
  46853. /**
  46854. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46855. */
  46856. useLogarithmicDepth: boolean;
  46857. /**
  46858. * Gets the current transparency mode.
  46859. */
  46860. /**
  46861. * Sets the transparency mode of the material.
  46862. *
  46863. * | Value | Type | Description |
  46864. * | ----- | ----------------------------------- | ----------- |
  46865. * | 0 | OPAQUE | |
  46866. * | 1 | ALPHATEST | |
  46867. * | 2 | ALPHABLEND | |
  46868. * | 3 | ALPHATESTANDBLEND | |
  46869. *
  46870. */
  46871. transparencyMode: Nullable<number>;
  46872. /**
  46873. * Returns true if alpha blending should be disabled.
  46874. */
  46875. private readonly _disableAlphaBlending;
  46876. /**
  46877. * Specifies whether or not this material should be rendered in alpha blend mode.
  46878. */
  46879. needAlphaBlending(): boolean;
  46880. /**
  46881. * Specifies if the mesh will require alpha blending.
  46882. * @param mesh - BJS mesh.
  46883. */
  46884. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46885. /**
  46886. * Specifies whether or not this material should be rendered in alpha test mode.
  46887. */
  46888. needAlphaTesting(): boolean;
  46889. /**
  46890. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46891. */
  46892. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46893. /**
  46894. * Gets the texture used for the alpha test.
  46895. */
  46896. getAlphaTestTexture(): BaseTexture;
  46897. /**
  46898. * Specifies that the submesh is ready to be used.
  46899. * @param mesh - BJS mesh.
  46900. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46901. * @param useInstances - Specifies that instances should be used.
  46902. * @returns - boolean indicating that the submesh is ready or not.
  46903. */
  46904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46905. /**
  46906. * Specifies if the material uses metallic roughness workflow.
  46907. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46908. */
  46909. isMetallicWorkflow(): boolean;
  46910. private _prepareEffect;
  46911. private _prepareDefines;
  46912. /**
  46913. * Force shader compilation
  46914. */
  46915. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46916. clipPlane: boolean;
  46917. }>): void;
  46918. /**
  46919. * Initializes the uniform buffer layout for the shader.
  46920. */
  46921. buildUniformLayout(): void;
  46922. /**
  46923. * Unbinds the material from the mesh
  46924. */
  46925. unbind(): void;
  46926. /**
  46927. * Binds the submesh data.
  46928. * @param world - The world matrix.
  46929. * @param mesh - The BJS mesh.
  46930. * @param subMesh - A submesh of the BJS mesh.
  46931. */
  46932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46933. /**
  46934. * Returns the animatable textures.
  46935. * @returns - Array of animatable textures.
  46936. */
  46937. getAnimatables(): IAnimatable[];
  46938. /**
  46939. * Returns the texture used for reflections.
  46940. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46941. */
  46942. private _getReflectionTexture;
  46943. /**
  46944. * Returns an array of the actively used textures.
  46945. * @returns - Array of BaseTextures
  46946. */
  46947. getActiveTextures(): BaseTexture[];
  46948. /**
  46949. * Checks to see if a texture is used in the material.
  46950. * @param texture - Base texture to use.
  46951. * @returns - Boolean specifying if a texture is used in the material.
  46952. */
  46953. hasTexture(texture: BaseTexture): boolean;
  46954. /**
  46955. * Disposes the resources of the material.
  46956. * @param forceDisposeEffect - Forces the disposal of effects.
  46957. * @param forceDisposeTextures - Forces the disposal of all textures.
  46958. */
  46959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46960. }
  46961. }
  46962. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46963. import { Nullable } from "babylonjs/types";
  46964. import { Scene } from "babylonjs/scene";
  46965. import { Color3 } from "babylonjs/Maths/math";
  46966. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46967. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46969. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46970. /**
  46971. * The Physically based material of BJS.
  46972. *
  46973. * This offers the main features of a standard PBR material.
  46974. * For more information, please refer to the documentation :
  46975. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46976. */
  46977. export class PBRMaterial extends PBRBaseMaterial {
  46978. /**
  46979. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46980. */
  46981. static readonly PBRMATERIAL_OPAQUE: number;
  46982. /**
  46983. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46984. */
  46985. static readonly PBRMATERIAL_ALPHATEST: number;
  46986. /**
  46987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46988. */
  46989. static readonly PBRMATERIAL_ALPHABLEND: number;
  46990. /**
  46991. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46992. * They are also discarded below the alpha cutoff threshold to improve performances.
  46993. */
  46994. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46995. /**
  46996. * Defines the default value of how much AO map is occluding the analytical lights
  46997. * (point spot...).
  46998. */
  46999. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47000. /**
  47001. * Intensity of the direct lights e.g. the four lights available in your scene.
  47002. * This impacts both the direct diffuse and specular highlights.
  47003. */
  47004. directIntensity: number;
  47005. /**
  47006. * Intensity of the emissive part of the material.
  47007. * This helps controlling the emissive effect without modifying the emissive color.
  47008. */
  47009. emissiveIntensity: number;
  47010. /**
  47011. * Intensity of the environment e.g. how much the environment will light the object
  47012. * either through harmonics for rough material or through the refelction for shiny ones.
  47013. */
  47014. environmentIntensity: number;
  47015. /**
  47016. * This is a special control allowing the reduction of the specular highlights coming from the
  47017. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47018. */
  47019. specularIntensity: number;
  47020. /**
  47021. * Debug Control allowing disabling the bump map on this material.
  47022. */
  47023. disableBumpMap: boolean;
  47024. /**
  47025. * AKA Diffuse Texture in standard nomenclature.
  47026. */
  47027. albedoTexture: BaseTexture;
  47028. /**
  47029. * AKA Occlusion Texture in other nomenclature.
  47030. */
  47031. ambientTexture: BaseTexture;
  47032. /**
  47033. * AKA Occlusion Texture Intensity in other nomenclature.
  47034. */
  47035. ambientTextureStrength: number;
  47036. /**
  47037. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47038. * 1 means it completely occludes it
  47039. * 0 mean it has no impact
  47040. */
  47041. ambientTextureImpactOnAnalyticalLights: number;
  47042. /**
  47043. * Stores the alpha values in a texture.
  47044. */
  47045. opacityTexture: BaseTexture;
  47046. /**
  47047. * Stores the reflection values in a texture.
  47048. */
  47049. reflectionTexture: Nullable<BaseTexture>;
  47050. /**
  47051. * Stores the emissive values in a texture.
  47052. */
  47053. emissiveTexture: BaseTexture;
  47054. /**
  47055. * AKA Specular texture in other nomenclature.
  47056. */
  47057. reflectivityTexture: BaseTexture;
  47058. /**
  47059. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47060. */
  47061. metallicTexture: BaseTexture;
  47062. /**
  47063. * Specifies the metallic scalar of the metallic/roughness workflow.
  47064. * Can also be used to scale the metalness values of the metallic texture.
  47065. */
  47066. metallic: Nullable<number>;
  47067. /**
  47068. * Specifies the roughness scalar of the metallic/roughness workflow.
  47069. * Can also be used to scale the roughness values of the metallic texture.
  47070. */
  47071. roughness: Nullable<number>;
  47072. /**
  47073. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47074. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47075. */
  47076. microSurfaceTexture: BaseTexture;
  47077. /**
  47078. * Stores surface normal data used to displace a mesh in a texture.
  47079. */
  47080. bumpTexture: BaseTexture;
  47081. /**
  47082. * Stores the pre-calculated light information of a mesh in a texture.
  47083. */
  47084. lightmapTexture: BaseTexture;
  47085. /**
  47086. * Stores the refracted light information in a texture.
  47087. */
  47088. refractionTexture: Nullable<BaseTexture>;
  47089. /**
  47090. * The color of a material in ambient lighting.
  47091. */
  47092. ambientColor: Color3;
  47093. /**
  47094. * AKA Diffuse Color in other nomenclature.
  47095. */
  47096. albedoColor: Color3;
  47097. /**
  47098. * AKA Specular Color in other nomenclature.
  47099. */
  47100. reflectivityColor: Color3;
  47101. /**
  47102. * The color reflected from the material.
  47103. */
  47104. reflectionColor: Color3;
  47105. /**
  47106. * The color emitted from the material.
  47107. */
  47108. emissiveColor: Color3;
  47109. /**
  47110. * AKA Glossiness in other nomenclature.
  47111. */
  47112. microSurface: number;
  47113. /**
  47114. * source material index of refraction (IOR)' / 'destination material IOR.
  47115. */
  47116. indexOfRefraction: number;
  47117. /**
  47118. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47119. */
  47120. invertRefractionY: boolean;
  47121. /**
  47122. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47123. * Materials half opaque for instance using refraction could benefit from this control.
  47124. */
  47125. linkRefractionWithTransparency: boolean;
  47126. /**
  47127. * If true, the light map contains occlusion information instead of lighting info.
  47128. */
  47129. useLightmapAsShadowmap: boolean;
  47130. /**
  47131. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47132. */
  47133. useAlphaFromAlbedoTexture: boolean;
  47134. /**
  47135. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47136. */
  47137. forceAlphaTest: boolean;
  47138. /**
  47139. * Defines the alpha limits in alpha test mode.
  47140. */
  47141. alphaCutOff: number;
  47142. /**
  47143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47145. */
  47146. useSpecularOverAlpha: boolean;
  47147. /**
  47148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47149. */
  47150. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47151. /**
  47152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47153. */
  47154. useRoughnessFromMetallicTextureAlpha: boolean;
  47155. /**
  47156. * Specifies if the metallic texture contains the roughness information in its green channel.
  47157. */
  47158. useRoughnessFromMetallicTextureGreen: boolean;
  47159. /**
  47160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47161. */
  47162. useMetallnessFromMetallicTextureBlue: boolean;
  47163. /**
  47164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47165. */
  47166. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47167. /**
  47168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47169. */
  47170. useAmbientInGrayScale: boolean;
  47171. /**
  47172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47173. * The material will try to infer what glossiness each pixel should be.
  47174. */
  47175. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47176. /**
  47177. * BJS is using an harcoded light falloff based on a manually sets up range.
  47178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47180. */
  47181. /**
  47182. * BJS is using an harcoded light falloff based on a manually sets up range.
  47183. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47184. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47185. */
  47186. usePhysicalLightFalloff: boolean;
  47187. /**
  47188. * In order to support the falloff compatibility with gltf, a special mode has been added
  47189. * to reproduce the gltf light falloff.
  47190. */
  47191. /**
  47192. * In order to support the falloff compatibility with gltf, a special mode has been added
  47193. * to reproduce the gltf light falloff.
  47194. */
  47195. useGLTFLightFalloff: boolean;
  47196. /**
  47197. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47198. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47199. */
  47200. useRadianceOverAlpha: boolean;
  47201. /**
  47202. * Allows using an object space normal map (instead of tangent space).
  47203. */
  47204. useObjectSpaceNormalMap: boolean;
  47205. /**
  47206. * Allows using the bump map in parallax mode.
  47207. */
  47208. useParallax: boolean;
  47209. /**
  47210. * Allows using the bump map in parallax occlusion mode.
  47211. */
  47212. useParallaxOcclusion: boolean;
  47213. /**
  47214. * Controls the scale bias of the parallax mode.
  47215. */
  47216. parallaxScaleBias: number;
  47217. /**
  47218. * If sets to true, disables all the lights affecting the material.
  47219. */
  47220. disableLighting: boolean;
  47221. /**
  47222. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47223. */
  47224. forceIrradianceInFragment: boolean;
  47225. /**
  47226. * Number of Simultaneous lights allowed on the material.
  47227. */
  47228. maxSimultaneousLights: number;
  47229. /**
  47230. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47231. */
  47232. invertNormalMapX: boolean;
  47233. /**
  47234. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47235. */
  47236. invertNormalMapY: boolean;
  47237. /**
  47238. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47239. */
  47240. twoSidedLighting: boolean;
  47241. /**
  47242. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47243. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47244. */
  47245. useAlphaFresnel: boolean;
  47246. /**
  47247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47248. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47249. */
  47250. useLinearAlphaFresnel: boolean;
  47251. /**
  47252. * Let user defines the brdf lookup texture used for IBL.
  47253. * A default 8bit version is embedded but you could point at :
  47254. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47255. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47256. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47257. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47258. */
  47259. environmentBRDFTexture: Nullable<BaseTexture>;
  47260. /**
  47261. * Force normal to face away from face.
  47262. */
  47263. forceNormalForward: boolean;
  47264. /**
  47265. * Enables specular anti aliasing in the PBR shader.
  47266. * It will both interacts on the Geometry for analytical and IBL lighting.
  47267. * It also prefilter the roughness map based on the bump values.
  47268. */
  47269. enableSpecularAntiAliasing: boolean;
  47270. /**
  47271. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47272. * makes the reflect vector face the model (under horizon).
  47273. */
  47274. useHorizonOcclusion: boolean;
  47275. /**
  47276. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47277. * too much the area relying on ambient texture to define their ambient occlusion.
  47278. */
  47279. useRadianceOcclusion: boolean;
  47280. /**
  47281. * If set to true, no lighting calculations will be applied.
  47282. */
  47283. unlit: boolean;
  47284. /**
  47285. * Gets the image processing configuration used either in this material.
  47286. */
  47287. /**
  47288. * Sets the Default image processing configuration used either in the this material.
  47289. *
  47290. * If sets to null, the scene one is in use.
  47291. */
  47292. imageProcessingConfiguration: ImageProcessingConfiguration;
  47293. /**
  47294. * Gets wether the color curves effect is enabled.
  47295. */
  47296. /**
  47297. * Sets wether the color curves effect is enabled.
  47298. */
  47299. cameraColorCurvesEnabled: boolean;
  47300. /**
  47301. * Gets wether the color grading effect is enabled.
  47302. */
  47303. /**
  47304. * Gets wether the color grading effect is enabled.
  47305. */
  47306. cameraColorGradingEnabled: boolean;
  47307. /**
  47308. * Gets wether tonemapping is enabled or not.
  47309. */
  47310. /**
  47311. * Sets wether tonemapping is enabled or not
  47312. */
  47313. cameraToneMappingEnabled: boolean;
  47314. /**
  47315. * The camera exposure used on this material.
  47316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47317. * This corresponds to a photographic exposure.
  47318. */
  47319. /**
  47320. * The camera exposure used on this material.
  47321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47322. * This corresponds to a photographic exposure.
  47323. */
  47324. cameraExposure: number;
  47325. /**
  47326. * Gets The camera contrast used on this material.
  47327. */
  47328. /**
  47329. * Sets The camera contrast used on this material.
  47330. */
  47331. cameraContrast: number;
  47332. /**
  47333. * Gets the Color Grading 2D Lookup Texture.
  47334. */
  47335. /**
  47336. * Sets the Color Grading 2D Lookup Texture.
  47337. */
  47338. cameraColorGradingTexture: Nullable<BaseTexture>;
  47339. /**
  47340. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47341. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47342. * 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;
  47343. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47344. */
  47345. /**
  47346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47348. * 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;
  47349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47350. */
  47351. cameraColorCurves: Nullable<ColorCurves>;
  47352. /**
  47353. * Instantiates a new PBRMaterial instance.
  47354. *
  47355. * @param name The material name
  47356. * @param scene The scene the material will be use in.
  47357. */
  47358. constructor(name: string, scene: Scene);
  47359. /**
  47360. * Returns the name of this material class.
  47361. */
  47362. getClassName(): string;
  47363. /**
  47364. * Makes a duplicate of the current material.
  47365. * @param name - name to use for the new material.
  47366. */
  47367. clone(name: string): PBRMaterial;
  47368. /**
  47369. * Serializes this PBR Material.
  47370. * @returns - An object with the serialized material.
  47371. */
  47372. serialize(): any;
  47373. /**
  47374. * Parses a PBR Material from a serialized object.
  47375. * @param source - Serialized object.
  47376. * @param scene - BJS scene instance.
  47377. * @param rootUrl - url for the scene object
  47378. * @returns - PBRMaterial
  47379. */
  47380. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47381. }
  47382. }
  47383. declare module "babylonjs/Misc/dds" {
  47384. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47385. import { Engine } from "babylonjs/Engines/engine";
  47386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47387. import { Nullable } from "babylonjs/types";
  47388. import { Scene } from "babylonjs/scene";
  47389. /**
  47390. * Direct draw surface info
  47391. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47392. */
  47393. export interface DDSInfo {
  47394. /**
  47395. * Width of the texture
  47396. */
  47397. width: number;
  47398. /**
  47399. * Width of the texture
  47400. */
  47401. height: number;
  47402. /**
  47403. * Number of Mipmaps for the texture
  47404. * @see https://en.wikipedia.org/wiki/Mipmap
  47405. */
  47406. mipmapCount: number;
  47407. /**
  47408. * If the textures format is a known fourCC format
  47409. * @see https://www.fourcc.org/
  47410. */
  47411. isFourCC: boolean;
  47412. /**
  47413. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47414. */
  47415. isRGB: boolean;
  47416. /**
  47417. * If the texture is a lumincance format
  47418. */
  47419. isLuminance: boolean;
  47420. /**
  47421. * If this is a cube texture
  47422. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47423. */
  47424. isCube: boolean;
  47425. /**
  47426. * If the texture is a compressed format eg. FOURCC_DXT1
  47427. */
  47428. isCompressed: boolean;
  47429. /**
  47430. * The dxgiFormat of the texture
  47431. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47432. */
  47433. dxgiFormat: number;
  47434. /**
  47435. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47436. */
  47437. textureType: number;
  47438. /**
  47439. * Sphericle polynomial created for the dds texture
  47440. */
  47441. sphericalPolynomial?: SphericalPolynomial;
  47442. }
  47443. /**
  47444. * Class used to provide DDS decompression tools
  47445. */
  47446. export class DDSTools {
  47447. /**
  47448. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47449. */
  47450. static StoreLODInAlphaChannel: boolean;
  47451. /**
  47452. * Gets DDS information from an array buffer
  47453. * @param arrayBuffer defines the array buffer to read data from
  47454. * @returns the DDS information
  47455. */
  47456. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47457. private static _FloatView;
  47458. private static _Int32View;
  47459. private static _ToHalfFloat;
  47460. private static _FromHalfFloat;
  47461. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47462. private static _GetHalfFloatRGBAArrayBuffer;
  47463. private static _GetFloatRGBAArrayBuffer;
  47464. private static _GetFloatAsUIntRGBAArrayBuffer;
  47465. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47466. private static _GetRGBAArrayBuffer;
  47467. private static _ExtractLongWordOrder;
  47468. private static _GetRGBArrayBuffer;
  47469. private static _GetLuminanceArrayBuffer;
  47470. /**
  47471. * Uploads DDS Levels to a Babylon Texture
  47472. * @hidden
  47473. */
  47474. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47475. }
  47476. module "babylonjs/Engines/engine" {
  47477. interface Engine {
  47478. /**
  47479. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47480. * @param rootUrl defines the url where the file to load is located
  47481. * @param scene defines the current scene
  47482. * @param lodScale defines scale to apply to the mip map selection
  47483. * @param lodOffset defines offset to apply to the mip map selection
  47484. * @param onLoad defines an optional callback raised when the texture is loaded
  47485. * @param onError defines an optional callback raised if there is an issue to load the texture
  47486. * @param format defines the format of the data
  47487. * @param forcedExtension defines the extension to use to pick the right loader
  47488. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47489. * @returns the cube texture as an InternalTexture
  47490. */
  47491. 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;
  47492. }
  47493. }
  47494. }
  47495. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47496. import { Nullable } from "babylonjs/types";
  47497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47499. /**
  47500. * Implementation of the DDS Texture Loader.
  47501. * @hidden
  47502. */
  47503. export class _DDSTextureLoader implements IInternalTextureLoader {
  47504. /**
  47505. * Defines wether the loader supports cascade loading the different faces.
  47506. */
  47507. readonly supportCascades: boolean;
  47508. /**
  47509. * This returns if the loader support the current file information.
  47510. * @param extension defines the file extension of the file being loaded
  47511. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47512. * @param fallback defines the fallback internal texture if any
  47513. * @param isBase64 defines whether the texture is encoded as a base64
  47514. * @param isBuffer defines whether the texture data are stored as a buffer
  47515. * @returns true if the loader can load the specified file
  47516. */
  47517. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47518. /**
  47519. * Transform the url before loading if required.
  47520. * @param rootUrl the url of the texture
  47521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47522. * @returns the transformed texture
  47523. */
  47524. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47525. /**
  47526. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47527. * @param rootUrl the url of the texture
  47528. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47529. * @returns the fallback texture
  47530. */
  47531. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47532. /**
  47533. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47534. * @param data contains the texture data
  47535. * @param texture defines the BabylonJS internal texture
  47536. * @param createPolynomials will be true if polynomials have been requested
  47537. * @param onLoad defines the callback to trigger once the texture is ready
  47538. * @param onError defines the callback to trigger in case of error
  47539. */
  47540. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47541. /**
  47542. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47543. * @param data contains the texture data
  47544. * @param texture defines the BabylonJS internal texture
  47545. * @param callback defines the method to call once ready to upload
  47546. */
  47547. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47548. }
  47549. }
  47550. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47552. /** @hidden */
  47553. export var rgbdEncodePixelShader: {
  47554. name: string;
  47555. shader: string;
  47556. };
  47557. }
  47558. declare module "babylonjs/Misc/environmentTextureTools" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47561. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47562. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47563. import "babylonjs/Shaders/rgbdEncode.fragment";
  47564. import "babylonjs/Shaders/rgbdDecode.fragment";
  47565. /**
  47566. * Raw texture data and descriptor sufficient for WebGL texture upload
  47567. */
  47568. export interface EnvironmentTextureInfo {
  47569. /**
  47570. * Version of the environment map
  47571. */
  47572. version: number;
  47573. /**
  47574. * Width of image
  47575. */
  47576. width: number;
  47577. /**
  47578. * Irradiance information stored in the file.
  47579. */
  47580. irradiance: any;
  47581. /**
  47582. * Specular information stored in the file.
  47583. */
  47584. specular: any;
  47585. }
  47586. /**
  47587. * Sets of helpers addressing the serialization and deserialization of environment texture
  47588. * stored in a BabylonJS env file.
  47589. * Those files are usually stored as .env files.
  47590. */
  47591. export class EnvironmentTextureTools {
  47592. /**
  47593. * Magic number identifying the env file.
  47594. */
  47595. private static _MagicBytes;
  47596. /**
  47597. * Gets the environment info from an env file.
  47598. * @param data The array buffer containing the .env bytes.
  47599. * @returns the environment file info (the json header) if successfully parsed.
  47600. */
  47601. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47602. /**
  47603. * Creates an environment texture from a loaded cube texture.
  47604. * @param texture defines the cube texture to convert in env file
  47605. * @return a promise containing the environment data if succesfull.
  47606. */
  47607. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47608. /**
  47609. * Creates a JSON representation of the spherical data.
  47610. * @param texture defines the texture containing the polynomials
  47611. * @return the JSON representation of the spherical info
  47612. */
  47613. private static _CreateEnvTextureIrradiance;
  47614. /**
  47615. * Uploads the texture info contained in the env file to the GPU.
  47616. * @param texture defines the internal texture to upload to
  47617. * @param arrayBuffer defines the buffer cotaining the data to load
  47618. * @param info defines the texture info retrieved through the GetEnvInfo method
  47619. * @returns a promise
  47620. */
  47621. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47622. /**
  47623. * Uploads the levels of image data to the GPU.
  47624. * @param texture defines the internal texture to upload to
  47625. * @param imageData defines the array buffer views of image data [mipmap][face]
  47626. * @returns a promise
  47627. */
  47628. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47629. /**
  47630. * Uploads spherical polynomials information to the texture.
  47631. * @param texture defines the texture we are trying to upload the information to
  47632. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47633. */
  47634. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47635. /** @hidden */
  47636. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47637. }
  47638. }
  47639. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47640. import { Nullable } from "babylonjs/types";
  47641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47642. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47643. /**
  47644. * Implementation of the ENV Texture Loader.
  47645. * @hidden
  47646. */
  47647. export class _ENVTextureLoader implements IInternalTextureLoader {
  47648. /**
  47649. * Defines wether the loader supports cascade loading the different faces.
  47650. */
  47651. readonly supportCascades: boolean;
  47652. /**
  47653. * This returns if the loader support the current file information.
  47654. * @param extension defines the file extension of the file being loaded
  47655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47656. * @param fallback defines the fallback internal texture if any
  47657. * @param isBase64 defines whether the texture is encoded as a base64
  47658. * @param isBuffer defines whether the texture data are stored as a buffer
  47659. * @returns true if the loader can load the specified file
  47660. */
  47661. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47662. /**
  47663. * Transform the url before loading if required.
  47664. * @param rootUrl the url of the texture
  47665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47666. * @returns the transformed texture
  47667. */
  47668. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47669. /**
  47670. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47671. * @param rootUrl the url of the texture
  47672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47673. * @returns the fallback texture
  47674. */
  47675. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47676. /**
  47677. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47678. * @param data contains the texture data
  47679. * @param texture defines the BabylonJS internal texture
  47680. * @param createPolynomials will be true if polynomials have been requested
  47681. * @param onLoad defines the callback to trigger once the texture is ready
  47682. * @param onError defines the callback to trigger in case of error
  47683. */
  47684. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47685. /**
  47686. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47687. * @param data contains the texture data
  47688. * @param texture defines the BabylonJS internal texture
  47689. * @param callback defines the method to call once ready to upload
  47690. */
  47691. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47692. }
  47693. }
  47694. declare module "babylonjs/Misc/khronosTextureContainer" {
  47695. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47696. /**
  47697. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47698. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47699. */
  47700. export class KhronosTextureContainer {
  47701. /** contents of the KTX container file */
  47702. arrayBuffer: any;
  47703. private static HEADER_LEN;
  47704. private static COMPRESSED_2D;
  47705. private static COMPRESSED_3D;
  47706. private static TEX_2D;
  47707. private static TEX_3D;
  47708. /**
  47709. * Gets the openGL type
  47710. */
  47711. glType: number;
  47712. /**
  47713. * Gets the openGL type size
  47714. */
  47715. glTypeSize: number;
  47716. /**
  47717. * Gets the openGL format
  47718. */
  47719. glFormat: number;
  47720. /**
  47721. * Gets the openGL internal format
  47722. */
  47723. glInternalFormat: number;
  47724. /**
  47725. * Gets the base internal format
  47726. */
  47727. glBaseInternalFormat: number;
  47728. /**
  47729. * Gets image width in pixel
  47730. */
  47731. pixelWidth: number;
  47732. /**
  47733. * Gets image height in pixel
  47734. */
  47735. pixelHeight: number;
  47736. /**
  47737. * Gets image depth in pixels
  47738. */
  47739. pixelDepth: number;
  47740. /**
  47741. * Gets the number of array elements
  47742. */
  47743. numberOfArrayElements: number;
  47744. /**
  47745. * Gets the number of faces
  47746. */
  47747. numberOfFaces: number;
  47748. /**
  47749. * Gets the number of mipmap levels
  47750. */
  47751. numberOfMipmapLevels: number;
  47752. /**
  47753. * Gets the bytes of key value data
  47754. */
  47755. bytesOfKeyValueData: number;
  47756. /**
  47757. * Gets the load type
  47758. */
  47759. loadType: number;
  47760. /**
  47761. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47762. */
  47763. isInvalid: boolean;
  47764. /**
  47765. * Creates a new KhronosTextureContainer
  47766. * @param arrayBuffer contents of the KTX container file
  47767. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47768. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47769. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47770. */
  47771. constructor(
  47772. /** contents of the KTX container file */
  47773. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47774. /**
  47775. * Uploads KTX content to a Babylon Texture.
  47776. * It is assumed that the texture has already been created & is currently bound
  47777. * @hidden
  47778. */
  47779. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47780. private _upload2DCompressedLevels;
  47781. }
  47782. }
  47783. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47784. import { Nullable } from "babylonjs/types";
  47785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47786. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47787. /**
  47788. * Implementation of the KTX Texture Loader.
  47789. * @hidden
  47790. */
  47791. export class _KTXTextureLoader implements IInternalTextureLoader {
  47792. /**
  47793. * Defines wether the loader supports cascade loading the different faces.
  47794. */
  47795. readonly supportCascades: boolean;
  47796. /**
  47797. * This returns if the loader support the current file information.
  47798. * @param extension defines the file extension of the file being loaded
  47799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47800. * @param fallback defines the fallback internal texture if any
  47801. * @param isBase64 defines whether the texture is encoded as a base64
  47802. * @param isBuffer defines whether the texture data are stored as a buffer
  47803. * @returns true if the loader can load the specified file
  47804. */
  47805. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47806. /**
  47807. * Transform the url before loading if required.
  47808. * @param rootUrl the url of the texture
  47809. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47810. * @returns the transformed texture
  47811. */
  47812. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47813. /**
  47814. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47815. * @param rootUrl the url of the texture
  47816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47817. * @returns the fallback texture
  47818. */
  47819. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47820. /**
  47821. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47822. * @param data contains the texture data
  47823. * @param texture defines the BabylonJS internal texture
  47824. * @param createPolynomials will be true if polynomials have been requested
  47825. * @param onLoad defines the callback to trigger once the texture is ready
  47826. * @param onError defines the callback to trigger in case of error
  47827. */
  47828. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47829. /**
  47830. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47831. * @param data contains the texture data
  47832. * @param texture defines the BabylonJS internal texture
  47833. * @param callback defines the method to call once ready to upload
  47834. */
  47835. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47836. }
  47837. }
  47838. declare module "babylonjs/Helpers/sceneHelpers" {
  47839. import { Nullable } from "babylonjs/types";
  47840. import { Mesh } from "babylonjs/Meshes/mesh";
  47841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47842. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47843. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47844. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47845. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47846. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47847. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47848. import "babylonjs/Meshes/Builders/boxBuilder";
  47849. /** @hidden */
  47850. export var _forceSceneHelpersToBundle: boolean;
  47851. module "babylonjs/scene" {
  47852. interface Scene {
  47853. /**
  47854. * Creates a default light for the scene.
  47855. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47856. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47857. */
  47858. createDefaultLight(replace?: boolean): void;
  47859. /**
  47860. * Creates a default camera for the scene.
  47861. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47862. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47863. * @param replace has default false, when true replaces the active camera in the scene
  47864. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47865. */
  47866. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47867. /**
  47868. * Creates a default camera and a default light.
  47869. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47870. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47871. * @param replace has the default false, when true replaces the active camera/light in the scene
  47872. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47873. */
  47874. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47875. /**
  47876. * Creates a new sky box
  47877. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47878. * @param environmentTexture defines the texture to use as environment texture
  47879. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47880. * @param scale defines the overall scale of the skybox
  47881. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47882. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47883. * @returns a new mesh holding the sky box
  47884. */
  47885. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47886. /**
  47887. * Creates a new environment
  47888. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47889. * @param options defines the options you can use to configure the environment
  47890. * @returns the new EnvironmentHelper
  47891. */
  47892. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47893. /**
  47894. * Creates a new VREXperienceHelper
  47895. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47896. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47897. * @returns a new VREXperienceHelper
  47898. */
  47899. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47900. /**
  47901. * Creates a new XREXperienceHelper
  47902. * @see http://doc.babylonjs.com/how_to/webxr
  47903. * @returns a promise for a new XREXperienceHelper
  47904. */
  47905. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47906. }
  47907. }
  47908. }
  47909. declare module "babylonjs/Helpers/videoDome" {
  47910. import { Scene } from "babylonjs/scene";
  47911. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47912. import { Mesh } from "babylonjs/Meshes/mesh";
  47913. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47914. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47915. import "babylonjs/Meshes/Builders/sphereBuilder";
  47916. /**
  47917. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47918. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47919. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47920. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47921. */
  47922. export class VideoDome extends TransformNode {
  47923. /**
  47924. * Define the video source as a Monoscopic panoramic 360 video.
  47925. */
  47926. static readonly MODE_MONOSCOPIC: number;
  47927. /**
  47928. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47929. */
  47930. static readonly MODE_TOPBOTTOM: number;
  47931. /**
  47932. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47933. */
  47934. static readonly MODE_SIDEBYSIDE: number;
  47935. private _useDirectMapping;
  47936. /**
  47937. * The video texture being displayed on the sphere
  47938. */
  47939. protected _videoTexture: VideoTexture;
  47940. /**
  47941. * Gets the video texture being displayed on the sphere
  47942. */
  47943. readonly videoTexture: VideoTexture;
  47944. /**
  47945. * The skybox material
  47946. */
  47947. protected _material: BackgroundMaterial;
  47948. /**
  47949. * The surface used for the skybox
  47950. */
  47951. protected _mesh: Mesh;
  47952. /**
  47953. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47954. * Also see the options.resolution property.
  47955. */
  47956. fovMultiplier: number;
  47957. private _videoMode;
  47958. /**
  47959. * Gets or set the current video mode for the video. It can be:
  47960. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47961. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47962. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47963. */
  47964. videoMode: number;
  47965. /**
  47966. * Oberserver used in Stereoscopic VR Mode.
  47967. */
  47968. private _onBeforeCameraRenderObserver;
  47969. /**
  47970. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47971. * @param name Element's name, child elements will append suffixes for their own names.
  47972. * @param urlsOrVideo defines the url(s) or the video element to use
  47973. * @param options An object containing optional or exposed sub element properties
  47974. */
  47975. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47976. resolution?: number;
  47977. clickToPlay?: boolean;
  47978. autoPlay?: boolean;
  47979. loop?: boolean;
  47980. size?: number;
  47981. poster?: string;
  47982. faceForward?: boolean;
  47983. useDirectMapping?: boolean;
  47984. }, scene: Scene);
  47985. private _changeVideoMode;
  47986. /**
  47987. * Releases resources associated with this node.
  47988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47990. */
  47991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47992. }
  47993. }
  47994. declare module "babylonjs/Helpers/index" {
  47995. export * from "babylonjs/Helpers/environmentHelper";
  47996. export * from "babylonjs/Helpers/photoDome";
  47997. export * from "babylonjs/Helpers/sceneHelpers";
  47998. export * from "babylonjs/Helpers/videoDome";
  47999. }
  48000. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48001. import { PerfCounter } from "babylonjs/Misc/tools";
  48002. import { IDisposable } from "babylonjs/scene";
  48003. import { Engine } from "babylonjs/Engines/engine";
  48004. /**
  48005. * This class can be used to get instrumentation data from a Babylon engine
  48006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48007. */
  48008. export class EngineInstrumentation implements IDisposable {
  48009. /**
  48010. * Define the instrumented engine.
  48011. */
  48012. engine: Engine;
  48013. private _captureGPUFrameTime;
  48014. private _gpuFrameTimeToken;
  48015. private _gpuFrameTime;
  48016. private _captureShaderCompilationTime;
  48017. private _shaderCompilationTime;
  48018. private _onBeginFrameObserver;
  48019. private _onEndFrameObserver;
  48020. private _onBeforeShaderCompilationObserver;
  48021. private _onAfterShaderCompilationObserver;
  48022. /**
  48023. * Gets the perf counter used for GPU frame time
  48024. */
  48025. readonly gpuFrameTimeCounter: PerfCounter;
  48026. /**
  48027. * Gets the GPU frame time capture status
  48028. */
  48029. /**
  48030. * Enable or disable the GPU frame time capture
  48031. */
  48032. captureGPUFrameTime: boolean;
  48033. /**
  48034. * Gets the perf counter used for shader compilation time
  48035. */
  48036. readonly shaderCompilationTimeCounter: PerfCounter;
  48037. /**
  48038. * Gets the shader compilation time capture status
  48039. */
  48040. /**
  48041. * Enable or disable the shader compilation time capture
  48042. */
  48043. captureShaderCompilationTime: boolean;
  48044. /**
  48045. * Instantiates a new engine instrumentation.
  48046. * This class can be used to get instrumentation data from a Babylon engine
  48047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48048. * @param engine Defines the engine to instrument
  48049. */
  48050. constructor(
  48051. /**
  48052. * Define the instrumented engine.
  48053. */
  48054. engine: Engine);
  48055. /**
  48056. * Dispose and release associated resources.
  48057. */
  48058. dispose(): void;
  48059. }
  48060. }
  48061. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48062. import { PerfCounter } from "babylonjs/Misc/tools";
  48063. import { Scene, IDisposable } from "babylonjs/scene";
  48064. /**
  48065. * This class can be used to get instrumentation data from a Babylon engine
  48066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48067. */
  48068. export class SceneInstrumentation implements IDisposable {
  48069. /**
  48070. * Defines the scene to instrument
  48071. */
  48072. scene: Scene;
  48073. private _captureActiveMeshesEvaluationTime;
  48074. private _activeMeshesEvaluationTime;
  48075. private _captureRenderTargetsRenderTime;
  48076. private _renderTargetsRenderTime;
  48077. private _captureFrameTime;
  48078. private _frameTime;
  48079. private _captureRenderTime;
  48080. private _renderTime;
  48081. private _captureInterFrameTime;
  48082. private _interFrameTime;
  48083. private _captureParticlesRenderTime;
  48084. private _particlesRenderTime;
  48085. private _captureSpritesRenderTime;
  48086. private _spritesRenderTime;
  48087. private _capturePhysicsTime;
  48088. private _physicsTime;
  48089. private _captureAnimationsTime;
  48090. private _animationsTime;
  48091. private _captureCameraRenderTime;
  48092. private _cameraRenderTime;
  48093. private _onBeforeActiveMeshesEvaluationObserver;
  48094. private _onAfterActiveMeshesEvaluationObserver;
  48095. private _onBeforeRenderTargetsRenderObserver;
  48096. private _onAfterRenderTargetsRenderObserver;
  48097. private _onAfterRenderObserver;
  48098. private _onBeforeDrawPhaseObserver;
  48099. private _onAfterDrawPhaseObserver;
  48100. private _onBeforeAnimationsObserver;
  48101. private _onBeforeParticlesRenderingObserver;
  48102. private _onAfterParticlesRenderingObserver;
  48103. private _onBeforeSpritesRenderingObserver;
  48104. private _onAfterSpritesRenderingObserver;
  48105. private _onBeforePhysicsObserver;
  48106. private _onAfterPhysicsObserver;
  48107. private _onAfterAnimationsObserver;
  48108. private _onBeforeCameraRenderObserver;
  48109. private _onAfterCameraRenderObserver;
  48110. /**
  48111. * Gets the perf counter used for active meshes evaluation time
  48112. */
  48113. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48114. /**
  48115. * Gets the active meshes evaluation time capture status
  48116. */
  48117. /**
  48118. * Enable or disable the active meshes evaluation time capture
  48119. */
  48120. captureActiveMeshesEvaluationTime: boolean;
  48121. /**
  48122. * Gets the perf counter used for render targets render time
  48123. */
  48124. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48125. /**
  48126. * Gets the render targets render time capture status
  48127. */
  48128. /**
  48129. * Enable or disable the render targets render time capture
  48130. */
  48131. captureRenderTargetsRenderTime: boolean;
  48132. /**
  48133. * Gets the perf counter used for particles render time
  48134. */
  48135. readonly particlesRenderTimeCounter: PerfCounter;
  48136. /**
  48137. * Gets the particles render time capture status
  48138. */
  48139. /**
  48140. * Enable or disable the particles render time capture
  48141. */
  48142. captureParticlesRenderTime: boolean;
  48143. /**
  48144. * Gets the perf counter used for sprites render time
  48145. */
  48146. readonly spritesRenderTimeCounter: PerfCounter;
  48147. /**
  48148. * Gets the sprites render time capture status
  48149. */
  48150. /**
  48151. * Enable or disable the sprites render time capture
  48152. */
  48153. captureSpritesRenderTime: boolean;
  48154. /**
  48155. * Gets the perf counter used for physics time
  48156. */
  48157. readonly physicsTimeCounter: PerfCounter;
  48158. /**
  48159. * Gets the physics time capture status
  48160. */
  48161. /**
  48162. * Enable or disable the physics time capture
  48163. */
  48164. capturePhysicsTime: boolean;
  48165. /**
  48166. * Gets the perf counter used for animations time
  48167. */
  48168. readonly animationsTimeCounter: PerfCounter;
  48169. /**
  48170. * Gets the animations time capture status
  48171. */
  48172. /**
  48173. * Enable or disable the animations time capture
  48174. */
  48175. captureAnimationsTime: boolean;
  48176. /**
  48177. * Gets the perf counter used for frame time capture
  48178. */
  48179. readonly frameTimeCounter: PerfCounter;
  48180. /**
  48181. * Gets the frame time capture status
  48182. */
  48183. /**
  48184. * Enable or disable the frame time capture
  48185. */
  48186. captureFrameTime: boolean;
  48187. /**
  48188. * Gets the perf counter used for inter-frames time capture
  48189. */
  48190. readonly interFrameTimeCounter: PerfCounter;
  48191. /**
  48192. * Gets the inter-frames time capture status
  48193. */
  48194. /**
  48195. * Enable or disable the inter-frames time capture
  48196. */
  48197. captureInterFrameTime: boolean;
  48198. /**
  48199. * Gets the perf counter used for render time capture
  48200. */
  48201. readonly renderTimeCounter: PerfCounter;
  48202. /**
  48203. * Gets the render time capture status
  48204. */
  48205. /**
  48206. * Enable or disable the render time capture
  48207. */
  48208. captureRenderTime: boolean;
  48209. /**
  48210. * Gets the perf counter used for camera render time capture
  48211. */
  48212. readonly cameraRenderTimeCounter: PerfCounter;
  48213. /**
  48214. * Gets the camera render time capture status
  48215. */
  48216. /**
  48217. * Enable or disable the camera render time capture
  48218. */
  48219. captureCameraRenderTime: boolean;
  48220. /**
  48221. * Gets the perf counter used for draw calls
  48222. */
  48223. readonly drawCallsCounter: PerfCounter;
  48224. /**
  48225. * Gets the perf counter used for texture collisions
  48226. */
  48227. readonly textureCollisionsCounter: PerfCounter;
  48228. /**
  48229. * Instantiates a new scene instrumentation.
  48230. * This class can be used to get instrumentation data from a Babylon engine
  48231. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48232. * @param scene Defines the scene to instrument
  48233. */
  48234. constructor(
  48235. /**
  48236. * Defines the scene to instrument
  48237. */
  48238. scene: Scene);
  48239. /**
  48240. * Dispose and release associated resources.
  48241. */
  48242. dispose(): void;
  48243. }
  48244. }
  48245. declare module "babylonjs/Instrumentation/index" {
  48246. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48247. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48248. export * from "babylonjs/Instrumentation/timeToken";
  48249. }
  48250. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48251. /** @hidden */
  48252. export var glowMapGenerationPixelShader: {
  48253. name: string;
  48254. shader: string;
  48255. };
  48256. }
  48257. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48258. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48259. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48260. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48261. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48263. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48264. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48265. /** @hidden */
  48266. export var glowMapGenerationVertexShader: {
  48267. name: string;
  48268. shader: string;
  48269. };
  48270. }
  48271. declare module "babylonjs/Layers/effectLayer" {
  48272. import { Observable } from "babylonjs/Misc/observable";
  48273. import { Nullable } from "babylonjs/types";
  48274. import { Camera } from "babylonjs/Cameras/camera";
  48275. import { Scene } from "babylonjs/scene";
  48276. import { Color4, ISize } from "babylonjs/Maths/math";
  48277. import { Engine } from "babylonjs/Engines/engine";
  48278. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48280. import { Mesh } from "babylonjs/Meshes/mesh";
  48281. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48283. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48284. import { Effect } from "babylonjs/Materials/effect";
  48285. import { Material } from "babylonjs/Materials/material";
  48286. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48287. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48288. /**
  48289. * Effect layer options. This helps customizing the behaviour
  48290. * of the effect layer.
  48291. */
  48292. export interface IEffectLayerOptions {
  48293. /**
  48294. * Multiplication factor apply to the canvas size to compute the render target size
  48295. * used to generated the objects (the smaller the faster).
  48296. */
  48297. mainTextureRatio: number;
  48298. /**
  48299. * Enforces a fixed size texture to ensure effect stability across devices.
  48300. */
  48301. mainTextureFixedSize?: number;
  48302. /**
  48303. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48304. */
  48305. alphaBlendingMode: number;
  48306. /**
  48307. * The camera attached to the layer.
  48308. */
  48309. camera: Nullable<Camera>;
  48310. /**
  48311. * The rendering group to draw the layer in.
  48312. */
  48313. renderingGroupId: number;
  48314. }
  48315. /**
  48316. * The effect layer Helps adding post process effect blended with the main pass.
  48317. *
  48318. * This can be for instance use to generate glow or higlight effects on the scene.
  48319. *
  48320. * The effect layer class can not be used directly and is intented to inherited from to be
  48321. * customized per effects.
  48322. */
  48323. export abstract class EffectLayer {
  48324. private _vertexBuffers;
  48325. private _indexBuffer;
  48326. private _cachedDefines;
  48327. private _effectLayerMapGenerationEffect;
  48328. private _effectLayerOptions;
  48329. private _mergeEffect;
  48330. protected _scene: Scene;
  48331. protected _engine: Engine;
  48332. protected _maxSize: number;
  48333. protected _mainTextureDesiredSize: ISize;
  48334. protected _mainTexture: RenderTargetTexture;
  48335. protected _shouldRender: boolean;
  48336. protected _postProcesses: PostProcess[];
  48337. protected _textures: BaseTexture[];
  48338. protected _emissiveTextureAndColor: {
  48339. texture: Nullable<BaseTexture>;
  48340. color: Color4;
  48341. };
  48342. /**
  48343. * The name of the layer
  48344. */
  48345. name: string;
  48346. /**
  48347. * The clear color of the texture used to generate the glow map.
  48348. */
  48349. neutralColor: Color4;
  48350. /**
  48351. * Specifies wether the highlight layer is enabled or not.
  48352. */
  48353. isEnabled: boolean;
  48354. /**
  48355. * Gets the camera attached to the layer.
  48356. */
  48357. readonly camera: Nullable<Camera>;
  48358. /**
  48359. * Gets the rendering group id the layer should render in.
  48360. */
  48361. readonly renderingGroupId: number;
  48362. /**
  48363. * An event triggered when the effect layer has been disposed.
  48364. */
  48365. onDisposeObservable: Observable<EffectLayer>;
  48366. /**
  48367. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48368. */
  48369. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48370. /**
  48371. * An event triggered when the generated texture is being merged in the scene.
  48372. */
  48373. onBeforeComposeObservable: Observable<EffectLayer>;
  48374. /**
  48375. * An event triggered when the generated texture has been merged in the scene.
  48376. */
  48377. onAfterComposeObservable: Observable<EffectLayer>;
  48378. /**
  48379. * An event triggered when the efffect layer changes its size.
  48380. */
  48381. onSizeChangedObservable: Observable<EffectLayer>;
  48382. /** @hidden */
  48383. static _SceneComponentInitialization: (scene: Scene) => void;
  48384. /**
  48385. * Instantiates a new effect Layer and references it in the scene.
  48386. * @param name The name of the layer
  48387. * @param scene The scene to use the layer in
  48388. */
  48389. constructor(
  48390. /** The Friendly of the effect in the scene */
  48391. name: string, scene: Scene);
  48392. /**
  48393. * Get the effect name of the layer.
  48394. * @return The effect name
  48395. */
  48396. abstract getEffectName(): string;
  48397. /**
  48398. * Checks for the readiness of the element composing the layer.
  48399. * @param subMesh the mesh to check for
  48400. * @param useInstances specify wether or not to use instances to render the mesh
  48401. * @return true if ready otherwise, false
  48402. */
  48403. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48404. /**
  48405. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48406. * @returns true if the effect requires stencil during the main canvas render pass.
  48407. */
  48408. abstract needStencil(): boolean;
  48409. /**
  48410. * Create the merge effect. This is the shader use to blit the information back
  48411. * to the main canvas at the end of the scene rendering.
  48412. * @returns The effect containing the shader used to merge the effect on the main canvas
  48413. */
  48414. protected abstract _createMergeEffect(): Effect;
  48415. /**
  48416. * Creates the render target textures and post processes used in the effect layer.
  48417. */
  48418. protected abstract _createTextureAndPostProcesses(): void;
  48419. /**
  48420. * Implementation specific of rendering the generating effect on the main canvas.
  48421. * @param effect The effect used to render through
  48422. */
  48423. protected abstract _internalRender(effect: Effect): void;
  48424. /**
  48425. * Sets the required values for both the emissive texture and and the main color.
  48426. */
  48427. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48428. /**
  48429. * Free any resources and references associated to a mesh.
  48430. * Internal use
  48431. * @param mesh The mesh to free.
  48432. */
  48433. abstract _disposeMesh(mesh: Mesh): void;
  48434. /**
  48435. * Serializes this layer (Glow or Highlight for example)
  48436. * @returns a serialized layer object
  48437. */
  48438. abstract serialize?(): any;
  48439. /**
  48440. * Initializes the effect layer with the required options.
  48441. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48442. */
  48443. protected _init(options: Partial<IEffectLayerOptions>): void;
  48444. /**
  48445. * Generates the index buffer of the full screen quad blending to the main canvas.
  48446. */
  48447. private _generateIndexBuffer;
  48448. /**
  48449. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48450. */
  48451. private _genrateVertexBuffer;
  48452. /**
  48453. * Sets the main texture desired size which is the closest power of two
  48454. * of the engine canvas size.
  48455. */
  48456. private _setMainTextureSize;
  48457. /**
  48458. * Creates the main texture for the effect layer.
  48459. */
  48460. protected _createMainTexture(): void;
  48461. /**
  48462. * Adds specific effects defines.
  48463. * @param defines The defines to add specifics to.
  48464. */
  48465. protected _addCustomEffectDefines(defines: string[]): void;
  48466. /**
  48467. * Checks for the readiness of the element composing the layer.
  48468. * @param subMesh the mesh to check for
  48469. * @param useInstances specify wether or not to use instances to render the mesh
  48470. * @param emissiveTexture the associated emissive texture used to generate the glow
  48471. * @return true if ready otherwise, false
  48472. */
  48473. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48474. /**
  48475. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48476. */
  48477. render(): void;
  48478. /**
  48479. * Determine if a given mesh will be used in the current effect.
  48480. * @param mesh mesh to test
  48481. * @returns true if the mesh will be used
  48482. */
  48483. hasMesh(mesh: AbstractMesh): boolean;
  48484. /**
  48485. * Returns true if the layer contains information to display, otherwise false.
  48486. * @returns true if the glow layer should be rendered
  48487. */
  48488. shouldRender(): boolean;
  48489. /**
  48490. * Returns true if the mesh should render, otherwise false.
  48491. * @param mesh The mesh to render
  48492. * @returns true if it should render otherwise false
  48493. */
  48494. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48495. /**
  48496. * Returns true if the mesh can be rendered, otherwise false.
  48497. * @param mesh The mesh to render
  48498. * @param material The material used on the mesh
  48499. * @returns true if it can be rendered otherwise false
  48500. */
  48501. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48502. /**
  48503. * Returns true if the mesh should render, otherwise false.
  48504. * @param mesh The mesh to render
  48505. * @returns true if it should render otherwise false
  48506. */
  48507. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48508. /**
  48509. * Renders the submesh passed in parameter to the generation map.
  48510. */
  48511. protected _renderSubMesh(subMesh: SubMesh): void;
  48512. /**
  48513. * Rebuild the required buffers.
  48514. * @hidden Internal use only.
  48515. */
  48516. _rebuild(): void;
  48517. /**
  48518. * Dispose only the render target textures and post process.
  48519. */
  48520. private _disposeTextureAndPostProcesses;
  48521. /**
  48522. * Dispose the highlight layer and free resources.
  48523. */
  48524. dispose(): void;
  48525. /**
  48526. * Gets the class name of the effect layer
  48527. * @returns the string with the class name of the effect layer
  48528. */
  48529. getClassName(): string;
  48530. /**
  48531. * Creates an effect layer from parsed effect layer data
  48532. * @param parsedEffectLayer defines effect layer data
  48533. * @param scene defines the current scene
  48534. * @param rootUrl defines the root URL containing the effect layer information
  48535. * @returns a parsed effect Layer
  48536. */
  48537. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48538. }
  48539. }
  48540. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48541. import { Scene } from "babylonjs/scene";
  48542. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48543. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48544. import { AbstractScene } from "babylonjs/abstractScene";
  48545. module "babylonjs/abstractScene" {
  48546. interface AbstractScene {
  48547. /**
  48548. * The list of effect layers (highlights/glow) added to the scene
  48549. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48550. * @see http://doc.babylonjs.com/how_to/glow_layer
  48551. */
  48552. effectLayers: Array<EffectLayer>;
  48553. /**
  48554. * Removes the given effect layer from this scene.
  48555. * @param toRemove defines the effect layer to remove
  48556. * @returns the index of the removed effect layer
  48557. */
  48558. removeEffectLayer(toRemove: EffectLayer): number;
  48559. /**
  48560. * Adds the given effect layer to this scene
  48561. * @param newEffectLayer defines the effect layer to add
  48562. */
  48563. addEffectLayer(newEffectLayer: EffectLayer): void;
  48564. }
  48565. }
  48566. /**
  48567. * Defines the layer scene component responsible to manage any effect layers
  48568. * in a given scene.
  48569. */
  48570. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48571. /**
  48572. * The component name helpfull to identify the component in the list of scene components.
  48573. */
  48574. readonly name: string;
  48575. /**
  48576. * The scene the component belongs to.
  48577. */
  48578. scene: Scene;
  48579. private _engine;
  48580. private _renderEffects;
  48581. private _needStencil;
  48582. private _previousStencilState;
  48583. /**
  48584. * Creates a new instance of the component for the given scene
  48585. * @param scene Defines the scene to register the component in
  48586. */
  48587. constructor(scene: Scene);
  48588. /**
  48589. * Registers the component in a given scene
  48590. */
  48591. register(): void;
  48592. /**
  48593. * Rebuilds the elements related to this component in case of
  48594. * context lost for instance.
  48595. */
  48596. rebuild(): void;
  48597. /**
  48598. * Serializes the component data to the specified json object
  48599. * @param serializationObject The object to serialize to
  48600. */
  48601. serialize(serializationObject: any): void;
  48602. /**
  48603. * Adds all the element from the container to the scene
  48604. * @param container the container holding the elements
  48605. */
  48606. addFromContainer(container: AbstractScene): void;
  48607. /**
  48608. * Removes all the elements in the container from the scene
  48609. * @param container contains the elements to remove
  48610. * @param dispose if the removed element should be disposed (default: false)
  48611. */
  48612. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48613. /**
  48614. * Disposes the component and the associated ressources.
  48615. */
  48616. dispose(): void;
  48617. private _isReadyForMesh;
  48618. private _renderMainTexture;
  48619. private _setStencil;
  48620. private _setStencilBack;
  48621. private _draw;
  48622. private _drawCamera;
  48623. private _drawRenderingGroup;
  48624. }
  48625. }
  48626. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48627. /** @hidden */
  48628. export var glowMapMergePixelShader: {
  48629. name: string;
  48630. shader: string;
  48631. };
  48632. }
  48633. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48634. /** @hidden */
  48635. export var glowMapMergeVertexShader: {
  48636. name: string;
  48637. shader: string;
  48638. };
  48639. }
  48640. declare module "babylonjs/Layers/glowLayer" {
  48641. import { Nullable } from "babylonjs/types";
  48642. import { Camera } from "babylonjs/Cameras/camera";
  48643. import { Scene } from "babylonjs/scene";
  48644. import { Color4 } from "babylonjs/Maths/math";
  48645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48647. import { Mesh } from "babylonjs/Meshes/mesh";
  48648. import { Texture } from "babylonjs/Materials/Textures/texture";
  48649. import { Effect } from "babylonjs/Materials/effect";
  48650. import { Material } from "babylonjs/Materials/material";
  48651. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48652. import "babylonjs/Shaders/glowMapMerge.fragment";
  48653. import "babylonjs/Shaders/glowMapMerge.vertex";
  48654. import "babylonjs/Layers/effectLayerSceneComponent";
  48655. module "babylonjs/abstractScene" {
  48656. interface AbstractScene {
  48657. /**
  48658. * Return a the first highlight layer of the scene with a given name.
  48659. * @param name The name of the highlight layer to look for.
  48660. * @return The highlight layer if found otherwise null.
  48661. */
  48662. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48663. }
  48664. }
  48665. /**
  48666. * Glow layer options. This helps customizing the behaviour
  48667. * of the glow layer.
  48668. */
  48669. export interface IGlowLayerOptions {
  48670. /**
  48671. * Multiplication factor apply to the canvas size to compute the render target size
  48672. * used to generated the glowing objects (the smaller the faster).
  48673. */
  48674. mainTextureRatio: number;
  48675. /**
  48676. * Enforces a fixed size texture to ensure resize independant blur.
  48677. */
  48678. mainTextureFixedSize?: number;
  48679. /**
  48680. * How big is the kernel of the blur texture.
  48681. */
  48682. blurKernelSize: number;
  48683. /**
  48684. * The camera attached to the layer.
  48685. */
  48686. camera: Nullable<Camera>;
  48687. /**
  48688. * Enable MSAA by chosing the number of samples.
  48689. */
  48690. mainTextureSamples?: number;
  48691. /**
  48692. * The rendering group to draw the layer in.
  48693. */
  48694. renderingGroupId: number;
  48695. }
  48696. /**
  48697. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48698. *
  48699. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48700. * glowy meshes to your scene.
  48701. *
  48702. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48703. */
  48704. export class GlowLayer extends EffectLayer {
  48705. /**
  48706. * Effect Name of the layer.
  48707. */
  48708. static readonly EffectName: string;
  48709. /**
  48710. * The default blur kernel size used for the glow.
  48711. */
  48712. static DefaultBlurKernelSize: number;
  48713. /**
  48714. * The default texture size ratio used for the glow.
  48715. */
  48716. static DefaultTextureRatio: number;
  48717. /**
  48718. * Sets the kernel size of the blur.
  48719. */
  48720. /**
  48721. * Gets the kernel size of the blur.
  48722. */
  48723. blurKernelSize: number;
  48724. /**
  48725. * Sets the glow intensity.
  48726. */
  48727. /**
  48728. * Gets the glow intensity.
  48729. */
  48730. intensity: number;
  48731. private _options;
  48732. private _intensity;
  48733. private _horizontalBlurPostprocess1;
  48734. private _verticalBlurPostprocess1;
  48735. private _horizontalBlurPostprocess2;
  48736. private _verticalBlurPostprocess2;
  48737. private _blurTexture1;
  48738. private _blurTexture2;
  48739. private _postProcesses1;
  48740. private _postProcesses2;
  48741. private _includedOnlyMeshes;
  48742. private _excludedMeshes;
  48743. /**
  48744. * Callback used to let the user override the color selection on a per mesh basis
  48745. */
  48746. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48747. /**
  48748. * Callback used to let the user override the texture selection on a per mesh basis
  48749. */
  48750. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48751. /**
  48752. * Instantiates a new glow Layer and references it to the scene.
  48753. * @param name The name of the layer
  48754. * @param scene The scene to use the layer in
  48755. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48756. */
  48757. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48758. /**
  48759. * Get the effect name of the layer.
  48760. * @return The effect name
  48761. */
  48762. getEffectName(): string;
  48763. /**
  48764. * Create the merge effect. This is the shader use to blit the information back
  48765. * to the main canvas at the end of the scene rendering.
  48766. */
  48767. protected _createMergeEffect(): Effect;
  48768. /**
  48769. * Creates the render target textures and post processes used in the glow layer.
  48770. */
  48771. protected _createTextureAndPostProcesses(): void;
  48772. /**
  48773. * Checks for the readiness of the element composing the layer.
  48774. * @param subMesh the mesh to check for
  48775. * @param useInstances specify wether or not to use instances to render the mesh
  48776. * @param emissiveTexture the associated emissive texture used to generate the glow
  48777. * @return true if ready otherwise, false
  48778. */
  48779. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48780. /**
  48781. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48782. */
  48783. needStencil(): boolean;
  48784. /**
  48785. * Returns true if the mesh can be rendered, otherwise false.
  48786. * @param mesh The mesh to render
  48787. * @param material The material used on the mesh
  48788. * @returns true if it can be rendered otherwise false
  48789. */
  48790. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48791. /**
  48792. * Implementation specific of rendering the generating effect on the main canvas.
  48793. * @param effect The effect used to render through
  48794. */
  48795. protected _internalRender(effect: Effect): void;
  48796. /**
  48797. * Sets the required values for both the emissive texture and and the main color.
  48798. */
  48799. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48800. /**
  48801. * Returns true if the mesh should render, otherwise false.
  48802. * @param mesh The mesh to render
  48803. * @returns true if it should render otherwise false
  48804. */
  48805. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48806. /**
  48807. * Adds specific effects defines.
  48808. * @param defines The defines to add specifics to.
  48809. */
  48810. protected _addCustomEffectDefines(defines: string[]): void;
  48811. /**
  48812. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48813. * @param mesh The mesh to exclude from the glow layer
  48814. */
  48815. addExcludedMesh(mesh: Mesh): void;
  48816. /**
  48817. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48818. * @param mesh The mesh to remove
  48819. */
  48820. removeExcludedMesh(mesh: Mesh): void;
  48821. /**
  48822. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48823. * @param mesh The mesh to include in the glow layer
  48824. */
  48825. addIncludedOnlyMesh(mesh: Mesh): void;
  48826. /**
  48827. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48828. * @param mesh The mesh to remove
  48829. */
  48830. removeIncludedOnlyMesh(mesh: Mesh): void;
  48831. /**
  48832. * Determine if a given mesh will be used in the glow layer
  48833. * @param mesh The mesh to test
  48834. * @returns true if the mesh will be highlighted by the current glow layer
  48835. */
  48836. hasMesh(mesh: AbstractMesh): boolean;
  48837. /**
  48838. * Free any resources and references associated to a mesh.
  48839. * Internal use
  48840. * @param mesh The mesh to free.
  48841. * @hidden
  48842. */
  48843. _disposeMesh(mesh: Mesh): void;
  48844. /**
  48845. * Gets the class name of the effect layer
  48846. * @returns the string with the class name of the effect layer
  48847. */
  48848. getClassName(): string;
  48849. /**
  48850. * Serializes this glow layer
  48851. * @returns a serialized glow layer object
  48852. */
  48853. serialize(): any;
  48854. /**
  48855. * Creates a Glow Layer from parsed glow layer data
  48856. * @param parsedGlowLayer defines glow layer data
  48857. * @param scene defines the current scene
  48858. * @param rootUrl defines the root URL containing the glow layer information
  48859. * @returns a parsed Glow Layer
  48860. */
  48861. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48862. }
  48863. }
  48864. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48865. /** @hidden */
  48866. export var glowBlurPostProcessPixelShader: {
  48867. name: string;
  48868. shader: string;
  48869. };
  48870. }
  48871. declare module "babylonjs/Layers/highlightLayer" {
  48872. import { Observable } from "babylonjs/Misc/observable";
  48873. import { Nullable } from "babylonjs/types";
  48874. import { Camera } from "babylonjs/Cameras/camera";
  48875. import { Scene } from "babylonjs/scene";
  48876. import { Color3, Color4 } from "babylonjs/Maths/math";
  48877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48879. import { Mesh } from "babylonjs/Meshes/mesh";
  48880. import { Effect } from "babylonjs/Materials/effect";
  48881. import { Material } from "babylonjs/Materials/material";
  48882. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48883. import "babylonjs/Shaders/glowMapMerge.fragment";
  48884. import "babylonjs/Shaders/glowMapMerge.vertex";
  48885. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48886. module "babylonjs/abstractScene" {
  48887. interface AbstractScene {
  48888. /**
  48889. * Return a the first highlight layer of the scene with a given name.
  48890. * @param name The name of the highlight layer to look for.
  48891. * @return The highlight layer if found otherwise null.
  48892. */
  48893. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48894. }
  48895. }
  48896. /**
  48897. * Highlight layer options. This helps customizing the behaviour
  48898. * of the highlight layer.
  48899. */
  48900. export interface IHighlightLayerOptions {
  48901. /**
  48902. * Multiplication factor apply to the canvas size to compute the render target size
  48903. * used to generated the glowing objects (the smaller the faster).
  48904. */
  48905. mainTextureRatio: number;
  48906. /**
  48907. * Enforces a fixed size texture to ensure resize independant blur.
  48908. */
  48909. mainTextureFixedSize?: number;
  48910. /**
  48911. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48912. * of the picture to blur (the smaller the faster).
  48913. */
  48914. blurTextureSizeRatio: number;
  48915. /**
  48916. * How big in texel of the blur texture is the vertical blur.
  48917. */
  48918. blurVerticalSize: number;
  48919. /**
  48920. * How big in texel of the blur texture is the horizontal blur.
  48921. */
  48922. blurHorizontalSize: number;
  48923. /**
  48924. * Alpha blending mode used to apply the blur. Default is combine.
  48925. */
  48926. alphaBlendingMode: number;
  48927. /**
  48928. * The camera attached to the layer.
  48929. */
  48930. camera: Nullable<Camera>;
  48931. /**
  48932. * Should we display highlight as a solid stroke?
  48933. */
  48934. isStroke?: boolean;
  48935. /**
  48936. * The rendering group to draw the layer in.
  48937. */
  48938. renderingGroupId: number;
  48939. }
  48940. /**
  48941. * The highlight layer Helps adding a glow effect around a mesh.
  48942. *
  48943. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48944. * glowy meshes to your scene.
  48945. *
  48946. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48947. */
  48948. export class HighlightLayer extends EffectLayer {
  48949. name: string;
  48950. /**
  48951. * Effect Name of the highlight layer.
  48952. */
  48953. static readonly EffectName: string;
  48954. /**
  48955. * The neutral color used during the preparation of the glow effect.
  48956. * This is black by default as the blend operation is a blend operation.
  48957. */
  48958. static NeutralColor: Color4;
  48959. /**
  48960. * Stencil value used for glowing meshes.
  48961. */
  48962. static GlowingMeshStencilReference: number;
  48963. /**
  48964. * Stencil value used for the other meshes in the scene.
  48965. */
  48966. static NormalMeshStencilReference: number;
  48967. /**
  48968. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48969. */
  48970. innerGlow: boolean;
  48971. /**
  48972. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48973. */
  48974. outerGlow: boolean;
  48975. /**
  48976. * Specifies the horizontal size of the blur.
  48977. */
  48978. /**
  48979. * Gets the horizontal size of the blur.
  48980. */
  48981. blurHorizontalSize: number;
  48982. /**
  48983. * Specifies the vertical size of the blur.
  48984. */
  48985. /**
  48986. * Gets the vertical size of the blur.
  48987. */
  48988. blurVerticalSize: number;
  48989. /**
  48990. * An event triggered when the highlight layer is being blurred.
  48991. */
  48992. onBeforeBlurObservable: Observable<HighlightLayer>;
  48993. /**
  48994. * An event triggered when the highlight layer has been blurred.
  48995. */
  48996. onAfterBlurObservable: Observable<HighlightLayer>;
  48997. private _instanceGlowingMeshStencilReference;
  48998. private _options;
  48999. private _downSamplePostprocess;
  49000. private _horizontalBlurPostprocess;
  49001. private _verticalBlurPostprocess;
  49002. private _blurTexture;
  49003. private _meshes;
  49004. private _excludedMeshes;
  49005. /**
  49006. * Instantiates a new highlight Layer and references it to the scene..
  49007. * @param name The name of the layer
  49008. * @param scene The scene to use the layer in
  49009. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49010. */
  49011. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49012. /**
  49013. * Get the effect name of the layer.
  49014. * @return The effect name
  49015. */
  49016. getEffectName(): string;
  49017. /**
  49018. * Create the merge effect. This is the shader use to blit the information back
  49019. * to the main canvas at the end of the scene rendering.
  49020. */
  49021. protected _createMergeEffect(): Effect;
  49022. /**
  49023. * Creates the render target textures and post processes used in the highlight layer.
  49024. */
  49025. protected _createTextureAndPostProcesses(): void;
  49026. /**
  49027. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49028. */
  49029. needStencil(): boolean;
  49030. /**
  49031. * Checks for the readiness of the element composing the layer.
  49032. * @param subMesh the mesh to check for
  49033. * @param useInstances specify wether or not to use instances to render the mesh
  49034. * @param emissiveTexture the associated emissive texture used to generate the glow
  49035. * @return true if ready otherwise, false
  49036. */
  49037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49038. /**
  49039. * Implementation specific of rendering the generating effect on the main canvas.
  49040. * @param effect The effect used to render through
  49041. */
  49042. protected _internalRender(effect: Effect): void;
  49043. /**
  49044. * Returns true if the layer contains information to display, otherwise false.
  49045. */
  49046. shouldRender(): boolean;
  49047. /**
  49048. * Returns true if the mesh should render, otherwise false.
  49049. * @param mesh The mesh to render
  49050. * @returns true if it should render otherwise false
  49051. */
  49052. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49053. /**
  49054. * Sets the required values for both the emissive texture and and the main color.
  49055. */
  49056. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49057. /**
  49058. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49059. * @param mesh The mesh to exclude from the highlight layer
  49060. */
  49061. addExcludedMesh(mesh: Mesh): void;
  49062. /**
  49063. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49064. * @param mesh The mesh to highlight
  49065. */
  49066. removeExcludedMesh(mesh: Mesh): void;
  49067. /**
  49068. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49069. * @param mesh mesh to test
  49070. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49071. */
  49072. hasMesh(mesh: AbstractMesh): boolean;
  49073. /**
  49074. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49075. * @param mesh The mesh to highlight
  49076. * @param color The color of the highlight
  49077. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49078. */
  49079. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49080. /**
  49081. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49082. * @param mesh The mesh to highlight
  49083. */
  49084. removeMesh(mesh: Mesh): void;
  49085. /**
  49086. * Force the stencil to the normal expected value for none glowing parts
  49087. */
  49088. private _defaultStencilReference;
  49089. /**
  49090. * Free any resources and references associated to a mesh.
  49091. * Internal use
  49092. * @param mesh The mesh to free.
  49093. * @hidden
  49094. */
  49095. _disposeMesh(mesh: Mesh): void;
  49096. /**
  49097. * Dispose the highlight layer and free resources.
  49098. */
  49099. dispose(): void;
  49100. /**
  49101. * Gets the class name of the effect layer
  49102. * @returns the string with the class name of the effect layer
  49103. */
  49104. getClassName(): string;
  49105. /**
  49106. * Serializes this Highlight layer
  49107. * @returns a serialized Highlight layer object
  49108. */
  49109. serialize(): any;
  49110. /**
  49111. * Creates a Highlight layer from parsed Highlight layer data
  49112. * @param parsedHightlightLayer defines the Highlight layer data
  49113. * @param scene defines the current scene
  49114. * @param rootUrl defines the root URL containing the Highlight layer information
  49115. * @returns a parsed Highlight layer
  49116. */
  49117. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49118. }
  49119. }
  49120. declare module "babylonjs/Layers/index" {
  49121. export * from "babylonjs/Layers/effectLayer";
  49122. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49123. export * from "babylonjs/Layers/glowLayer";
  49124. export * from "babylonjs/Layers/highlightLayer";
  49125. export * from "babylonjs/Layers/layer";
  49126. export * from "babylonjs/Layers/layerSceneComponent";
  49127. }
  49128. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49129. /** @hidden */
  49130. export var lensFlarePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49136. /** @hidden */
  49137. export var lensFlareVertexShader: {
  49138. name: string;
  49139. shader: string;
  49140. };
  49141. }
  49142. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49143. import { Scene } from "babylonjs/scene";
  49144. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49146. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49147. import "babylonjs/Shaders/lensFlare.fragment";
  49148. import "babylonjs/Shaders/lensFlare.vertex";
  49149. /**
  49150. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49151. * It is usually composed of several `lensFlare`.
  49152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49153. */
  49154. export class LensFlareSystem {
  49155. /**
  49156. * Define the name of the lens flare system
  49157. */
  49158. name: string;
  49159. /**
  49160. * List of lens flares used in this system.
  49161. */
  49162. lensFlares: LensFlare[];
  49163. /**
  49164. * Define a limit from the border the lens flare can be visible.
  49165. */
  49166. borderLimit: number;
  49167. /**
  49168. * Define a viewport border we do not want to see the lens flare in.
  49169. */
  49170. viewportBorder: number;
  49171. /**
  49172. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49173. */
  49174. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49175. /**
  49176. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49177. */
  49178. layerMask: number;
  49179. /**
  49180. * Define the id of the lens flare system in the scene.
  49181. * (equal to name by default)
  49182. */
  49183. id: string;
  49184. private _scene;
  49185. private _emitter;
  49186. private _vertexBuffers;
  49187. private _indexBuffer;
  49188. private _effect;
  49189. private _positionX;
  49190. private _positionY;
  49191. private _isEnabled;
  49192. /** @hidden */
  49193. static _SceneComponentInitialization: (scene: Scene) => void;
  49194. /**
  49195. * Instantiates a lens flare system.
  49196. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49197. * It is usually composed of several `lensFlare`.
  49198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49199. * @param name Define the name of the lens flare system in the scene
  49200. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49201. * @param scene Define the scene the lens flare system belongs to
  49202. */
  49203. constructor(
  49204. /**
  49205. * Define the name of the lens flare system
  49206. */
  49207. name: string, emitter: any, scene: Scene);
  49208. /**
  49209. * Define if the lens flare system is enabled.
  49210. */
  49211. isEnabled: boolean;
  49212. /**
  49213. * Get the scene the effects belongs to.
  49214. * @returns the scene holding the lens flare system
  49215. */
  49216. getScene(): Scene;
  49217. /**
  49218. * Get the emitter of the lens flare system.
  49219. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49220. * @returns the emitter of the lens flare system
  49221. */
  49222. getEmitter(): any;
  49223. /**
  49224. * Set the emitter of the lens flare system.
  49225. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49226. * @param newEmitter Define the new emitter of the system
  49227. */
  49228. setEmitter(newEmitter: any): void;
  49229. /**
  49230. * Get the lens flare system emitter position.
  49231. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49232. * @returns the position
  49233. */
  49234. getEmitterPosition(): Vector3;
  49235. /**
  49236. * @hidden
  49237. */
  49238. computeEffectivePosition(globalViewport: Viewport): boolean;
  49239. /** @hidden */
  49240. _isVisible(): boolean;
  49241. /**
  49242. * @hidden
  49243. */
  49244. render(): boolean;
  49245. /**
  49246. * Dispose and release the lens flare with its associated resources.
  49247. */
  49248. dispose(): void;
  49249. /**
  49250. * Parse a lens flare system from a JSON repressentation
  49251. * @param parsedLensFlareSystem Define the JSON to parse
  49252. * @param scene Define the scene the parsed system should be instantiated in
  49253. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49254. * @returns the parsed system
  49255. */
  49256. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49257. /**
  49258. * Serialize the current Lens Flare System into a JSON representation.
  49259. * @returns the serialized JSON
  49260. */
  49261. serialize(): any;
  49262. }
  49263. }
  49264. declare module "babylonjs/LensFlares/lensFlare" {
  49265. import { Nullable } from "babylonjs/types";
  49266. import { Color3 } from "babylonjs/Maths/math";
  49267. import { Texture } from "babylonjs/Materials/Textures/texture";
  49268. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49269. /**
  49270. * This represents one of the lens effect in a `lensFlareSystem`.
  49271. * It controls one of the indiviual texture used in the effect.
  49272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49273. */
  49274. export class LensFlare {
  49275. /**
  49276. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49277. */
  49278. size: number;
  49279. /**
  49280. * 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.
  49281. */
  49282. position: number;
  49283. /**
  49284. * Define the lens color.
  49285. */
  49286. color: Color3;
  49287. /**
  49288. * Define the lens texture.
  49289. */
  49290. texture: Nullable<Texture>;
  49291. /**
  49292. * Define the alpha mode to render this particular lens.
  49293. */
  49294. alphaMode: number;
  49295. private _system;
  49296. /**
  49297. * Creates a new Lens Flare.
  49298. * This represents one of the lens effect in a `lensFlareSystem`.
  49299. * It controls one of the indiviual texture used in the effect.
  49300. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49301. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49302. * @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.
  49303. * @param color Define the lens color
  49304. * @param imgUrl Define the lens texture url
  49305. * @param system Define the `lensFlareSystem` this flare is part of
  49306. * @returns The newly created Lens Flare
  49307. */
  49308. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49309. /**
  49310. * Instantiates a new Lens Flare.
  49311. * This represents one of the lens effect in a `lensFlareSystem`.
  49312. * It controls one of the indiviual texture used in the effect.
  49313. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49314. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49315. * @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.
  49316. * @param color Define the lens color
  49317. * @param imgUrl Define the lens texture url
  49318. * @param system Define the `lensFlareSystem` this flare is part of
  49319. */
  49320. constructor(
  49321. /**
  49322. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49323. */
  49324. size: number,
  49325. /**
  49326. * 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.
  49327. */
  49328. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49329. /**
  49330. * Dispose and release the lens flare with its associated resources.
  49331. */
  49332. dispose(): void;
  49333. }
  49334. }
  49335. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49336. import { Nullable } from "babylonjs/types";
  49337. import { Scene } from "babylonjs/scene";
  49338. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49339. import { AbstractScene } from "babylonjs/abstractScene";
  49340. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49341. module "babylonjs/abstractScene" {
  49342. interface AbstractScene {
  49343. /**
  49344. * The list of lens flare system added to the scene
  49345. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49346. */
  49347. lensFlareSystems: Array<LensFlareSystem>;
  49348. /**
  49349. * Removes the given lens flare system from this scene.
  49350. * @param toRemove The lens flare system to remove
  49351. * @returns The index of the removed lens flare system
  49352. */
  49353. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49354. /**
  49355. * Adds the given lens flare system to this scene
  49356. * @param newLensFlareSystem The lens flare system to add
  49357. */
  49358. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49359. /**
  49360. * Gets a lens flare system using its name
  49361. * @param name defines the name to look for
  49362. * @returns the lens flare system or null if not found
  49363. */
  49364. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49365. /**
  49366. * Gets a lens flare system using its id
  49367. * @param id defines the id to look for
  49368. * @returns the lens flare system or null if not found
  49369. */
  49370. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49371. }
  49372. }
  49373. /**
  49374. * Defines the lens flare scene component responsible to manage any lens flares
  49375. * in a given scene.
  49376. */
  49377. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49378. /**
  49379. * The component name helpfull to identify the component in the list of scene components.
  49380. */
  49381. readonly name: string;
  49382. /**
  49383. * The scene the component belongs to.
  49384. */
  49385. scene: Scene;
  49386. /**
  49387. * Creates a new instance of the component for the given scene
  49388. * @param scene Defines the scene to register the component in
  49389. */
  49390. constructor(scene: Scene);
  49391. /**
  49392. * Registers the component in a given scene
  49393. */
  49394. register(): void;
  49395. /**
  49396. * Rebuilds the elements related to this component in case of
  49397. * context lost for instance.
  49398. */
  49399. rebuild(): void;
  49400. /**
  49401. * Adds all the element from the container to the scene
  49402. * @param container the container holding the elements
  49403. */
  49404. addFromContainer(container: AbstractScene): void;
  49405. /**
  49406. * Removes all the elements in the container from the scene
  49407. * @param container contains the elements to remove
  49408. * @param dispose if the removed element should be disposed (default: false)
  49409. */
  49410. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49411. /**
  49412. * Serializes the component data to the specified json object
  49413. * @param serializationObject The object to serialize to
  49414. */
  49415. serialize(serializationObject: any): void;
  49416. /**
  49417. * Disposes the component and the associated ressources.
  49418. */
  49419. dispose(): void;
  49420. private _draw;
  49421. }
  49422. }
  49423. declare module "babylonjs/LensFlares/index" {
  49424. export * from "babylonjs/LensFlares/lensFlare";
  49425. export * from "babylonjs/LensFlares/lensFlareSystem";
  49426. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49427. }
  49428. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49429. import { Scene } from "babylonjs/scene";
  49430. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49431. import { AbstractScene } from "babylonjs/abstractScene";
  49432. /**
  49433. * Defines the shadow generator component responsible to manage any shadow generators
  49434. * in a given scene.
  49435. */
  49436. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49437. /**
  49438. * The component name helpfull to identify the component in the list of scene components.
  49439. */
  49440. readonly name: string;
  49441. /**
  49442. * The scene the component belongs to.
  49443. */
  49444. scene: Scene;
  49445. /**
  49446. * Creates a new instance of the component for the given scene
  49447. * @param scene Defines the scene to register the component in
  49448. */
  49449. constructor(scene: Scene);
  49450. /**
  49451. * Registers the component in a given scene
  49452. */
  49453. register(): void;
  49454. /**
  49455. * Rebuilds the elements related to this component in case of
  49456. * context lost for instance.
  49457. */
  49458. rebuild(): void;
  49459. /**
  49460. * Serializes the component data to the specified json object
  49461. * @param serializationObject The object to serialize to
  49462. */
  49463. serialize(serializationObject: any): void;
  49464. /**
  49465. * Adds all the element from the container to the scene
  49466. * @param container the container holding the elements
  49467. */
  49468. addFromContainer(container: AbstractScene): void;
  49469. /**
  49470. * Removes all the elements in the container from the scene
  49471. * @param container contains the elements to remove
  49472. * @param dispose if the removed element should be disposed (default: false)
  49473. */
  49474. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49475. /**
  49476. * Rebuilds the elements related to this component in case of
  49477. * context lost for instance.
  49478. */
  49479. dispose(): void;
  49480. private _gatherRenderTargets;
  49481. }
  49482. }
  49483. declare module "babylonjs/Lights/Shadows/index" {
  49484. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49485. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49486. }
  49487. declare module "babylonjs/Lights/pointLight" {
  49488. import { Scene } from "babylonjs/scene";
  49489. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49491. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49492. import { Effect } from "babylonjs/Materials/effect";
  49493. /**
  49494. * A point light is a light defined by an unique point in world space.
  49495. * The light is emitted in every direction from this point.
  49496. * A good example of a point light is a standard light bulb.
  49497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49498. */
  49499. export class PointLight extends ShadowLight {
  49500. private _shadowAngle;
  49501. /**
  49502. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49503. * This specifies what angle the shadow will use to be created.
  49504. *
  49505. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49506. */
  49507. /**
  49508. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49509. * This specifies what angle the shadow will use to be created.
  49510. *
  49511. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49512. */
  49513. shadowAngle: number;
  49514. /**
  49515. * Gets the direction if it has been set.
  49516. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49517. */
  49518. /**
  49519. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49520. */
  49521. direction: Vector3;
  49522. /**
  49523. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49524. * A PointLight emits the light in every direction.
  49525. * It can cast shadows.
  49526. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49527. * ```javascript
  49528. * var pointLight = new PointLight("pl", camera.position, scene);
  49529. * ```
  49530. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49531. * @param name The light friendly name
  49532. * @param position The position of the point light in the scene
  49533. * @param scene The scene the lights belongs to
  49534. */
  49535. constructor(name: string, position: Vector3, scene: Scene);
  49536. /**
  49537. * Returns the string "PointLight"
  49538. * @returns the class name
  49539. */
  49540. getClassName(): string;
  49541. /**
  49542. * Returns the integer 0.
  49543. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49544. */
  49545. getTypeID(): number;
  49546. /**
  49547. * Specifies wether or not the shadowmap should be a cube texture.
  49548. * @returns true if the shadowmap needs to be a cube texture.
  49549. */
  49550. needCube(): boolean;
  49551. /**
  49552. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49553. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49554. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49555. */
  49556. getShadowDirection(faceIndex?: number): Vector3;
  49557. /**
  49558. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49559. * - fov = PI / 2
  49560. * - aspect ratio : 1.0
  49561. * - z-near and far equal to the active camera minZ and maxZ.
  49562. * Returns the PointLight.
  49563. */
  49564. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49565. protected _buildUniformLayout(): void;
  49566. /**
  49567. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49568. * @param effect The effect to update
  49569. * @param lightIndex The index of the light in the effect to update
  49570. * @returns The point light
  49571. */
  49572. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49573. /**
  49574. * Prepares the list of defines specific to the light type.
  49575. * @param defines the list of defines
  49576. * @param lightIndex defines the index of the light for the effect
  49577. */
  49578. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49579. }
  49580. }
  49581. declare module "babylonjs/Lights/index" {
  49582. export * from "babylonjs/Lights/light";
  49583. export * from "babylonjs/Lights/shadowLight";
  49584. export * from "babylonjs/Lights/Shadows/index";
  49585. export * from "babylonjs/Lights/directionalLight";
  49586. export * from "babylonjs/Lights/hemisphericLight";
  49587. export * from "babylonjs/Lights/pointLight";
  49588. export * from "babylonjs/Lights/spotLight";
  49589. }
  49590. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49591. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49592. /**
  49593. * Header information of HDR texture files.
  49594. */
  49595. export interface HDRInfo {
  49596. /**
  49597. * The height of the texture in pixels.
  49598. */
  49599. height: number;
  49600. /**
  49601. * The width of the texture in pixels.
  49602. */
  49603. width: number;
  49604. /**
  49605. * The index of the beginning of the data in the binary file.
  49606. */
  49607. dataPosition: number;
  49608. }
  49609. /**
  49610. * This groups tools to convert HDR texture to native colors array.
  49611. */
  49612. export class HDRTools {
  49613. private static Ldexp;
  49614. private static Rgbe2float;
  49615. private static readStringLine;
  49616. /**
  49617. * Reads header information from an RGBE texture stored in a native array.
  49618. * More information on this format are available here:
  49619. * https://en.wikipedia.org/wiki/RGBE_image_format
  49620. *
  49621. * @param uint8array The binary file stored in native array.
  49622. * @return The header information.
  49623. */
  49624. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49625. /**
  49626. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49627. * This RGBE texture needs to store the information as a panorama.
  49628. *
  49629. * More information on this format are available here:
  49630. * https://en.wikipedia.org/wiki/RGBE_image_format
  49631. *
  49632. * @param buffer The binary file stored in an array buffer.
  49633. * @param size The expected size of the extracted cubemap.
  49634. * @return The Cube Map information.
  49635. */
  49636. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49637. /**
  49638. * Returns the pixels data extracted from an RGBE texture.
  49639. * This pixels will be stored left to right up to down in the R G B order in one array.
  49640. *
  49641. * More information on this format are available here:
  49642. * https://en.wikipedia.org/wiki/RGBE_image_format
  49643. *
  49644. * @param uint8array The binary file stored in an array buffer.
  49645. * @param hdrInfo The header information of the file.
  49646. * @return The pixels data in RGB right to left up to down order.
  49647. */
  49648. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49649. private static RGBE_ReadPixels_RLE;
  49650. }
  49651. }
  49652. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49653. import { Nullable } from "babylonjs/types";
  49654. import { Scene } from "babylonjs/scene";
  49655. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49657. /**
  49658. * This represents a texture coming from an HDR input.
  49659. *
  49660. * The only supported format is currently panorama picture stored in RGBE format.
  49661. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49662. */
  49663. export class HDRCubeTexture extends BaseTexture {
  49664. private static _facesMapping;
  49665. private _generateHarmonics;
  49666. private _noMipmap;
  49667. private _textureMatrix;
  49668. private _size;
  49669. private _onLoad;
  49670. private _onError;
  49671. /**
  49672. * The texture URL.
  49673. */
  49674. url: string;
  49675. /**
  49676. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49677. */
  49678. coordinatesMode: number;
  49679. protected _isBlocking: boolean;
  49680. /**
  49681. * Sets wether or not the texture is blocking during loading.
  49682. */
  49683. /**
  49684. * Gets wether or not the texture is blocking during loading.
  49685. */
  49686. isBlocking: boolean;
  49687. protected _rotationY: number;
  49688. /**
  49689. * Sets texture matrix rotation angle around Y axis in radians.
  49690. */
  49691. /**
  49692. * Gets texture matrix rotation angle around Y axis radians.
  49693. */
  49694. rotationY: number;
  49695. /**
  49696. * Gets or sets the center of the bounding box associated with the cube texture
  49697. * It must define where the camera used to render the texture was set
  49698. */
  49699. boundingBoxPosition: Vector3;
  49700. private _boundingBoxSize;
  49701. /**
  49702. * Gets or sets the size of the bounding box associated with the cube texture
  49703. * When defined, the cubemap will switch to local mode
  49704. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49705. * @example https://www.babylonjs-playground.com/#RNASML
  49706. */
  49707. boundingBoxSize: Vector3;
  49708. /**
  49709. * Instantiates an HDRTexture from the following parameters.
  49710. *
  49711. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49712. * @param scene The scene the texture will be used in
  49713. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49714. * @param noMipmap Forces to not generate the mipmap if true
  49715. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49716. * @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)
  49717. * @param reserved Reserved flag for internal use.
  49718. */
  49719. 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>);
  49720. /**
  49721. * Get the current class name of the texture useful for serialization or dynamic coding.
  49722. * @returns "HDRCubeTexture"
  49723. */
  49724. getClassName(): string;
  49725. /**
  49726. * Occurs when the file is raw .hdr file.
  49727. */
  49728. private loadTexture;
  49729. clone(): HDRCubeTexture;
  49730. delayLoad(): void;
  49731. /**
  49732. * Get the texture reflection matrix used to rotate/transform the reflection.
  49733. * @returns the reflection matrix
  49734. */
  49735. getReflectionTextureMatrix(): Matrix;
  49736. /**
  49737. * Set the texture reflection matrix used to rotate/transform the reflection.
  49738. * @param value Define the reflection matrix to set
  49739. */
  49740. setReflectionTextureMatrix(value: Matrix): void;
  49741. /**
  49742. * Parses a JSON representation of an HDR Texture in order to create the texture
  49743. * @param parsedTexture Define the JSON representation
  49744. * @param scene Define the scene the texture should be created in
  49745. * @param rootUrl Define the root url in case we need to load relative dependencies
  49746. * @returns the newly created texture after parsing
  49747. */
  49748. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49749. serialize(): any;
  49750. }
  49751. }
  49752. declare module "babylonjs/Physics/physicsEngine" {
  49753. import { Nullable } from "babylonjs/types";
  49754. import { Vector3 } from "babylonjs/Maths/math";
  49755. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49756. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49757. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49758. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49759. /**
  49760. * Class used to control physics engine
  49761. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49762. */
  49763. export class PhysicsEngine implements IPhysicsEngine {
  49764. private _physicsPlugin;
  49765. /**
  49766. * Global value used to control the smallest number supported by the simulation
  49767. */
  49768. static Epsilon: number;
  49769. private _impostors;
  49770. private _joints;
  49771. /**
  49772. * Gets the gravity vector used by the simulation
  49773. */
  49774. gravity: Vector3;
  49775. /**
  49776. * Factory used to create the default physics plugin.
  49777. * @returns The default physics plugin
  49778. */
  49779. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49780. /**
  49781. * Creates a new Physics Engine
  49782. * @param gravity defines the gravity vector used by the simulation
  49783. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49784. */
  49785. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49786. /**
  49787. * Sets the gravity vector used by the simulation
  49788. * @param gravity defines the gravity vector to use
  49789. */
  49790. setGravity(gravity: Vector3): void;
  49791. /**
  49792. * Set the time step of the physics engine.
  49793. * Default is 1/60.
  49794. * To slow it down, enter 1/600 for example.
  49795. * To speed it up, 1/30
  49796. * @param newTimeStep defines the new timestep to apply to this world.
  49797. */
  49798. setTimeStep(newTimeStep?: number): void;
  49799. /**
  49800. * Get the time step of the physics engine.
  49801. * @returns the current time step
  49802. */
  49803. getTimeStep(): number;
  49804. /**
  49805. * Release all resources
  49806. */
  49807. dispose(): void;
  49808. /**
  49809. * Gets the name of the current physics plugin
  49810. * @returns the name of the plugin
  49811. */
  49812. getPhysicsPluginName(): string;
  49813. /**
  49814. * Adding a new impostor for the impostor tracking.
  49815. * This will be done by the impostor itself.
  49816. * @param impostor the impostor to add
  49817. */
  49818. addImpostor(impostor: PhysicsImpostor): void;
  49819. /**
  49820. * Remove an impostor from the engine.
  49821. * This impostor and its mesh will not longer be updated by the physics engine.
  49822. * @param impostor the impostor to remove
  49823. */
  49824. removeImpostor(impostor: PhysicsImpostor): void;
  49825. /**
  49826. * Add a joint to the physics engine
  49827. * @param mainImpostor defines the main impostor to which the joint is added.
  49828. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49829. * @param joint defines the joint that will connect both impostors.
  49830. */
  49831. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49832. /**
  49833. * Removes a joint from the simulation
  49834. * @param mainImpostor defines the impostor used with the joint
  49835. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49836. * @param joint defines the joint to remove
  49837. */
  49838. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49839. /**
  49840. * Called by the scene. No need to call it.
  49841. * @param delta defines the timespam between frames
  49842. */
  49843. _step(delta: number): void;
  49844. /**
  49845. * Gets the current plugin used to run the simulation
  49846. * @returns current plugin
  49847. */
  49848. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49849. /**
  49850. * Gets the list of physic impostors
  49851. * @returns an array of PhysicsImpostor
  49852. */
  49853. getImpostors(): Array<PhysicsImpostor>;
  49854. /**
  49855. * Gets the impostor for a physics enabled object
  49856. * @param object defines the object impersonated by the impostor
  49857. * @returns the PhysicsImpostor or null if not found
  49858. */
  49859. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49860. /**
  49861. * Gets the impostor for a physics body object
  49862. * @param body defines physics body used by the impostor
  49863. * @returns the PhysicsImpostor or null if not found
  49864. */
  49865. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49866. /**
  49867. * Does a raycast in the physics world
  49868. * @param from when should the ray start?
  49869. * @param to when should the ray end?
  49870. * @returns PhysicsRaycastResult
  49871. */
  49872. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49873. }
  49874. }
  49875. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49876. import { Nullable } from "babylonjs/types";
  49877. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49879. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49880. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49881. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49882. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49883. /** @hidden */
  49884. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49885. private _useDeltaForWorldStep;
  49886. world: any;
  49887. name: string;
  49888. private _physicsMaterials;
  49889. private _fixedTimeStep;
  49890. private _cannonRaycastResult;
  49891. private _raycastResult;
  49892. private _removeAfterStep;
  49893. BJSCANNON: any;
  49894. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49895. setGravity(gravity: Vector3): void;
  49896. setTimeStep(timeStep: number): void;
  49897. getTimeStep(): number;
  49898. executeStep(delta: number): void;
  49899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49900. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49901. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49902. private _processChildMeshes;
  49903. removePhysicsBody(impostor: PhysicsImpostor): void;
  49904. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49905. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49906. private _addMaterial;
  49907. private _checkWithEpsilon;
  49908. private _createShape;
  49909. private _createHeightmap;
  49910. private _minus90X;
  49911. private _plus90X;
  49912. private _tmpPosition;
  49913. private _tmpDeltaPosition;
  49914. private _tmpUnityRotation;
  49915. private _updatePhysicsBodyTransformation;
  49916. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49917. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49918. isSupported(): boolean;
  49919. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49920. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49921. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49922. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49923. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49924. getBodyMass(impostor: PhysicsImpostor): number;
  49925. getBodyFriction(impostor: PhysicsImpostor): number;
  49926. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49927. getBodyRestitution(impostor: PhysicsImpostor): number;
  49928. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49929. sleepBody(impostor: PhysicsImpostor): void;
  49930. wakeUpBody(impostor: PhysicsImpostor): void;
  49931. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49932. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49933. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49934. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49935. getRadius(impostor: PhysicsImpostor): number;
  49936. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49937. dispose(): void;
  49938. private _extendNamespace;
  49939. /**
  49940. * Does a raycast in the physics world
  49941. * @param from when should the ray start?
  49942. * @param to when should the ray end?
  49943. * @returns PhysicsRaycastResult
  49944. */
  49945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49946. }
  49947. }
  49948. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49949. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49950. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49951. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49953. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49954. import { Nullable } from "babylonjs/types";
  49955. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49956. /** @hidden */
  49957. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49958. world: any;
  49959. name: string;
  49960. BJSOIMO: any;
  49961. private _raycastResult;
  49962. constructor(iterations?: number, oimoInjection?: any);
  49963. setGravity(gravity: Vector3): void;
  49964. setTimeStep(timeStep: number): void;
  49965. getTimeStep(): number;
  49966. private _tmpImpostorsArray;
  49967. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49968. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49969. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49970. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49971. private _tmpPositionVector;
  49972. removePhysicsBody(impostor: PhysicsImpostor): void;
  49973. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49974. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49975. isSupported(): boolean;
  49976. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49977. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49978. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49979. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49980. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49981. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49982. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49983. getBodyMass(impostor: PhysicsImpostor): number;
  49984. getBodyFriction(impostor: PhysicsImpostor): number;
  49985. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49986. getBodyRestitution(impostor: PhysicsImpostor): number;
  49987. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49988. sleepBody(impostor: PhysicsImpostor): void;
  49989. wakeUpBody(impostor: PhysicsImpostor): void;
  49990. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49991. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49992. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49993. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49994. getRadius(impostor: PhysicsImpostor): number;
  49995. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49996. dispose(): void;
  49997. /**
  49998. * Does a raycast in the physics world
  49999. * @param from when should the ray start?
  50000. * @param to when should the ray end?
  50001. * @returns PhysicsRaycastResult
  50002. */
  50003. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50004. }
  50005. }
  50006. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50007. import { Nullable } from "babylonjs/types";
  50008. import { Scene } from "babylonjs/scene";
  50009. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50010. import { Mesh } from "babylonjs/Meshes/mesh";
  50011. /**
  50012. * Class containing static functions to help procedurally build meshes
  50013. */
  50014. export class RibbonBuilder {
  50015. /**
  50016. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50017. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50018. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50019. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50020. * * 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
  50021. * * 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
  50022. * * 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
  50023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50026. * * 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
  50027. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50028. * * 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
  50029. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50031. * @param name defines the name of the mesh
  50032. * @param options defines the options used to create the mesh
  50033. * @param scene defines the hosting scene
  50034. * @returns the ribbon mesh
  50035. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50036. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50037. */
  50038. static CreateRibbon(name: string, options: {
  50039. pathArray: Vector3[][];
  50040. closeArray?: boolean;
  50041. closePath?: boolean;
  50042. offset?: number;
  50043. updatable?: boolean;
  50044. sideOrientation?: number;
  50045. frontUVs?: Vector4;
  50046. backUVs?: Vector4;
  50047. instance?: Mesh;
  50048. invertUV?: boolean;
  50049. uvs?: Vector2[];
  50050. colors?: Color4[];
  50051. }, scene?: Nullable<Scene>): Mesh;
  50052. }
  50053. }
  50054. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50055. import { Nullable } from "babylonjs/types";
  50056. import { Scene } from "babylonjs/scene";
  50057. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50058. import { Mesh } from "babylonjs/Meshes/mesh";
  50059. /**
  50060. * Class containing static functions to help procedurally build meshes
  50061. */
  50062. export class ShapeBuilder {
  50063. /**
  50064. * 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.
  50065. * * 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.
  50066. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50067. * * 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.
  50068. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50069. * * 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
  50070. * * 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
  50071. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50076. * @param name defines the name of the mesh
  50077. * @param options defines the options used to create the mesh
  50078. * @param scene defines the hosting scene
  50079. * @returns the extruded shape mesh
  50080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50082. */
  50083. static ExtrudeShape(name: string, options: {
  50084. shape: Vector3[];
  50085. path: Vector3[];
  50086. scale?: number;
  50087. rotation?: number;
  50088. cap?: number;
  50089. updatable?: boolean;
  50090. sideOrientation?: number;
  50091. frontUVs?: Vector4;
  50092. backUVs?: Vector4;
  50093. instance?: Mesh;
  50094. invertUV?: boolean;
  50095. }, scene?: Nullable<Scene>): Mesh;
  50096. /**
  50097. * Creates an custom extruded shape mesh.
  50098. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50099. * * 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.
  50100. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50101. * * 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
  50102. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50103. * * 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
  50104. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50105. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50106. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50107. * * 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
  50108. * * 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
  50109. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50114. * @param name defines the name of the mesh
  50115. * @param options defines the options used to create the mesh
  50116. * @param scene defines the hosting scene
  50117. * @returns the custom extruded shape mesh
  50118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50119. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50121. */
  50122. static ExtrudeShapeCustom(name: string, options: {
  50123. shape: Vector3[];
  50124. path: Vector3[];
  50125. scaleFunction?: any;
  50126. rotationFunction?: any;
  50127. ribbonCloseArray?: boolean;
  50128. ribbonClosePath?: boolean;
  50129. cap?: number;
  50130. updatable?: boolean;
  50131. sideOrientation?: number;
  50132. frontUVs?: Vector4;
  50133. backUVs?: Vector4;
  50134. instance?: Mesh;
  50135. invertUV?: boolean;
  50136. }, scene?: Nullable<Scene>): Mesh;
  50137. private static _ExtrudeShapeGeneric;
  50138. }
  50139. }
  50140. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50141. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50142. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50143. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50144. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50145. import { Nullable } from "babylonjs/types";
  50146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50147. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50148. /**
  50149. * AmmoJS Physics plugin
  50150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50151. * @see https://github.com/kripken/ammo.js/
  50152. */
  50153. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50154. private _useDeltaForWorldStep;
  50155. /**
  50156. * Reference to the Ammo library
  50157. */
  50158. bjsAMMO: any;
  50159. /**
  50160. * Created ammoJS world which physics bodies are added to
  50161. */
  50162. world: any;
  50163. /**
  50164. * Name of the plugin
  50165. */
  50166. name: string;
  50167. private _timeStep;
  50168. private _fixedTimeStep;
  50169. private _maxSteps;
  50170. private _tmpQuaternion;
  50171. private _tmpAmmoTransform;
  50172. private _tmpAmmoQuaternion;
  50173. private _tmpAmmoConcreteContactResultCallback;
  50174. private _collisionConfiguration;
  50175. private _dispatcher;
  50176. private _overlappingPairCache;
  50177. private _solver;
  50178. private _softBodySolver;
  50179. private _tmpAmmoVectorA;
  50180. private _tmpAmmoVectorB;
  50181. private _tmpAmmoVectorC;
  50182. private _tmpAmmoVectorD;
  50183. private _tmpContactCallbackResult;
  50184. private _tmpAmmoVectorRCA;
  50185. private _tmpAmmoVectorRCB;
  50186. private _raycastResult;
  50187. private static readonly DISABLE_COLLISION_FLAG;
  50188. private static readonly KINEMATIC_FLAG;
  50189. private static readonly DISABLE_DEACTIVATION_FLAG;
  50190. /**
  50191. * Initializes the ammoJS plugin
  50192. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50193. * @param ammoInjection can be used to inject your own ammo reference
  50194. */
  50195. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50196. /**
  50197. * Sets the gravity of the physics world (m/(s^2))
  50198. * @param gravity Gravity to set
  50199. */
  50200. setGravity(gravity: Vector3): void;
  50201. /**
  50202. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50203. * @param timeStep timestep to use in seconds
  50204. */
  50205. setTimeStep(timeStep: number): void;
  50206. /**
  50207. * 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)
  50208. * @param fixedTimeStep fixedTimeStep to use in seconds
  50209. */
  50210. setFixedTimeStep(fixedTimeStep: number): void;
  50211. /**
  50212. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50213. * @param maxSteps the maximum number of steps by the physics engine per frame
  50214. */
  50215. setMaxSteps(maxSteps: number): void;
  50216. /**
  50217. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50218. * @returns the current timestep in seconds
  50219. */
  50220. getTimeStep(): number;
  50221. private _isImpostorInContact;
  50222. private _isImpostorPairInContact;
  50223. private _stepSimulation;
  50224. /**
  50225. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50226. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50227. * After the step the babylon meshes are set to the position of the physics imposters
  50228. * @param delta amount of time to step forward
  50229. * @param impostors array of imposters to update before/after the step
  50230. */
  50231. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50232. /**
  50233. * Update babylon mesh to match physics world object
  50234. * @param impostor imposter to match
  50235. */
  50236. private _afterSoftStep;
  50237. /**
  50238. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50239. * @param impostor imposter to match
  50240. */
  50241. private _ropeStep;
  50242. /**
  50243. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50244. * @param impostor imposter to match
  50245. */
  50246. private _softbodyOrClothStep;
  50247. private _tmpVector;
  50248. private _tmpMatrix;
  50249. /**
  50250. * Applies an impulse on the imposter
  50251. * @param impostor imposter to apply impulse to
  50252. * @param force amount of force to be applied to the imposter
  50253. * @param contactPoint the location to apply the impulse on the imposter
  50254. */
  50255. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50256. /**
  50257. * Applies a force on the imposter
  50258. * @param impostor imposter to apply force
  50259. * @param force amount of force to be applied to the imposter
  50260. * @param contactPoint the location to apply the force on the imposter
  50261. */
  50262. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50263. /**
  50264. * Creates a physics body using the plugin
  50265. * @param impostor the imposter to create the physics body on
  50266. */
  50267. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50268. /**
  50269. * Removes the physics body from the imposter and disposes of the body's memory
  50270. * @param impostor imposter to remove the physics body from
  50271. */
  50272. removePhysicsBody(impostor: PhysicsImpostor): void;
  50273. /**
  50274. * Generates a joint
  50275. * @param impostorJoint the imposter joint to create the joint with
  50276. */
  50277. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50278. /**
  50279. * Removes a joint
  50280. * @param impostorJoint the imposter joint to remove the joint from
  50281. */
  50282. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50283. private _addMeshVerts;
  50284. /**
  50285. * Initialise the soft body vertices to match its object's (mesh) vertices
  50286. * Softbody vertices (nodes) are in world space and to match this
  50287. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50288. * @param impostor to create the softbody for
  50289. */
  50290. private _softVertexData;
  50291. /**
  50292. * Create an impostor's soft body
  50293. * @param impostor to create the softbody for
  50294. */
  50295. private _createSoftbody;
  50296. /**
  50297. * Create cloth for an impostor
  50298. * @param impostor to create the softbody for
  50299. */
  50300. private _createCloth;
  50301. /**
  50302. * Create rope for an impostor
  50303. * @param impostor to create the softbody for
  50304. */
  50305. private _createRope;
  50306. private _addHullVerts;
  50307. private _createShape;
  50308. /**
  50309. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50310. * @param impostor imposter containing the physics body and babylon object
  50311. */
  50312. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50313. /**
  50314. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50315. * @param impostor imposter containing the physics body and babylon object
  50316. * @param newPosition new position
  50317. * @param newRotation new rotation
  50318. */
  50319. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50320. /**
  50321. * If this plugin is supported
  50322. * @returns true if its supported
  50323. */
  50324. isSupported(): boolean;
  50325. /**
  50326. * Sets the linear velocity of the physics body
  50327. * @param impostor imposter to set the velocity on
  50328. * @param velocity velocity to set
  50329. */
  50330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50331. /**
  50332. * Sets the angular velocity of the physics body
  50333. * @param impostor imposter to set the velocity on
  50334. * @param velocity velocity to set
  50335. */
  50336. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50337. /**
  50338. * gets the linear velocity
  50339. * @param impostor imposter to get linear velocity from
  50340. * @returns linear velocity
  50341. */
  50342. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50343. /**
  50344. * gets the angular velocity
  50345. * @param impostor imposter to get angular velocity from
  50346. * @returns angular velocity
  50347. */
  50348. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50349. /**
  50350. * Sets the mass of physics body
  50351. * @param impostor imposter to set the mass on
  50352. * @param mass mass to set
  50353. */
  50354. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50355. /**
  50356. * Gets the mass of the physics body
  50357. * @param impostor imposter to get the mass from
  50358. * @returns mass
  50359. */
  50360. getBodyMass(impostor: PhysicsImpostor): number;
  50361. /**
  50362. * Gets friction of the impostor
  50363. * @param impostor impostor to get friction from
  50364. * @returns friction value
  50365. */
  50366. getBodyFriction(impostor: PhysicsImpostor): number;
  50367. /**
  50368. * Sets friction of the impostor
  50369. * @param impostor impostor to set friction on
  50370. * @param friction friction value
  50371. */
  50372. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50373. /**
  50374. * Gets restitution of the impostor
  50375. * @param impostor impostor to get restitution from
  50376. * @returns restitution value
  50377. */
  50378. getBodyRestitution(impostor: PhysicsImpostor): number;
  50379. /**
  50380. * Sets resitution of the impostor
  50381. * @param impostor impostor to set resitution on
  50382. * @param restitution resitution value
  50383. */
  50384. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50385. /**
  50386. * Gets pressure inside the impostor
  50387. * @param impostor impostor to get pressure from
  50388. * @returns pressure value
  50389. */
  50390. getBodyPressure(impostor: PhysicsImpostor): number;
  50391. /**
  50392. * Sets pressure inside a soft body impostor
  50393. * Cloth and rope must remain 0 pressure
  50394. * @param impostor impostor to set pressure on
  50395. * @param pressure pressure value
  50396. */
  50397. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50398. /**
  50399. * Gets stiffness of the impostor
  50400. * @param impostor impostor to get stiffness from
  50401. * @returns pressure value
  50402. */
  50403. getBodyStiffness(impostor: PhysicsImpostor): number;
  50404. /**
  50405. * Sets stiffness of the impostor
  50406. * @param impostor impostor to set stiffness on
  50407. * @param stiffness stiffness value from 0 to 1
  50408. */
  50409. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50410. /**
  50411. * Gets velocityIterations of the impostor
  50412. * @param impostor impostor to get velocity iterations from
  50413. * @returns velocityIterations value
  50414. */
  50415. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50416. /**
  50417. * Sets velocityIterations of the impostor
  50418. * @param impostor impostor to set velocity iterations on
  50419. * @param velocityIterations velocityIterations value
  50420. */
  50421. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50422. /**
  50423. * Gets positionIterations of the impostor
  50424. * @param impostor impostor to get position iterations from
  50425. * @returns positionIterations value
  50426. */
  50427. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50428. /**
  50429. * Sets positionIterations of the impostor
  50430. * @param impostor impostor to set position on
  50431. * @param positionIterations positionIterations value
  50432. */
  50433. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50434. /**
  50435. * Append an anchor to a cloth object
  50436. * @param impostor is the cloth impostor to add anchor to
  50437. * @param otherImpostor is the rigid impostor to anchor to
  50438. * @param width ratio across width from 0 to 1
  50439. * @param height ratio up height from 0 to 1
  50440. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50441. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50442. */
  50443. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50444. /**
  50445. * Append an hook to a rope object
  50446. * @param impostor is the rope impostor to add hook to
  50447. * @param otherImpostor is the rigid impostor to hook to
  50448. * @param length ratio along the rope from 0 to 1
  50449. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50450. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50451. */
  50452. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50453. /**
  50454. * Sleeps the physics body and stops it from being active
  50455. * @param impostor impostor to sleep
  50456. */
  50457. sleepBody(impostor: PhysicsImpostor): void;
  50458. /**
  50459. * Activates the physics body
  50460. * @param impostor impostor to activate
  50461. */
  50462. wakeUpBody(impostor: PhysicsImpostor): void;
  50463. /**
  50464. * Updates the distance parameters of the joint
  50465. * @param joint joint to update
  50466. * @param maxDistance maximum distance of the joint
  50467. * @param minDistance minimum distance of the joint
  50468. */
  50469. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50470. /**
  50471. * Sets a motor on the joint
  50472. * @param joint joint to set motor on
  50473. * @param speed speed of the motor
  50474. * @param maxForce maximum force of the motor
  50475. * @param motorIndex index of the motor
  50476. */
  50477. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50478. /**
  50479. * Sets the motors limit
  50480. * @param joint joint to set limit on
  50481. * @param upperLimit upper limit
  50482. * @param lowerLimit lower limit
  50483. */
  50484. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50485. /**
  50486. * Syncs the position and rotation of a mesh with the impostor
  50487. * @param mesh mesh to sync
  50488. * @param impostor impostor to update the mesh with
  50489. */
  50490. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50491. /**
  50492. * Gets the radius of the impostor
  50493. * @param impostor impostor to get radius from
  50494. * @returns the radius
  50495. */
  50496. getRadius(impostor: PhysicsImpostor): number;
  50497. /**
  50498. * Gets the box size of the impostor
  50499. * @param impostor impostor to get box size from
  50500. * @param result the resulting box size
  50501. */
  50502. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50503. /**
  50504. * Disposes of the impostor
  50505. */
  50506. dispose(): void;
  50507. /**
  50508. * Does a raycast in the physics world
  50509. * @param from when should the ray start?
  50510. * @param to when should the ray end?
  50511. * @returns PhysicsRaycastResult
  50512. */
  50513. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50514. }
  50515. }
  50516. declare module "babylonjs/Probes/reflectionProbe" {
  50517. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50518. import { Vector3 } from "babylonjs/Maths/math";
  50519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50520. import { Nullable } from "babylonjs/types";
  50521. import { Scene } from "babylonjs/scene";
  50522. module "babylonjs/abstractScene" {
  50523. interface AbstractScene {
  50524. /**
  50525. * The list of reflection probes added to the scene
  50526. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50527. */
  50528. reflectionProbes: Array<ReflectionProbe>;
  50529. /**
  50530. * Removes the given reflection probe from this scene.
  50531. * @param toRemove The reflection probe to remove
  50532. * @returns The index of the removed reflection probe
  50533. */
  50534. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50535. /**
  50536. * Adds the given reflection probe to this scene.
  50537. * @param newReflectionProbe The reflection probe to add
  50538. */
  50539. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50540. }
  50541. }
  50542. /**
  50543. * Class used to generate realtime reflection / refraction cube textures
  50544. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50545. */
  50546. export class ReflectionProbe {
  50547. /** defines the name of the probe */
  50548. name: string;
  50549. private _scene;
  50550. private _renderTargetTexture;
  50551. private _projectionMatrix;
  50552. private _viewMatrix;
  50553. private _target;
  50554. private _add;
  50555. private _attachedMesh;
  50556. private _invertYAxis;
  50557. /** Gets or sets probe position (center of the cube map) */
  50558. position: Vector3;
  50559. /**
  50560. * Creates a new reflection probe
  50561. * @param name defines the name of the probe
  50562. * @param size defines the texture resolution (for each face)
  50563. * @param scene defines the hosting scene
  50564. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50565. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50566. */
  50567. constructor(
  50568. /** defines the name of the probe */
  50569. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50570. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50571. samples: number;
  50572. /** Gets or sets the refresh rate to use (on every frame by default) */
  50573. refreshRate: number;
  50574. /**
  50575. * Gets the hosting scene
  50576. * @returns a Scene
  50577. */
  50578. getScene(): Scene;
  50579. /** Gets the internal CubeTexture used to render to */
  50580. readonly cubeTexture: RenderTargetTexture;
  50581. /** Gets the list of meshes to render */
  50582. readonly renderList: Nullable<AbstractMesh[]>;
  50583. /**
  50584. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50585. * @param mesh defines the mesh to attach to
  50586. */
  50587. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50588. /**
  50589. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50590. * @param renderingGroupId The rendering group id corresponding to its index
  50591. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50592. */
  50593. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50594. /**
  50595. * Clean all associated resources
  50596. */
  50597. dispose(): void;
  50598. /**
  50599. * Converts the reflection probe information to a readable string for debug purpose.
  50600. * @param fullDetails Supports for multiple levels of logging within scene loading
  50601. * @returns the human readable reflection probe info
  50602. */
  50603. toString(fullDetails?: boolean): string;
  50604. /**
  50605. * Get the class name of the relfection probe.
  50606. * @returns "ReflectionProbe"
  50607. */
  50608. getClassName(): string;
  50609. /**
  50610. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50611. * @returns The JSON representation of the texture
  50612. */
  50613. serialize(): any;
  50614. /**
  50615. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50616. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50617. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50618. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50619. * @returns The parsed reflection probe if successful
  50620. */
  50621. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50622. }
  50623. }
  50624. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50625. /** @hidden */
  50626. export var _BabylonLoaderRegistered: boolean;
  50627. }
  50628. declare module "babylonjs/Loading/Plugins/index" {
  50629. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50630. }
  50631. declare module "babylonjs/Loading/index" {
  50632. export * from "babylonjs/Loading/loadingScreen";
  50633. export * from "babylonjs/Loading/Plugins/index";
  50634. export * from "babylonjs/Loading/sceneLoader";
  50635. export * from "babylonjs/Loading/sceneLoaderFlags";
  50636. }
  50637. declare module "babylonjs/Materials/Background/index" {
  50638. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50639. }
  50640. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50641. import { Scene } from "babylonjs/scene";
  50642. import { Color3 } from "babylonjs/Maths/math";
  50643. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50645. /**
  50646. * The Physically based simple base material of BJS.
  50647. *
  50648. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50649. * It is used as the base class for both the specGloss and metalRough conventions.
  50650. */
  50651. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50652. /**
  50653. * Number of Simultaneous lights allowed on the material.
  50654. */
  50655. maxSimultaneousLights: number;
  50656. /**
  50657. * If sets to true, disables all the lights affecting the material.
  50658. */
  50659. disableLighting: boolean;
  50660. /**
  50661. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50662. */
  50663. environmentTexture: BaseTexture;
  50664. /**
  50665. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50666. */
  50667. invertNormalMapX: boolean;
  50668. /**
  50669. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50670. */
  50671. invertNormalMapY: boolean;
  50672. /**
  50673. * Normal map used in the model.
  50674. */
  50675. normalTexture: BaseTexture;
  50676. /**
  50677. * Emissivie color used to self-illuminate the model.
  50678. */
  50679. emissiveColor: Color3;
  50680. /**
  50681. * Emissivie texture used to self-illuminate the model.
  50682. */
  50683. emissiveTexture: BaseTexture;
  50684. /**
  50685. * Occlusion Channel Strenght.
  50686. */
  50687. occlusionStrength: number;
  50688. /**
  50689. * Occlusion Texture of the material (adding extra occlusion effects).
  50690. */
  50691. occlusionTexture: BaseTexture;
  50692. /**
  50693. * Defines the alpha limits in alpha test mode.
  50694. */
  50695. alphaCutOff: number;
  50696. /**
  50697. * Gets the current double sided mode.
  50698. */
  50699. /**
  50700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50701. */
  50702. doubleSided: boolean;
  50703. /**
  50704. * Stores the pre-calculated light information of a mesh in a texture.
  50705. */
  50706. lightmapTexture: BaseTexture;
  50707. /**
  50708. * If true, the light map contains occlusion information instead of lighting info.
  50709. */
  50710. useLightmapAsShadowmap: boolean;
  50711. /**
  50712. * Instantiates a new PBRMaterial instance.
  50713. *
  50714. * @param name The material name
  50715. * @param scene The scene the material will be use in.
  50716. */
  50717. constructor(name: string, scene: Scene);
  50718. getClassName(): string;
  50719. }
  50720. }
  50721. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50722. import { Scene } from "babylonjs/scene";
  50723. import { Color3 } from "babylonjs/Maths/math";
  50724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50725. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50726. /**
  50727. * The PBR material of BJS following the metal roughness convention.
  50728. *
  50729. * This fits to the PBR convention in the GLTF definition:
  50730. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50731. */
  50732. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50733. /**
  50734. * The base color has two different interpretations depending on the value of metalness.
  50735. * When the material is a metal, the base color is the specific measured reflectance value
  50736. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50737. * of the material.
  50738. */
  50739. baseColor: Color3;
  50740. /**
  50741. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50742. * well as opacity information in the alpha channel.
  50743. */
  50744. baseTexture: BaseTexture;
  50745. /**
  50746. * Specifies the metallic scalar value of the material.
  50747. * Can also be used to scale the metalness values of the metallic texture.
  50748. */
  50749. metallic: number;
  50750. /**
  50751. * Specifies the roughness scalar value of the material.
  50752. * Can also be used to scale the roughness values of the metallic texture.
  50753. */
  50754. roughness: number;
  50755. /**
  50756. * Texture containing both the metallic value in the B channel and the
  50757. * roughness value in the G channel to keep better precision.
  50758. */
  50759. metallicRoughnessTexture: BaseTexture;
  50760. /**
  50761. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50762. *
  50763. * @param name The material name
  50764. * @param scene The scene the material will be use in.
  50765. */
  50766. constructor(name: string, scene: Scene);
  50767. /**
  50768. * Return the currrent class name of the material.
  50769. */
  50770. getClassName(): string;
  50771. /**
  50772. * Makes a duplicate of the current material.
  50773. * @param name - name to use for the new material.
  50774. */
  50775. clone(name: string): PBRMetallicRoughnessMaterial;
  50776. /**
  50777. * Serialize the material to a parsable JSON object.
  50778. */
  50779. serialize(): any;
  50780. /**
  50781. * Parses a JSON object correponding to the serialize function.
  50782. */
  50783. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50784. }
  50785. }
  50786. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50787. import { Scene } from "babylonjs/scene";
  50788. import { Color3 } from "babylonjs/Maths/math";
  50789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50790. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50791. /**
  50792. * The PBR material of BJS following the specular glossiness convention.
  50793. *
  50794. * This fits to the PBR convention in the GLTF definition:
  50795. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50796. */
  50797. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50798. /**
  50799. * Specifies the diffuse color of the material.
  50800. */
  50801. diffuseColor: Color3;
  50802. /**
  50803. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50804. * channel.
  50805. */
  50806. diffuseTexture: BaseTexture;
  50807. /**
  50808. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50809. */
  50810. specularColor: Color3;
  50811. /**
  50812. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50813. */
  50814. glossiness: number;
  50815. /**
  50816. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50817. */
  50818. specularGlossinessTexture: BaseTexture;
  50819. /**
  50820. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50821. *
  50822. * @param name The material name
  50823. * @param scene The scene the material will be use in.
  50824. */
  50825. constructor(name: string, scene: Scene);
  50826. /**
  50827. * Return the currrent class name of the material.
  50828. */
  50829. getClassName(): string;
  50830. /**
  50831. * Makes a duplicate of the current material.
  50832. * @param name - name to use for the new material.
  50833. */
  50834. clone(name: string): PBRSpecularGlossinessMaterial;
  50835. /**
  50836. * Serialize the material to a parsable JSON object.
  50837. */
  50838. serialize(): any;
  50839. /**
  50840. * Parses a JSON object correponding to the serialize function.
  50841. */
  50842. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50843. }
  50844. }
  50845. declare module "babylonjs/Materials/PBR/index" {
  50846. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50847. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50848. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50849. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50850. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50851. }
  50852. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50853. import { Nullable } from "babylonjs/types";
  50854. import { Scene } from "babylonjs/scene";
  50855. import { Matrix } from "babylonjs/Maths/math";
  50856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50857. /**
  50858. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50859. * It can help converting any input color in a desired output one. This can then be used to create effects
  50860. * from sepia, black and white to sixties or futuristic rendering...
  50861. *
  50862. * The only supported format is currently 3dl.
  50863. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50864. */
  50865. export class ColorGradingTexture extends BaseTexture {
  50866. /**
  50867. * The current texture matrix. (will always be identity in color grading texture)
  50868. */
  50869. private _textureMatrix;
  50870. /**
  50871. * The texture URL.
  50872. */
  50873. url: string;
  50874. /**
  50875. * Empty line regex stored for GC.
  50876. */
  50877. private static _noneEmptyLineRegex;
  50878. private _engine;
  50879. /**
  50880. * Instantiates a ColorGradingTexture from the following parameters.
  50881. *
  50882. * @param url The location of the color gradind data (currently only supporting 3dl)
  50883. * @param scene The scene the texture will be used in
  50884. */
  50885. constructor(url: string, scene: Scene);
  50886. /**
  50887. * Returns the texture matrix used in most of the material.
  50888. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50889. */
  50890. getTextureMatrix(): Matrix;
  50891. /**
  50892. * Occurs when the file being loaded is a .3dl LUT file.
  50893. */
  50894. private load3dlTexture;
  50895. /**
  50896. * Starts the loading process of the texture.
  50897. */
  50898. private loadTexture;
  50899. /**
  50900. * Clones the color gradind texture.
  50901. */
  50902. clone(): ColorGradingTexture;
  50903. /**
  50904. * Called during delayed load for textures.
  50905. */
  50906. delayLoad(): void;
  50907. /**
  50908. * Parses a color grading texture serialized by Babylon.
  50909. * @param parsedTexture The texture information being parsedTexture
  50910. * @param scene The scene to load the texture in
  50911. * @param rootUrl The root url of the data assets to load
  50912. * @return A color gradind texture
  50913. */
  50914. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50915. /**
  50916. * Serializes the LUT texture to json format.
  50917. */
  50918. serialize(): any;
  50919. }
  50920. }
  50921. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50923. import { Scene } from "babylonjs/scene";
  50924. import { Nullable } from "babylonjs/types";
  50925. /**
  50926. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50927. */
  50928. export class EquiRectangularCubeTexture extends BaseTexture {
  50929. /** The six faces of the cube. */
  50930. private static _FacesMapping;
  50931. private _noMipmap;
  50932. private _onLoad;
  50933. private _onError;
  50934. /** The size of the cubemap. */
  50935. private _size;
  50936. /** The buffer of the image. */
  50937. private _buffer;
  50938. /** The width of the input image. */
  50939. private _width;
  50940. /** The height of the input image. */
  50941. private _height;
  50942. /** The URL to the image. */
  50943. url: string;
  50944. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50945. coordinatesMode: number;
  50946. /**
  50947. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50948. * @param url The location of the image
  50949. * @param scene The scene the texture will be used in
  50950. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50951. * @param noMipmap Forces to not generate the mipmap if true
  50952. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50953. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50954. * @param onLoad — defines a callback called when texture is loaded
  50955. * @param onError — defines a callback called if there is an error
  50956. */
  50957. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50958. /**
  50959. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50960. */
  50961. private loadImage;
  50962. /**
  50963. * Convert the image buffer into a cubemap and create a CubeTexture.
  50964. */
  50965. private loadTexture;
  50966. /**
  50967. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50968. * @param buffer The ArrayBuffer that should be converted.
  50969. * @returns The buffer as Float32Array.
  50970. */
  50971. private getFloat32ArrayFromArrayBuffer;
  50972. /**
  50973. * Get the current class name of the texture useful for serialization or dynamic coding.
  50974. * @returns "EquiRectangularCubeTexture"
  50975. */
  50976. getClassName(): string;
  50977. /**
  50978. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50979. * @returns A clone of the current EquiRectangularCubeTexture.
  50980. */
  50981. clone(): EquiRectangularCubeTexture;
  50982. }
  50983. }
  50984. declare module "babylonjs/Misc/tga" {
  50985. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50986. /**
  50987. * Based on jsTGALoader - Javascript loader for TGA file
  50988. * By Vincent Thibault
  50989. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50990. */
  50991. export class TGATools {
  50992. private static _TYPE_INDEXED;
  50993. private static _TYPE_RGB;
  50994. private static _TYPE_GREY;
  50995. private static _TYPE_RLE_INDEXED;
  50996. private static _TYPE_RLE_RGB;
  50997. private static _TYPE_RLE_GREY;
  50998. private static _ORIGIN_MASK;
  50999. private static _ORIGIN_SHIFT;
  51000. private static _ORIGIN_BL;
  51001. private static _ORIGIN_BR;
  51002. private static _ORIGIN_UL;
  51003. private static _ORIGIN_UR;
  51004. /**
  51005. * Gets the header of a TGA file
  51006. * @param data defines the TGA data
  51007. * @returns the header
  51008. */
  51009. static GetTGAHeader(data: Uint8Array): any;
  51010. /**
  51011. * Uploads TGA content to a Babylon Texture
  51012. * @hidden
  51013. */
  51014. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51015. /** @hidden */
  51016. 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;
  51017. /** @hidden */
  51018. 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;
  51019. /** @hidden */
  51020. 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;
  51021. /** @hidden */
  51022. 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;
  51023. /** @hidden */
  51024. 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;
  51025. /** @hidden */
  51026. 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;
  51027. }
  51028. }
  51029. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51030. import { Nullable } from "babylonjs/types";
  51031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51032. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51033. /**
  51034. * Implementation of the TGA Texture Loader.
  51035. * @hidden
  51036. */
  51037. export class _TGATextureLoader implements IInternalTextureLoader {
  51038. /**
  51039. * Defines wether the loader supports cascade loading the different faces.
  51040. */
  51041. readonly supportCascades: boolean;
  51042. /**
  51043. * This returns if the loader support the current file information.
  51044. * @param extension defines the file extension of the file being loaded
  51045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51046. * @param fallback defines the fallback internal texture if any
  51047. * @param isBase64 defines whether the texture is encoded as a base64
  51048. * @param isBuffer defines whether the texture data are stored as a buffer
  51049. * @returns true if the loader can load the specified file
  51050. */
  51051. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51052. /**
  51053. * Transform the url before loading if required.
  51054. * @param rootUrl the url of the texture
  51055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51056. * @returns the transformed texture
  51057. */
  51058. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51059. /**
  51060. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51061. * @param rootUrl the url of the texture
  51062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51063. * @returns the fallback texture
  51064. */
  51065. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51066. /**
  51067. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51068. * @param data contains the texture data
  51069. * @param texture defines the BabylonJS internal texture
  51070. * @param createPolynomials will be true if polynomials have been requested
  51071. * @param onLoad defines the callback to trigger once the texture is ready
  51072. * @param onError defines the callback to trigger in case of error
  51073. */
  51074. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51075. /**
  51076. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51077. * @param data contains the texture data
  51078. * @param texture defines the BabylonJS internal texture
  51079. * @param callback defines the method to call once ready to upload
  51080. */
  51081. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51082. }
  51083. }
  51084. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51085. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51086. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51087. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51088. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51089. }
  51090. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51091. import { Scene } from "babylonjs/scene";
  51092. import { Texture } from "babylonjs/Materials/Textures/texture";
  51093. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51094. /**
  51095. * 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.
  51096. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51098. */
  51099. export class CustomProceduralTexture extends ProceduralTexture {
  51100. private _animate;
  51101. private _time;
  51102. private _config;
  51103. private _texturePath;
  51104. /**
  51105. * Instantiates a new Custom Procedural Texture.
  51106. * 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.
  51107. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51109. * @param name Define the name of the texture
  51110. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51111. * @param size Define the size of the texture to create
  51112. * @param scene Define the scene the texture belongs to
  51113. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51114. * @param generateMipMaps Define if the texture should creates mip maps or not
  51115. */
  51116. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51117. private _loadJson;
  51118. /**
  51119. * Is the texture ready to be used ? (rendered at least once)
  51120. * @returns true if ready, otherwise, false.
  51121. */
  51122. isReady(): boolean;
  51123. /**
  51124. * Render the texture to its associated render target.
  51125. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51126. */
  51127. render(useCameraPostProcess?: boolean): void;
  51128. /**
  51129. * Update the list of dependant textures samplers in the shader.
  51130. */
  51131. updateTextures(): void;
  51132. /**
  51133. * Update the uniform values of the procedural texture in the shader.
  51134. */
  51135. updateShaderUniforms(): void;
  51136. /**
  51137. * Define if the texture animates or not.
  51138. */
  51139. animate: boolean;
  51140. }
  51141. }
  51142. declare module "babylonjs/Shaders/noise.fragment" {
  51143. /** @hidden */
  51144. export var noisePixelShader: {
  51145. name: string;
  51146. shader: string;
  51147. };
  51148. }
  51149. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51150. import { Nullable } from "babylonjs/types";
  51151. import { Scene } from "babylonjs/scene";
  51152. import { Texture } from "babylonjs/Materials/Textures/texture";
  51153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51154. import "babylonjs/Shaders/noise.fragment";
  51155. /**
  51156. * Class used to generate noise procedural textures
  51157. */
  51158. export class NoiseProceduralTexture extends ProceduralTexture {
  51159. private _time;
  51160. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51161. brightness: number;
  51162. /** Defines the number of octaves to process */
  51163. octaves: number;
  51164. /** Defines the level of persistence (0.8 by default) */
  51165. persistence: number;
  51166. /** Gets or sets animation speed factor (default is 1) */
  51167. animationSpeedFactor: number;
  51168. /**
  51169. * Creates a new NoiseProceduralTexture
  51170. * @param name defines the name fo the texture
  51171. * @param size defines the size of the texture (default is 256)
  51172. * @param scene defines the hosting scene
  51173. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51174. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51175. */
  51176. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51177. private _updateShaderUniforms;
  51178. protected _getDefines(): string;
  51179. /** Generate the current state of the procedural texture */
  51180. render(useCameraPostProcess?: boolean): void;
  51181. /**
  51182. * Serializes this noise procedural texture
  51183. * @returns a serialized noise procedural texture object
  51184. */
  51185. serialize(): any;
  51186. /**
  51187. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51188. * @param parsedTexture defines parsed texture data
  51189. * @param scene defines the current scene
  51190. * @param rootUrl defines the root URL containing noise procedural texture information
  51191. * @returns a parsed NoiseProceduralTexture
  51192. */
  51193. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51194. }
  51195. }
  51196. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51197. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51198. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51199. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51200. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51201. }
  51202. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51203. import { Nullable } from "babylonjs/types";
  51204. import { Scene } from "babylonjs/scene";
  51205. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51207. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51208. /**
  51209. * Raw cube texture where the raw buffers are passed in
  51210. */
  51211. export class RawCubeTexture extends CubeTexture {
  51212. /**
  51213. * Creates a cube texture where the raw buffers are passed in.
  51214. * @param scene defines the scene the texture is attached to
  51215. * @param data defines the array of data to use to create each face
  51216. * @param size defines the size of the textures
  51217. * @param format defines the format of the data
  51218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51219. * @param generateMipMaps defines if the engine should generate the mip levels
  51220. * @param invertY defines if data must be stored with Y axis inverted
  51221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51222. * @param compression defines the compression used (null by default)
  51223. */
  51224. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51225. /**
  51226. * Updates the raw cube texture.
  51227. * @param data defines the data to store
  51228. * @param format defines the data format
  51229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51230. * @param invertY defines if data must be stored with Y axis inverted
  51231. * @param compression defines the compression used (null by default)
  51232. * @param level defines which level of the texture to update
  51233. */
  51234. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51235. /**
  51236. * Updates a raw cube texture with RGBD encoded data.
  51237. * @param data defines the array of data [mipmap][face] to use to create each face
  51238. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51239. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51240. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51241. * @returns a promsie that resolves when the operation is complete
  51242. */
  51243. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51244. /**
  51245. * Clones the raw cube texture.
  51246. * @return a new cube texture
  51247. */
  51248. clone(): CubeTexture;
  51249. /** @hidden */
  51250. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51251. }
  51252. }
  51253. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51254. import { Scene } from "babylonjs/scene";
  51255. import { Texture } from "babylonjs/Materials/Textures/texture";
  51256. /**
  51257. * Class used to store 3D textures containing user data
  51258. */
  51259. export class RawTexture3D extends Texture {
  51260. /** Gets or sets the texture format to use */
  51261. format: number;
  51262. private _engine;
  51263. /**
  51264. * Create a new RawTexture3D
  51265. * @param data defines the data of the texture
  51266. * @param width defines the width of the texture
  51267. * @param height defines the height of the texture
  51268. * @param depth defines the depth of the texture
  51269. * @param format defines the texture format to use
  51270. * @param scene defines the hosting scene
  51271. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51272. * @param invertY defines if texture must be stored with Y axis inverted
  51273. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51274. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51275. */
  51276. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51277. /** Gets or sets the texture format to use */
  51278. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51279. /**
  51280. * Update the texture with new data
  51281. * @param data defines the data to store in the texture
  51282. */
  51283. update(data: ArrayBufferView): void;
  51284. }
  51285. }
  51286. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51287. import { Scene } from "babylonjs/scene";
  51288. import { Plane } from "babylonjs/Maths/math";
  51289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51290. /**
  51291. * Creates a refraction texture used by refraction channel of the standard material.
  51292. * It is like a mirror but to see through a material.
  51293. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51294. */
  51295. export class RefractionTexture extends RenderTargetTexture {
  51296. /**
  51297. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51298. * 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.
  51299. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51300. */
  51301. refractionPlane: Plane;
  51302. /**
  51303. * Define how deep under the surface we should see.
  51304. */
  51305. depth: number;
  51306. /**
  51307. * Creates a refraction texture used by refraction channel of the standard material.
  51308. * It is like a mirror but to see through a material.
  51309. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51310. * @param name Define the texture name
  51311. * @param size Define the size of the underlying texture
  51312. * @param scene Define the scene the refraction belongs to
  51313. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51314. */
  51315. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51316. /**
  51317. * Clone the refraction texture.
  51318. * @returns the cloned texture
  51319. */
  51320. clone(): RefractionTexture;
  51321. /**
  51322. * Serialize the texture to a JSON representation you could use in Parse later on
  51323. * @returns the serialized JSON representation
  51324. */
  51325. serialize(): any;
  51326. }
  51327. }
  51328. declare module "babylonjs/Materials/Textures/index" {
  51329. export * from "babylonjs/Materials/Textures/baseTexture";
  51330. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51331. export * from "babylonjs/Materials/Textures/cubeTexture";
  51332. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51333. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51334. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51335. export * from "babylonjs/Materials/Textures/internalTexture";
  51336. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51337. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  51338. export * from "babylonjs/Materials/Textures/Loaders/index";
  51339. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51340. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51341. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51342. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51343. export * from "babylonjs/Materials/Textures/rawTexture";
  51344. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51345. export * from "babylonjs/Materials/Textures/refractionTexture";
  51346. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51347. export * from "babylonjs/Materials/Textures/texture";
  51348. export * from "babylonjs/Materials/Textures/videoTexture";
  51349. }
  51350. declare module "babylonjs/Materials/index" {
  51351. export * from "babylonjs/Materials/Background/index";
  51352. export * from "babylonjs/Materials/colorCurves";
  51353. export * from "babylonjs/Materials/effect";
  51354. export * from "babylonjs/Materials/fresnelParameters";
  51355. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51356. export * from "babylonjs/Materials/material";
  51357. export * from "babylonjs/Materials/materialDefines";
  51358. export * from "babylonjs/Materials/materialHelper";
  51359. export * from "babylonjs/Materials/multiMaterial";
  51360. export * from "babylonjs/Materials/PBR/index";
  51361. export * from "babylonjs/Materials/pushMaterial";
  51362. export * from "babylonjs/Materials/shaderMaterial";
  51363. export * from "babylonjs/Materials/standardMaterial";
  51364. export * from "babylonjs/Materials/Textures/index";
  51365. export * from "babylonjs/Materials/uniformBuffer";
  51366. export * from "babylonjs/Materials/materialFlags";
  51367. }
  51368. declare module "babylonjs/Maths/index" {
  51369. export * from "babylonjs/Maths/math.scalar";
  51370. export * from "babylonjs/Maths/math";
  51371. export * from "babylonjs/Maths/sphericalPolynomial";
  51372. }
  51373. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51374. import { IDisposable } from "babylonjs/scene";
  51375. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51376. /**
  51377. * Configuration for Draco compression
  51378. */
  51379. export interface IDracoCompressionConfiguration {
  51380. /**
  51381. * Configuration for the decoder.
  51382. */
  51383. decoder?: {
  51384. /**
  51385. * The url to the WebAssembly module.
  51386. */
  51387. wasmUrl?: string;
  51388. /**
  51389. * The url to the WebAssembly binary.
  51390. */
  51391. wasmBinaryUrl?: string;
  51392. /**
  51393. * The url to the fallback JavaScript module.
  51394. */
  51395. fallbackUrl?: string;
  51396. };
  51397. }
  51398. /**
  51399. * Draco compression (https://google.github.io/draco/)
  51400. *
  51401. * This class wraps the Draco module.
  51402. *
  51403. * **Encoder**
  51404. *
  51405. * The encoder is not currently implemented.
  51406. *
  51407. * **Decoder**
  51408. *
  51409. * 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.
  51410. *
  51411. * To update the configuration, use the following code:
  51412. * ```javascript
  51413. * DracoCompression.Configuration = {
  51414. * decoder: {
  51415. * wasmUrl: "<url to the WebAssembly library>",
  51416. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51417. * fallbackUrl: "<url to the fallback JavaScript library>",
  51418. * }
  51419. * };
  51420. * ```
  51421. *
  51422. * 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.
  51423. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51424. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51425. *
  51426. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51427. * ```javascript
  51428. * var dracoCompression = new DracoCompression();
  51429. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51430. * [VertexBuffer.PositionKind]: 0
  51431. * });
  51432. * ```
  51433. *
  51434. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51435. */
  51436. export class DracoCompression implements IDisposable {
  51437. private static _DecoderModulePromise;
  51438. /**
  51439. * The configuration. Defaults to the following urls:
  51440. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51441. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51442. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51443. */
  51444. static Configuration: IDracoCompressionConfiguration;
  51445. /**
  51446. * Returns true if the decoder is available.
  51447. */
  51448. static readonly DecoderAvailable: boolean;
  51449. /**
  51450. * Constructor
  51451. */
  51452. constructor();
  51453. /**
  51454. * Stop all async operations and release resources.
  51455. */
  51456. dispose(): void;
  51457. /**
  51458. * Decode Draco compressed mesh data to vertex data.
  51459. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51460. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51461. * @returns A promise that resolves with the decoded vertex data
  51462. */
  51463. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51464. [kind: string]: number;
  51465. }): Promise<VertexData>;
  51466. private static _GetDecoderModule;
  51467. private static _LoadScriptAsync;
  51468. private static _LoadFileAsync;
  51469. }
  51470. }
  51471. declare module "babylonjs/Meshes/Compression/index" {
  51472. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51473. }
  51474. declare module "babylonjs/Meshes/csg" {
  51475. import { Nullable } from "babylonjs/types";
  51476. import { Scene } from "babylonjs/scene";
  51477. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51478. import { Mesh } from "babylonjs/Meshes/mesh";
  51479. import { Material } from "babylonjs/Materials/material";
  51480. /**
  51481. * Class for building Constructive Solid Geometry
  51482. */
  51483. export class CSG {
  51484. private polygons;
  51485. /**
  51486. * The world matrix
  51487. */
  51488. matrix: Matrix;
  51489. /**
  51490. * Stores the position
  51491. */
  51492. position: Vector3;
  51493. /**
  51494. * Stores the rotation
  51495. */
  51496. rotation: Vector3;
  51497. /**
  51498. * Stores the rotation quaternion
  51499. */
  51500. rotationQuaternion: Nullable<Quaternion>;
  51501. /**
  51502. * Stores the scaling vector
  51503. */
  51504. scaling: Vector3;
  51505. /**
  51506. * Convert the Mesh to CSG
  51507. * @param mesh The Mesh to convert to CSG
  51508. * @returns A new CSG from the Mesh
  51509. */
  51510. static FromMesh(mesh: Mesh): CSG;
  51511. /**
  51512. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51513. * @param polygons Polygons used to construct a CSG solid
  51514. */
  51515. private static FromPolygons;
  51516. /**
  51517. * Clones, or makes a deep copy, of the CSG
  51518. * @returns A new CSG
  51519. */
  51520. clone(): CSG;
  51521. /**
  51522. * Unions this CSG with another CSG
  51523. * @param csg The CSG to union against this CSG
  51524. * @returns The unioned CSG
  51525. */
  51526. union(csg: CSG): CSG;
  51527. /**
  51528. * Unions this CSG with another CSG in place
  51529. * @param csg The CSG to union against this CSG
  51530. */
  51531. unionInPlace(csg: CSG): void;
  51532. /**
  51533. * Subtracts this CSG with another CSG
  51534. * @param csg The CSG to subtract against this CSG
  51535. * @returns A new CSG
  51536. */
  51537. subtract(csg: CSG): CSG;
  51538. /**
  51539. * Subtracts this CSG with another CSG in place
  51540. * @param csg The CSG to subtact against this CSG
  51541. */
  51542. subtractInPlace(csg: CSG): void;
  51543. /**
  51544. * Intersect this CSG with another CSG
  51545. * @param csg The CSG to intersect against this CSG
  51546. * @returns A new CSG
  51547. */
  51548. intersect(csg: CSG): CSG;
  51549. /**
  51550. * Intersects this CSG with another CSG in place
  51551. * @param csg The CSG to intersect against this CSG
  51552. */
  51553. intersectInPlace(csg: CSG): void;
  51554. /**
  51555. * Return a new CSG solid with solid and empty space switched. This solid is
  51556. * not modified.
  51557. * @returns A new CSG solid with solid and empty space switched
  51558. */
  51559. inverse(): CSG;
  51560. /**
  51561. * Inverses the CSG in place
  51562. */
  51563. inverseInPlace(): void;
  51564. /**
  51565. * This is used to keep meshes transformations so they can be restored
  51566. * when we build back a Babylon Mesh
  51567. * NB : All CSG operations are performed in world coordinates
  51568. * @param csg The CSG to copy the transform attributes from
  51569. * @returns This CSG
  51570. */
  51571. copyTransformAttributes(csg: CSG): CSG;
  51572. /**
  51573. * Build Raw mesh from CSG
  51574. * Coordinates here are in world space
  51575. * @param name The name of the mesh geometry
  51576. * @param scene The Scene
  51577. * @param keepSubMeshes Specifies if the submeshes should be kept
  51578. * @returns A new Mesh
  51579. */
  51580. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51581. /**
  51582. * Build Mesh from CSG taking material and transforms into account
  51583. * @param name The name of the Mesh
  51584. * @param material The material of the Mesh
  51585. * @param scene The Scene
  51586. * @param keepSubMeshes Specifies if submeshes should be kept
  51587. * @returns The new Mesh
  51588. */
  51589. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51590. }
  51591. }
  51592. declare module "babylonjs/Meshes/trailMesh" {
  51593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51594. import { Mesh } from "babylonjs/Meshes/mesh";
  51595. import { Scene } from "babylonjs/scene";
  51596. /**
  51597. * Class used to create a trail following a mesh
  51598. */
  51599. export class TrailMesh extends Mesh {
  51600. private _generator;
  51601. private _autoStart;
  51602. private _running;
  51603. private _diameter;
  51604. private _length;
  51605. private _sectionPolygonPointsCount;
  51606. private _sectionVectors;
  51607. private _sectionNormalVectors;
  51608. private _beforeRenderObserver;
  51609. /**
  51610. * @constructor
  51611. * @param name The value used by scene.getMeshByName() to do a lookup.
  51612. * @param generator The mesh to generate a trail.
  51613. * @param scene The scene to add this mesh to.
  51614. * @param diameter Diameter of trailing mesh. Default is 1.
  51615. * @param length Length of trailing mesh. Default is 60.
  51616. * @param autoStart Automatically start trailing mesh. Default true.
  51617. */
  51618. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51619. /**
  51620. * "TrailMesh"
  51621. * @returns "TrailMesh"
  51622. */
  51623. getClassName(): string;
  51624. private _createMesh;
  51625. /**
  51626. * Start trailing mesh.
  51627. */
  51628. start(): void;
  51629. /**
  51630. * Stop trailing mesh.
  51631. */
  51632. stop(): void;
  51633. /**
  51634. * Update trailing mesh geometry.
  51635. */
  51636. update(): void;
  51637. /**
  51638. * Returns a new TrailMesh object.
  51639. * @param name is a string, the name given to the new mesh
  51640. * @param newGenerator use new generator object for cloned trail mesh
  51641. * @returns a new mesh
  51642. */
  51643. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51644. /**
  51645. * Serializes this trail mesh
  51646. * @param serializationObject object to write serialization to
  51647. */
  51648. serialize(serializationObject: any): void;
  51649. /**
  51650. * Parses a serialized trail mesh
  51651. * @param parsedMesh the serialized mesh
  51652. * @param scene the scene to create the trail mesh in
  51653. * @returns the created trail mesh
  51654. */
  51655. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51656. }
  51657. }
  51658. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51659. import { Vector4 } from "babylonjs/Maths/math";
  51660. import { Mesh } from "babylonjs/Meshes/mesh";
  51661. /**
  51662. * Class containing static functions to help procedurally build meshes
  51663. */
  51664. export class TorusKnotBuilder {
  51665. /**
  51666. * Creates a torus knot mesh
  51667. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51668. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51669. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51670. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51674. * @param name defines the name of the mesh
  51675. * @param options defines the options used to create the mesh
  51676. * @param scene defines the hosting scene
  51677. * @returns the torus knot mesh
  51678. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51679. */
  51680. static CreateTorusKnot(name: string, options: {
  51681. radius?: number;
  51682. tube?: number;
  51683. radialSegments?: number;
  51684. tubularSegments?: number;
  51685. p?: number;
  51686. q?: number;
  51687. updatable?: boolean;
  51688. sideOrientation?: number;
  51689. frontUVs?: Vector4;
  51690. backUVs?: Vector4;
  51691. }, scene: any): Mesh;
  51692. }
  51693. }
  51694. declare module "babylonjs/Meshes/polygonMesh" {
  51695. import { Scene } from "babylonjs/scene";
  51696. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51697. import { Mesh } from "babylonjs/Meshes/mesh";
  51698. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51699. /**
  51700. * Polygon
  51701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51702. */
  51703. export class Polygon {
  51704. /**
  51705. * Creates a rectangle
  51706. * @param xmin bottom X coord
  51707. * @param ymin bottom Y coord
  51708. * @param xmax top X coord
  51709. * @param ymax top Y coord
  51710. * @returns points that make the resulting rectation
  51711. */
  51712. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51713. /**
  51714. * Creates a circle
  51715. * @param radius radius of circle
  51716. * @param cx scale in x
  51717. * @param cy scale in y
  51718. * @param numberOfSides number of sides that make up the circle
  51719. * @returns points that make the resulting circle
  51720. */
  51721. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51722. /**
  51723. * Creates a polygon from input string
  51724. * @param input Input polygon data
  51725. * @returns the parsed points
  51726. */
  51727. static Parse(input: string): Vector2[];
  51728. /**
  51729. * Starts building a polygon from x and y coordinates
  51730. * @param x x coordinate
  51731. * @param y y coordinate
  51732. * @returns the started path2
  51733. */
  51734. static StartingAt(x: number, y: number): Path2;
  51735. }
  51736. /**
  51737. * Builds a polygon
  51738. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51739. */
  51740. export class PolygonMeshBuilder {
  51741. private _points;
  51742. private _outlinepoints;
  51743. private _holes;
  51744. private _name;
  51745. private _scene;
  51746. private _epoints;
  51747. private _eholes;
  51748. private _addToepoint;
  51749. /**
  51750. * Babylon reference to the earcut plugin.
  51751. */
  51752. bjsEarcut: any;
  51753. /**
  51754. * Creates a PolygonMeshBuilder
  51755. * @param name name of the builder
  51756. * @param contours Path of the polygon
  51757. * @param scene scene to add to when creating the mesh
  51758. * @param earcutInjection can be used to inject your own earcut reference
  51759. */
  51760. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51761. /**
  51762. * Adds a whole within the polygon
  51763. * @param hole Array of points defining the hole
  51764. * @returns this
  51765. */
  51766. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51767. /**
  51768. * Creates the polygon
  51769. * @param updatable If the mesh should be updatable
  51770. * @param depth The depth of the mesh created
  51771. * @returns the created mesh
  51772. */
  51773. build(updatable?: boolean, depth?: number): Mesh;
  51774. /**
  51775. * Creates the polygon
  51776. * @param depth The depth of the mesh created
  51777. * @returns the created VertexData
  51778. */
  51779. buildVertexData(depth?: number): VertexData;
  51780. /**
  51781. * Adds a side to the polygon
  51782. * @param positions points that make the polygon
  51783. * @param normals normals of the polygon
  51784. * @param uvs uvs of the polygon
  51785. * @param indices indices of the polygon
  51786. * @param bounds bounds of the polygon
  51787. * @param points points of the polygon
  51788. * @param depth depth of the polygon
  51789. * @param flip flip of the polygon
  51790. */
  51791. private addSide;
  51792. }
  51793. }
  51794. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51795. import { Scene } from "babylonjs/scene";
  51796. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51797. import { Mesh } from "babylonjs/Meshes/mesh";
  51798. import { Nullable } from "babylonjs/types";
  51799. /**
  51800. * Class containing static functions to help procedurally build meshes
  51801. */
  51802. export class PolygonBuilder {
  51803. /**
  51804. * Creates a polygon mesh
  51805. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51806. * * 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
  51807. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51810. * * Remember you can only change the shape positions, not their number when updating a polygon
  51811. * @param name defines the name of the mesh
  51812. * @param options defines the options used to create the mesh
  51813. * @param scene defines the hosting scene
  51814. * @param earcutInjection can be used to inject your own earcut reference
  51815. * @returns the polygon mesh
  51816. */
  51817. static CreatePolygon(name: string, options: {
  51818. shape: Vector3[];
  51819. holes?: Vector3[][];
  51820. depth?: number;
  51821. faceUV?: Vector4[];
  51822. faceColors?: Color4[];
  51823. updatable?: boolean;
  51824. sideOrientation?: number;
  51825. frontUVs?: Vector4;
  51826. backUVs?: Vector4;
  51827. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51828. /**
  51829. * Creates an extruded polygon mesh, with depth in the Y direction.
  51830. * * 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)
  51831. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51832. * @param name defines the name of the mesh
  51833. * @param options defines the options used to create the mesh
  51834. * @param scene defines the hosting scene
  51835. * @param earcutInjection can be used to inject your own earcut reference
  51836. * @returns the polygon mesh
  51837. */
  51838. static ExtrudePolygon(name: string, options: {
  51839. shape: Vector3[];
  51840. holes?: Vector3[][];
  51841. depth?: number;
  51842. faceUV?: Vector4[];
  51843. faceColors?: Color4[];
  51844. updatable?: boolean;
  51845. sideOrientation?: number;
  51846. frontUVs?: Vector4;
  51847. backUVs?: Vector4;
  51848. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51849. }
  51850. }
  51851. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51852. import { Scene } from "babylonjs/scene";
  51853. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51854. import { Mesh } from "babylonjs/Meshes/mesh";
  51855. import { Nullable } from "babylonjs/types";
  51856. /**
  51857. * Class containing static functions to help procedurally build meshes
  51858. */
  51859. export class LatheBuilder {
  51860. /**
  51861. * Creates lathe mesh.
  51862. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51863. * * 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
  51864. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51865. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51866. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51867. * * 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
  51868. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51869. * * 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
  51870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51874. * @param name defines the name of the mesh
  51875. * @param options defines the options used to create the mesh
  51876. * @param scene defines the hosting scene
  51877. * @returns the lathe mesh
  51878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51879. */
  51880. static CreateLathe(name: string, options: {
  51881. shape: Vector3[];
  51882. radius?: number;
  51883. tessellation?: number;
  51884. clip?: number;
  51885. arc?: number;
  51886. closed?: boolean;
  51887. updatable?: boolean;
  51888. sideOrientation?: number;
  51889. frontUVs?: Vector4;
  51890. backUVs?: Vector4;
  51891. cap?: number;
  51892. invertUV?: boolean;
  51893. }, scene?: Nullable<Scene>): Mesh;
  51894. }
  51895. }
  51896. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51897. import { Nullable } from "babylonjs/types";
  51898. import { Scene } from "babylonjs/scene";
  51899. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51900. import { Mesh } from "babylonjs/Meshes/mesh";
  51901. /**
  51902. * Class containing static functions to help procedurally build meshes
  51903. */
  51904. export class TubeBuilder {
  51905. /**
  51906. * Creates a tube mesh.
  51907. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51908. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51909. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51910. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51911. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51912. * * 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)
  51913. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51914. * * 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
  51915. * * 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
  51916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51920. * @param name defines the name of the mesh
  51921. * @param options defines the options used to create the mesh
  51922. * @param scene defines the hosting scene
  51923. * @returns the tube mesh
  51924. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51925. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51926. */
  51927. static CreateTube(name: string, options: {
  51928. path: Vector3[];
  51929. radius?: number;
  51930. tessellation?: number;
  51931. radiusFunction?: {
  51932. (i: number, distance: number): number;
  51933. };
  51934. cap?: number;
  51935. arc?: number;
  51936. updatable?: boolean;
  51937. sideOrientation?: number;
  51938. frontUVs?: Vector4;
  51939. backUVs?: Vector4;
  51940. instance?: Mesh;
  51941. invertUV?: boolean;
  51942. }, scene?: Nullable<Scene>): Mesh;
  51943. }
  51944. }
  51945. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51946. import { Scene } from "babylonjs/scene";
  51947. import { Vector4 } from "babylonjs/Maths/math";
  51948. import { Mesh } from "babylonjs/Meshes/mesh";
  51949. import { Nullable } from "babylonjs/types";
  51950. /**
  51951. * Class containing static functions to help procedurally build meshes
  51952. */
  51953. export class IcoSphereBuilder {
  51954. /**
  51955. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51956. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51957. * * 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`)
  51958. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51959. * * 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
  51960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51963. * @param name defines the name of the mesh
  51964. * @param options defines the options used to create the mesh
  51965. * @param scene defines the hosting scene
  51966. * @returns the icosahedron mesh
  51967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51968. */
  51969. static CreateIcoSphere(name: string, options: {
  51970. radius?: number;
  51971. radiusX?: number;
  51972. radiusY?: number;
  51973. radiusZ?: number;
  51974. flat?: boolean;
  51975. subdivisions?: number;
  51976. sideOrientation?: number;
  51977. frontUVs?: Vector4;
  51978. backUVs?: Vector4;
  51979. updatable?: boolean;
  51980. }, scene?: Nullable<Scene>): Mesh;
  51981. }
  51982. }
  51983. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51984. import { Vector3 } from "babylonjs/Maths/math";
  51985. import { Mesh } from "babylonjs/Meshes/mesh";
  51986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51987. /**
  51988. * Class containing static functions to help procedurally build meshes
  51989. */
  51990. export class DecalBuilder {
  51991. /**
  51992. * Creates a decal mesh.
  51993. * 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
  51994. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51995. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51996. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51997. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51998. * @param name defines the name of the mesh
  51999. * @param sourceMesh defines the mesh where the decal must be applied
  52000. * @param options defines the options used to create the mesh
  52001. * @param scene defines the hosting scene
  52002. * @returns the decal mesh
  52003. * @see https://doc.babylonjs.com/how_to/decals
  52004. */
  52005. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52006. position?: Vector3;
  52007. normal?: Vector3;
  52008. size?: Vector3;
  52009. angle?: number;
  52010. }): Mesh;
  52011. }
  52012. }
  52013. declare module "babylonjs/Meshes/meshBuilder" {
  52014. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52015. import { Nullable } from "babylonjs/types";
  52016. import { Scene } from "babylonjs/scene";
  52017. import { Mesh } from "babylonjs/Meshes/mesh";
  52018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52019. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52021. /**
  52022. * Class containing static functions to help procedurally build meshes
  52023. */
  52024. export class MeshBuilder {
  52025. /**
  52026. * Creates a box mesh
  52027. * * The parameter `size` sets the size (float) of each box side (default 1)
  52028. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52029. * * 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)
  52030. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52034. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52035. * @param name defines the name of the mesh
  52036. * @param options defines the options used to create the mesh
  52037. * @param scene defines the hosting scene
  52038. * @returns the box mesh
  52039. */
  52040. static CreateBox(name: string, options: {
  52041. size?: number;
  52042. width?: number;
  52043. height?: number;
  52044. depth?: number;
  52045. faceUV?: Vector4[];
  52046. faceColors?: Color4[];
  52047. sideOrientation?: number;
  52048. frontUVs?: Vector4;
  52049. backUVs?: Vector4;
  52050. updatable?: boolean;
  52051. }, scene?: Nullable<Scene>): Mesh;
  52052. /**
  52053. * Creates a sphere mesh
  52054. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52055. * * 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`)
  52056. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52057. * * 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
  52058. * * 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)
  52059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52062. * @param name defines the name of the mesh
  52063. * @param options defines the options used to create the mesh
  52064. * @param scene defines the hosting scene
  52065. * @returns the sphere mesh
  52066. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52067. */
  52068. static CreateSphere(name: string, options: {
  52069. segments?: number;
  52070. diameter?: number;
  52071. diameterX?: number;
  52072. diameterY?: number;
  52073. diameterZ?: number;
  52074. arc?: number;
  52075. slice?: number;
  52076. sideOrientation?: number;
  52077. frontUVs?: Vector4;
  52078. backUVs?: Vector4;
  52079. updatable?: boolean;
  52080. }, scene?: Nullable<Scene>): Mesh;
  52081. /**
  52082. * Creates a plane polygonal mesh. By default, this is a disc
  52083. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52084. * * 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
  52085. * * 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
  52086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52089. * @param name defines the name of the mesh
  52090. * @param options defines the options used to create the mesh
  52091. * @param scene defines the hosting scene
  52092. * @returns the plane polygonal mesh
  52093. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52094. */
  52095. static CreateDisc(name: string, options: {
  52096. radius?: number;
  52097. tessellation?: number;
  52098. arc?: number;
  52099. updatable?: boolean;
  52100. sideOrientation?: number;
  52101. frontUVs?: Vector4;
  52102. backUVs?: Vector4;
  52103. }, scene?: Nullable<Scene>): Mesh;
  52104. /**
  52105. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52106. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52107. * * 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`)
  52108. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52109. * * 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
  52110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52113. * @param name defines the name of the mesh
  52114. * @param options defines the options used to create the mesh
  52115. * @param scene defines the hosting scene
  52116. * @returns the icosahedron mesh
  52117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52118. */
  52119. static CreateIcoSphere(name: string, options: {
  52120. radius?: number;
  52121. radiusX?: number;
  52122. radiusY?: number;
  52123. radiusZ?: number;
  52124. flat?: boolean;
  52125. subdivisions?: number;
  52126. sideOrientation?: number;
  52127. frontUVs?: Vector4;
  52128. backUVs?: Vector4;
  52129. updatable?: boolean;
  52130. }, scene?: Nullable<Scene>): Mesh;
  52131. /**
  52132. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52133. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52134. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52135. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52136. * * 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
  52137. * * 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
  52138. * * 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
  52139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52142. * * 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
  52143. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52144. * * 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
  52145. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52147. * @param name defines the name of the mesh
  52148. * @param options defines the options used to create the mesh
  52149. * @param scene defines the hosting scene
  52150. * @returns the ribbon mesh
  52151. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52153. */
  52154. static CreateRibbon(name: string, options: {
  52155. pathArray: Vector3[][];
  52156. closeArray?: boolean;
  52157. closePath?: boolean;
  52158. offset?: number;
  52159. updatable?: boolean;
  52160. sideOrientation?: number;
  52161. frontUVs?: Vector4;
  52162. backUVs?: Vector4;
  52163. instance?: Mesh;
  52164. invertUV?: boolean;
  52165. uvs?: Vector2[];
  52166. colors?: Color4[];
  52167. }, scene?: Nullable<Scene>): Mesh;
  52168. /**
  52169. * Creates a cylinder or a cone mesh
  52170. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52171. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52172. * * 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.
  52173. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52174. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52175. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52176. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52177. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52178. * * 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).
  52179. * * 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
  52180. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52181. * * 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
  52182. * * 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.
  52183. * * If `enclose` is false, a ring surface is one element.
  52184. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52185. * * 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
  52186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52189. * @param name defines the name of the mesh
  52190. * @param options defines the options used to create the mesh
  52191. * @param scene defines the hosting scene
  52192. * @returns the cylinder mesh
  52193. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52194. */
  52195. static CreateCylinder(name: string, options: {
  52196. height?: number;
  52197. diameterTop?: number;
  52198. diameterBottom?: number;
  52199. diameter?: number;
  52200. tessellation?: number;
  52201. subdivisions?: number;
  52202. arc?: number;
  52203. faceColors?: Color4[];
  52204. faceUV?: Vector4[];
  52205. updatable?: boolean;
  52206. hasRings?: boolean;
  52207. enclose?: boolean;
  52208. sideOrientation?: number;
  52209. frontUVs?: Vector4;
  52210. backUVs?: Vector4;
  52211. }, scene?: Nullable<Scene>): Mesh;
  52212. /**
  52213. * Creates a torus mesh
  52214. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52215. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52216. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52220. * @param name defines the name of the mesh
  52221. * @param options defines the options used to create the mesh
  52222. * @param scene defines the hosting scene
  52223. * @returns the torus mesh
  52224. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52225. */
  52226. static CreateTorus(name: string, options: {
  52227. diameter?: number;
  52228. thickness?: number;
  52229. tessellation?: number;
  52230. updatable?: boolean;
  52231. sideOrientation?: number;
  52232. frontUVs?: Vector4;
  52233. backUVs?: Vector4;
  52234. }, scene?: Nullable<Scene>): Mesh;
  52235. /**
  52236. * Creates a torus knot mesh
  52237. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52238. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52239. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52240. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52244. * @param name defines the name of the mesh
  52245. * @param options defines the options used to create the mesh
  52246. * @param scene defines the hosting scene
  52247. * @returns the torus knot mesh
  52248. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52249. */
  52250. static CreateTorusKnot(name: string, options: {
  52251. radius?: number;
  52252. tube?: number;
  52253. radialSegments?: number;
  52254. tubularSegments?: number;
  52255. p?: number;
  52256. q?: number;
  52257. updatable?: boolean;
  52258. sideOrientation?: number;
  52259. frontUVs?: Vector4;
  52260. backUVs?: Vector4;
  52261. }, scene?: Nullable<Scene>): Mesh;
  52262. /**
  52263. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52264. * * 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
  52265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52266. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52267. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52268. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52269. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52270. * * 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
  52271. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52274. * @param name defines the name of the new line system
  52275. * @param options defines the options used to create the line system
  52276. * @param scene defines the hosting scene
  52277. * @returns a new line system mesh
  52278. */
  52279. static CreateLineSystem(name: string, options: {
  52280. lines: Vector3[][];
  52281. updatable?: boolean;
  52282. instance?: Nullable<LinesMesh>;
  52283. colors?: Nullable<Color4[][]>;
  52284. useVertexAlpha?: boolean;
  52285. }, scene: Nullable<Scene>): LinesMesh;
  52286. /**
  52287. * Creates a line mesh
  52288. * 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
  52289. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52290. * * The parameter `points` is an array successive Vector3
  52291. * * 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
  52292. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52293. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52294. * * When updating an instance, remember that only point positions can change, not the number of points
  52295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52297. * @param name defines the name of the new line system
  52298. * @param options defines the options used to create the line system
  52299. * @param scene defines the hosting scene
  52300. * @returns a new line mesh
  52301. */
  52302. static CreateLines(name: string, options: {
  52303. points: Vector3[];
  52304. updatable?: boolean;
  52305. instance?: Nullable<LinesMesh>;
  52306. colors?: Color4[];
  52307. useVertexAlpha?: boolean;
  52308. }, scene?: Nullable<Scene>): LinesMesh;
  52309. /**
  52310. * Creates a dashed line mesh
  52311. * * 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
  52312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52313. * * The parameter `points` is an array successive Vector3
  52314. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52315. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52316. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52317. * * 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
  52318. * * When updating an instance, remember that only point positions can change, not the number of points
  52319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52320. * @param name defines the name of the mesh
  52321. * @param options defines the options used to create the mesh
  52322. * @param scene defines the hosting scene
  52323. * @returns the dashed line mesh
  52324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52325. */
  52326. static CreateDashedLines(name: string, options: {
  52327. points: Vector3[];
  52328. dashSize?: number;
  52329. gapSize?: number;
  52330. dashNb?: number;
  52331. updatable?: boolean;
  52332. instance?: LinesMesh;
  52333. }, scene?: Nullable<Scene>): LinesMesh;
  52334. /**
  52335. * 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.
  52336. * * 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.
  52337. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52338. * * 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.
  52339. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52340. * * 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
  52341. * * 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
  52342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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. * @param name defines the name of the mesh
  52348. * @param options defines the options used to create the mesh
  52349. * @param scene defines the hosting scene
  52350. * @returns the extruded shape mesh
  52351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52353. */
  52354. static ExtrudeShape(name: string, options: {
  52355. shape: Vector3[];
  52356. path: Vector3[];
  52357. scale?: number;
  52358. rotation?: number;
  52359. cap?: number;
  52360. updatable?: boolean;
  52361. sideOrientation?: number;
  52362. frontUVs?: Vector4;
  52363. backUVs?: Vector4;
  52364. instance?: Mesh;
  52365. invertUV?: boolean;
  52366. }, scene?: Nullable<Scene>): Mesh;
  52367. /**
  52368. * Creates an custom extruded shape mesh.
  52369. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52370. * * 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.
  52371. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52372. * * 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
  52373. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52374. * * 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
  52375. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52376. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52377. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52378. * * 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
  52379. * * 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
  52380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52385. * @param name defines the name of the mesh
  52386. * @param options defines the options used to create the mesh
  52387. * @param scene defines the hosting scene
  52388. * @returns the custom extruded shape mesh
  52389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52392. */
  52393. static ExtrudeShapeCustom(name: string, options: {
  52394. shape: Vector3[];
  52395. path: Vector3[];
  52396. scaleFunction?: any;
  52397. rotationFunction?: any;
  52398. ribbonCloseArray?: boolean;
  52399. ribbonClosePath?: boolean;
  52400. cap?: number;
  52401. updatable?: boolean;
  52402. sideOrientation?: number;
  52403. frontUVs?: Vector4;
  52404. backUVs?: Vector4;
  52405. instance?: Mesh;
  52406. invertUV?: boolean;
  52407. }, scene?: Nullable<Scene>): Mesh;
  52408. /**
  52409. * Creates lathe mesh.
  52410. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52411. * * 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
  52412. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52413. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52414. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52415. * * 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
  52416. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52417. * * 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
  52418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52422. * @param name defines the name of the mesh
  52423. * @param options defines the options used to create the mesh
  52424. * @param scene defines the hosting scene
  52425. * @returns the lathe mesh
  52426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52427. */
  52428. static CreateLathe(name: string, options: {
  52429. shape: Vector3[];
  52430. radius?: number;
  52431. tessellation?: number;
  52432. clip?: number;
  52433. arc?: number;
  52434. closed?: boolean;
  52435. updatable?: boolean;
  52436. sideOrientation?: number;
  52437. frontUVs?: Vector4;
  52438. backUVs?: Vector4;
  52439. cap?: number;
  52440. invertUV?: boolean;
  52441. }, scene?: Nullable<Scene>): Mesh;
  52442. /**
  52443. * Creates a plane mesh
  52444. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52445. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52446. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52450. * @param name defines the name of the mesh
  52451. * @param options defines the options used to create the mesh
  52452. * @param scene defines the hosting scene
  52453. * @returns the plane mesh
  52454. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52455. */
  52456. static CreatePlane(name: string, options: {
  52457. size?: number;
  52458. width?: number;
  52459. height?: number;
  52460. sideOrientation?: number;
  52461. frontUVs?: Vector4;
  52462. backUVs?: Vector4;
  52463. updatable?: boolean;
  52464. sourcePlane?: Plane;
  52465. }, scene?: Nullable<Scene>): Mesh;
  52466. /**
  52467. * Creates a ground mesh
  52468. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52469. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52471. * @param name defines the name of the mesh
  52472. * @param options defines the options used to create the mesh
  52473. * @param scene defines the hosting scene
  52474. * @returns the ground mesh
  52475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52476. */
  52477. static CreateGround(name: string, options: {
  52478. width?: number;
  52479. height?: number;
  52480. subdivisions?: number;
  52481. subdivisionsX?: number;
  52482. subdivisionsY?: number;
  52483. updatable?: boolean;
  52484. }, scene?: Nullable<Scene>): Mesh;
  52485. /**
  52486. * Creates a tiled ground mesh
  52487. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52488. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52489. * * 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
  52490. * * 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
  52491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52492. * @param name defines the name of the mesh
  52493. * @param options defines the options used to create the mesh
  52494. * @param scene defines the hosting scene
  52495. * @returns the tiled ground mesh
  52496. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52497. */
  52498. static CreateTiledGround(name: string, options: {
  52499. xmin: number;
  52500. zmin: number;
  52501. xmax: number;
  52502. zmax: number;
  52503. subdivisions?: {
  52504. w: number;
  52505. h: number;
  52506. };
  52507. precision?: {
  52508. w: number;
  52509. h: number;
  52510. };
  52511. updatable?: boolean;
  52512. }, scene?: Nullable<Scene>): Mesh;
  52513. /**
  52514. * Creates a ground mesh from a height map
  52515. * * The parameter `url` sets the URL of the height map image resource.
  52516. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52517. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52518. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52519. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52520. * * 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.
  52521. * * 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).
  52522. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  52526. * @param options defines the options used to create the mesh
  52527. * @param scene defines the hosting scene
  52528. * @returns the ground mesh
  52529. * @see https://doc.babylonjs.com/babylon101/height_map
  52530. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52531. */
  52532. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52533. width?: number;
  52534. height?: number;
  52535. subdivisions?: number;
  52536. minHeight?: number;
  52537. maxHeight?: number;
  52538. colorFilter?: Color3;
  52539. alphaFilter?: number;
  52540. updatable?: boolean;
  52541. onReady?: (mesh: GroundMesh) => void;
  52542. }, scene?: Nullable<Scene>): GroundMesh;
  52543. /**
  52544. * Creates a polygon mesh
  52545. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52546. * * 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
  52547. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52550. * * Remember you can only change the shape positions, not their number when updating a polygon
  52551. * @param name defines the name of the mesh
  52552. * @param options defines the options used to create the mesh
  52553. * @param scene defines the hosting scene
  52554. * @param earcutInjection can be used to inject your own earcut reference
  52555. * @returns the polygon mesh
  52556. */
  52557. static CreatePolygon(name: string, options: {
  52558. shape: Vector3[];
  52559. holes?: Vector3[][];
  52560. depth?: number;
  52561. faceUV?: Vector4[];
  52562. faceColors?: Color4[];
  52563. updatable?: boolean;
  52564. sideOrientation?: number;
  52565. frontUVs?: Vector4;
  52566. backUVs?: Vector4;
  52567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52568. /**
  52569. * Creates an extruded polygon mesh, with depth in the Y direction.
  52570. * * 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)
  52571. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52572. * @param name defines the name of the mesh
  52573. * @param options defines the options used to create the mesh
  52574. * @param scene defines the hosting scene
  52575. * @param earcutInjection can be used to inject your own earcut reference
  52576. * @returns the polygon mesh
  52577. */
  52578. static ExtrudePolygon(name: string, options: {
  52579. shape: Vector3[];
  52580. holes?: Vector3[][];
  52581. depth?: number;
  52582. faceUV?: Vector4[];
  52583. faceColors?: Color4[];
  52584. updatable?: boolean;
  52585. sideOrientation?: number;
  52586. frontUVs?: Vector4;
  52587. backUVs?: Vector4;
  52588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52589. /**
  52590. * Creates a tube mesh.
  52591. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52592. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52593. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52594. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52595. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52596. * * 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)
  52597. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52598. * * 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
  52599. * * 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
  52600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52604. * @param name defines the name of the mesh
  52605. * @param options defines the options used to create the mesh
  52606. * @param scene defines the hosting scene
  52607. * @returns the tube mesh
  52608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52609. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52610. */
  52611. static CreateTube(name: string, options: {
  52612. path: Vector3[];
  52613. radius?: number;
  52614. tessellation?: number;
  52615. radiusFunction?: {
  52616. (i: number, distance: number): number;
  52617. };
  52618. cap?: number;
  52619. arc?: number;
  52620. updatable?: boolean;
  52621. sideOrientation?: number;
  52622. frontUVs?: Vector4;
  52623. backUVs?: Vector4;
  52624. instance?: Mesh;
  52625. invertUV?: boolean;
  52626. }, scene?: Nullable<Scene>): Mesh;
  52627. /**
  52628. * Creates a polyhedron mesh
  52629. * * 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
  52630. * * The parameter `size` (positive float, default 1) sets the polygon size
  52631. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52632. * * 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`
  52633. * * 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
  52634. * * 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)`)
  52635. * * 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
  52636. * * 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
  52637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52640. * @param name defines the name of the mesh
  52641. * @param options defines the options used to create the mesh
  52642. * @param scene defines the hosting scene
  52643. * @returns the polyhedron mesh
  52644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52645. */
  52646. static CreatePolyhedron(name: string, options: {
  52647. type?: number;
  52648. size?: number;
  52649. sizeX?: number;
  52650. sizeY?: number;
  52651. sizeZ?: number;
  52652. custom?: any;
  52653. faceUV?: Vector4[];
  52654. faceColors?: Color4[];
  52655. flat?: boolean;
  52656. updatable?: boolean;
  52657. sideOrientation?: number;
  52658. frontUVs?: Vector4;
  52659. backUVs?: Vector4;
  52660. }, scene?: Nullable<Scene>): Mesh;
  52661. /**
  52662. * Creates a decal mesh.
  52663. * 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
  52664. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52665. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52666. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52667. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52668. * @param name defines the name of the mesh
  52669. * @param sourceMesh defines the mesh where the decal must be applied
  52670. * @param options defines the options used to create the mesh
  52671. * @param scene defines the hosting scene
  52672. * @returns the decal mesh
  52673. * @see https://doc.babylonjs.com/how_to/decals
  52674. */
  52675. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52676. position?: Vector3;
  52677. normal?: Vector3;
  52678. size?: Vector3;
  52679. angle?: number;
  52680. }): Mesh;
  52681. }
  52682. }
  52683. declare module "babylonjs/Meshes/meshSimplification" {
  52684. import { Mesh } from "babylonjs/Meshes/mesh";
  52685. /**
  52686. * A simplifier interface for future simplification implementations
  52687. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52688. */
  52689. export interface ISimplifier {
  52690. /**
  52691. * Simplification of a given mesh according to the given settings.
  52692. * Since this requires computation, it is assumed that the function runs async.
  52693. * @param settings The settings of the simplification, including quality and distance
  52694. * @param successCallback A callback that will be called after the mesh was simplified.
  52695. * @param errorCallback in case of an error, this callback will be called. optional.
  52696. */
  52697. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52698. }
  52699. /**
  52700. * Expected simplification settings.
  52701. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52703. */
  52704. export interface ISimplificationSettings {
  52705. /**
  52706. * Gets or sets the expected quality
  52707. */
  52708. quality: number;
  52709. /**
  52710. * Gets or sets the distance when this optimized version should be used
  52711. */
  52712. distance: number;
  52713. /**
  52714. * Gets an already optimized mesh
  52715. */
  52716. optimizeMesh?: boolean;
  52717. }
  52718. /**
  52719. * Class used to specify simplification options
  52720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52721. */
  52722. export class SimplificationSettings implements ISimplificationSettings {
  52723. /** expected quality */
  52724. quality: number;
  52725. /** distance when this optimized version should be used */
  52726. distance: number;
  52727. /** already optimized mesh */
  52728. optimizeMesh?: boolean | undefined;
  52729. /**
  52730. * Creates a SimplificationSettings
  52731. * @param quality expected quality
  52732. * @param distance distance when this optimized version should be used
  52733. * @param optimizeMesh already optimized mesh
  52734. */
  52735. constructor(
  52736. /** expected quality */
  52737. quality: number,
  52738. /** distance when this optimized version should be used */
  52739. distance: number,
  52740. /** already optimized mesh */
  52741. optimizeMesh?: boolean | undefined);
  52742. }
  52743. /**
  52744. * Interface used to define a simplification task
  52745. */
  52746. export interface ISimplificationTask {
  52747. /**
  52748. * Array of settings
  52749. */
  52750. settings: Array<ISimplificationSettings>;
  52751. /**
  52752. * Simplification type
  52753. */
  52754. simplificationType: SimplificationType;
  52755. /**
  52756. * Mesh to simplify
  52757. */
  52758. mesh: Mesh;
  52759. /**
  52760. * Callback called on success
  52761. */
  52762. successCallback?: () => void;
  52763. /**
  52764. * Defines if parallel processing can be used
  52765. */
  52766. parallelProcessing: boolean;
  52767. }
  52768. /**
  52769. * Queue used to order the simplification tasks
  52770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52771. */
  52772. export class SimplificationQueue {
  52773. private _simplificationArray;
  52774. /**
  52775. * Gets a boolean indicating that the process is still running
  52776. */
  52777. running: boolean;
  52778. /**
  52779. * Creates a new queue
  52780. */
  52781. constructor();
  52782. /**
  52783. * Adds a new simplification task
  52784. * @param task defines a task to add
  52785. */
  52786. addTask(task: ISimplificationTask): void;
  52787. /**
  52788. * Execute next task
  52789. */
  52790. executeNext(): void;
  52791. /**
  52792. * Execute a simplification task
  52793. * @param task defines the task to run
  52794. */
  52795. runSimplification(task: ISimplificationTask): void;
  52796. private getSimplifier;
  52797. }
  52798. /**
  52799. * The implemented types of simplification
  52800. * At the moment only Quadratic Error Decimation is implemented
  52801. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52802. */
  52803. export enum SimplificationType {
  52804. /** Quadratic error decimation */
  52805. QUADRATIC = 0
  52806. }
  52807. }
  52808. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52809. import { Scene } from "babylonjs/scene";
  52810. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52811. import { ISceneComponent } from "babylonjs/sceneComponent";
  52812. module "babylonjs/scene" {
  52813. interface Scene {
  52814. /** @hidden (Backing field) */
  52815. _simplificationQueue: SimplificationQueue;
  52816. /**
  52817. * Gets or sets the simplification queue attached to the scene
  52818. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52819. */
  52820. simplificationQueue: SimplificationQueue;
  52821. }
  52822. }
  52823. module "babylonjs/Meshes/mesh" {
  52824. interface Mesh {
  52825. /**
  52826. * Simplify the mesh according to the given array of settings.
  52827. * Function will return immediately and will simplify async
  52828. * @param settings a collection of simplification settings
  52829. * @param parallelProcessing should all levels calculate parallel or one after the other
  52830. * @param simplificationType the type of simplification to run
  52831. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52832. * @returns the current mesh
  52833. */
  52834. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52835. }
  52836. }
  52837. /**
  52838. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52839. * created in a scene
  52840. */
  52841. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52842. /**
  52843. * The component name helpfull to identify the component in the list of scene components.
  52844. */
  52845. readonly name: string;
  52846. /**
  52847. * The scene the component belongs to.
  52848. */
  52849. scene: Scene;
  52850. /**
  52851. * Creates a new instance of the component for the given scene
  52852. * @param scene Defines the scene to register the component in
  52853. */
  52854. constructor(scene: Scene);
  52855. /**
  52856. * Registers the component in a given scene
  52857. */
  52858. register(): void;
  52859. /**
  52860. * Rebuilds the elements related to this component in case of
  52861. * context lost for instance.
  52862. */
  52863. rebuild(): void;
  52864. /**
  52865. * Disposes the component and the associated ressources
  52866. */
  52867. dispose(): void;
  52868. private _beforeCameraUpdate;
  52869. }
  52870. }
  52871. declare module "babylonjs/Meshes/Builders/index" {
  52872. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52873. export * from "babylonjs/Meshes/Builders/discBuilder";
  52874. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52875. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52876. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52877. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52878. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52879. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52880. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52881. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52882. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52883. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52884. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52885. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52886. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52887. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52888. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52889. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52890. }
  52891. declare module "babylonjs/Meshes/index" {
  52892. export * from "babylonjs/Meshes/abstractMesh";
  52893. export * from "babylonjs/Meshes/buffer";
  52894. export * from "babylonjs/Meshes/Compression/index";
  52895. export * from "babylonjs/Meshes/csg";
  52896. export * from "babylonjs/Meshes/geometry";
  52897. export * from "babylonjs/Meshes/groundMesh";
  52898. export * from "babylonjs/Meshes/trailMesh";
  52899. export * from "babylonjs/Meshes/instancedMesh";
  52900. export * from "babylonjs/Meshes/linesMesh";
  52901. export * from "babylonjs/Meshes/mesh";
  52902. export * from "babylonjs/Meshes/mesh.vertexData";
  52903. export * from "babylonjs/Meshes/meshBuilder";
  52904. export * from "babylonjs/Meshes/meshSimplification";
  52905. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52906. export * from "babylonjs/Meshes/polygonMesh";
  52907. export * from "babylonjs/Meshes/subMesh";
  52908. export * from "babylonjs/Meshes/transformNode";
  52909. export * from "babylonjs/Meshes/Builders/index";
  52910. }
  52911. declare module "babylonjs/Morph/index" {
  52912. export * from "babylonjs/Morph/morphTarget";
  52913. export * from "babylonjs/Morph/morphTargetManager";
  52914. }
  52915. declare module "babylonjs/Offline/database" {
  52916. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52917. /**
  52918. * Class used to enable access to IndexedDB
  52919. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52920. */
  52921. export class Database implements IOfflineProvider {
  52922. private _callbackManifestChecked;
  52923. private _currentSceneUrl;
  52924. private _db;
  52925. private _enableSceneOffline;
  52926. private _enableTexturesOffline;
  52927. private _manifestVersionFound;
  52928. private _mustUpdateRessources;
  52929. private _hasReachedQuota;
  52930. private _isSupported;
  52931. private _idbFactory;
  52932. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52933. private static IsUASupportingBlobStorage;
  52934. /**
  52935. * Gets a boolean indicating if Database storate is enabled (off by default)
  52936. */
  52937. static IDBStorageEnabled: boolean;
  52938. /**
  52939. * Gets a boolean indicating if scene must be saved in the database
  52940. */
  52941. readonly enableSceneOffline: boolean;
  52942. /**
  52943. * Gets a boolean indicating if textures must be saved in the database
  52944. */
  52945. readonly enableTexturesOffline: boolean;
  52946. /**
  52947. * Creates a new Database
  52948. * @param urlToScene defines the url to load the scene
  52949. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52950. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52951. */
  52952. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52953. private static _ParseURL;
  52954. private static _ReturnFullUrlLocation;
  52955. private _checkManifestFile;
  52956. /**
  52957. * Open the database and make it available
  52958. * @param successCallback defines the callback to call on success
  52959. * @param errorCallback defines the callback to call on error
  52960. */
  52961. open(successCallback: () => void, errorCallback: () => void): void;
  52962. /**
  52963. * Loads an image from the database
  52964. * @param url defines the url to load from
  52965. * @param image defines the target DOM image
  52966. */
  52967. loadImage(url: string, image: HTMLImageElement): void;
  52968. private _loadImageFromDBAsync;
  52969. private _saveImageIntoDBAsync;
  52970. private _checkVersionFromDB;
  52971. private _loadVersionFromDBAsync;
  52972. private _saveVersionIntoDBAsync;
  52973. /**
  52974. * Loads a file from database
  52975. * @param url defines the URL to load from
  52976. * @param sceneLoaded defines a callback to call on success
  52977. * @param progressCallBack defines a callback to call when progress changed
  52978. * @param errorCallback defines a callback to call on error
  52979. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52980. */
  52981. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52982. private _loadFileAsync;
  52983. private _saveFileAsync;
  52984. /**
  52985. * Validates if xhr data is correct
  52986. * @param xhr defines the request to validate
  52987. * @param dataType defines the expected data type
  52988. * @returns true if data is correct
  52989. */
  52990. private static _ValidateXHRData;
  52991. }
  52992. }
  52993. declare module "babylonjs/Offline/index" {
  52994. export * from "babylonjs/Offline/database";
  52995. export * from "babylonjs/Offline/IOfflineProvider";
  52996. }
  52997. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52998. /** @hidden */
  52999. export var gpuUpdateParticlesPixelShader: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53005. /** @hidden */
  53006. export var gpuUpdateParticlesVertexShader: {
  53007. name: string;
  53008. shader: string;
  53009. };
  53010. }
  53011. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53012. /** @hidden */
  53013. export var clipPlaneFragmentDeclaration2: {
  53014. name: string;
  53015. shader: string;
  53016. };
  53017. }
  53018. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53019. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53020. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53022. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53023. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53024. /** @hidden */
  53025. export var gpuRenderParticlesPixelShader: {
  53026. name: string;
  53027. shader: string;
  53028. };
  53029. }
  53030. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53031. /** @hidden */
  53032. export var clipPlaneVertexDeclaration2: {
  53033. name: string;
  53034. shader: string;
  53035. };
  53036. }
  53037. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53038. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53039. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53040. /** @hidden */
  53041. export var gpuRenderParticlesVertexShader: {
  53042. name: string;
  53043. shader: string;
  53044. };
  53045. }
  53046. declare module "babylonjs/Particles/gpuParticleSystem" {
  53047. import { Nullable } from "babylonjs/types";
  53048. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53049. import { Observable } from "babylonjs/Misc/observable";
  53050. import { Color4, Color3 } from "babylonjs/Maths/math";
  53051. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53052. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53053. import { Scene, IDisposable } from "babylonjs/scene";
  53054. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53055. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53056. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53057. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53058. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53059. /**
  53060. * This represents a GPU particle system in Babylon
  53061. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53062. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53063. */
  53064. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53065. /**
  53066. * The layer mask we are rendering the particles through.
  53067. */
  53068. layerMask: number;
  53069. private _capacity;
  53070. private _activeCount;
  53071. private _currentActiveCount;
  53072. private _accumulatedCount;
  53073. private _renderEffect;
  53074. private _updateEffect;
  53075. private _buffer0;
  53076. private _buffer1;
  53077. private _spriteBuffer;
  53078. private _updateVAO;
  53079. private _renderVAO;
  53080. private _targetIndex;
  53081. private _sourceBuffer;
  53082. private _targetBuffer;
  53083. private _engine;
  53084. private _currentRenderId;
  53085. private _started;
  53086. private _stopped;
  53087. private _timeDelta;
  53088. private _randomTexture;
  53089. private _randomTexture2;
  53090. private _attributesStrideSize;
  53091. private _updateEffectOptions;
  53092. private _randomTextureSize;
  53093. private _actualFrame;
  53094. private readonly _rawTextureWidth;
  53095. /**
  53096. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53097. */
  53098. static readonly IsSupported: boolean;
  53099. /**
  53100. * An event triggered when the system is disposed.
  53101. */
  53102. onDisposeObservable: Observable<GPUParticleSystem>;
  53103. /**
  53104. * Gets the maximum number of particles active at the same time.
  53105. * @returns The max number of active particles.
  53106. */
  53107. getCapacity(): number;
  53108. /**
  53109. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53110. * to override the particles.
  53111. */
  53112. forceDepthWrite: boolean;
  53113. /**
  53114. * Gets or set the number of active particles
  53115. */
  53116. activeParticleCount: number;
  53117. private _preWarmDone;
  53118. /**
  53119. * Is this system ready to be used/rendered
  53120. * @return true if the system is ready
  53121. */
  53122. isReady(): boolean;
  53123. /**
  53124. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53125. * @returns True if it has been started, otherwise false.
  53126. */
  53127. isStarted(): boolean;
  53128. /**
  53129. * Starts the particle system and begins to emit
  53130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53131. */
  53132. start(delay?: number): void;
  53133. /**
  53134. * Stops the particle system.
  53135. */
  53136. stop(): void;
  53137. /**
  53138. * Remove all active particles
  53139. */
  53140. reset(): void;
  53141. /**
  53142. * Returns the string "GPUParticleSystem"
  53143. * @returns a string containing the class name
  53144. */
  53145. getClassName(): string;
  53146. private _colorGradientsTexture;
  53147. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53148. /**
  53149. * Adds a new color gradient
  53150. * @param gradient defines the gradient to use (between 0 and 1)
  53151. * @param color1 defines the color to affect to the specified gradient
  53152. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53153. * @returns the current particle system
  53154. */
  53155. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53156. /**
  53157. * Remove a specific color gradient
  53158. * @param gradient defines the gradient to remove
  53159. * @returns the current particle system
  53160. */
  53161. removeColorGradient(gradient: number): GPUParticleSystem;
  53162. private _angularSpeedGradientsTexture;
  53163. private _sizeGradientsTexture;
  53164. private _velocityGradientsTexture;
  53165. private _limitVelocityGradientsTexture;
  53166. private _dragGradientsTexture;
  53167. private _addFactorGradient;
  53168. /**
  53169. * Adds a new size gradient
  53170. * @param gradient defines the gradient to use (between 0 and 1)
  53171. * @param factor defines the size factor to affect to the specified gradient
  53172. * @returns the current particle system
  53173. */
  53174. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53175. /**
  53176. * Remove a specific size gradient
  53177. * @param gradient defines the gradient to remove
  53178. * @returns the current particle system
  53179. */
  53180. removeSizeGradient(gradient: number): GPUParticleSystem;
  53181. /**
  53182. * Adds a new angular speed gradient
  53183. * @param gradient defines the gradient to use (between 0 and 1)
  53184. * @param factor defines the angular speed to affect to the specified gradient
  53185. * @returns the current particle system
  53186. */
  53187. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53188. /**
  53189. * Remove a specific angular speed gradient
  53190. * @param gradient defines the gradient to remove
  53191. * @returns the current particle system
  53192. */
  53193. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53194. /**
  53195. * Adds a new velocity gradient
  53196. * @param gradient defines the gradient to use (between 0 and 1)
  53197. * @param factor defines the velocity to affect to the specified gradient
  53198. * @returns the current particle system
  53199. */
  53200. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53201. /**
  53202. * Remove a specific velocity gradient
  53203. * @param gradient defines the gradient to remove
  53204. * @returns the current particle system
  53205. */
  53206. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53207. /**
  53208. * Adds a new limit velocity gradient
  53209. * @param gradient defines the gradient to use (between 0 and 1)
  53210. * @param factor defines the limit velocity value to affect to the specified gradient
  53211. * @returns the current particle system
  53212. */
  53213. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53214. /**
  53215. * Remove a specific limit velocity gradient
  53216. * @param gradient defines the gradient to remove
  53217. * @returns the current particle system
  53218. */
  53219. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53220. /**
  53221. * Adds a new drag gradient
  53222. * @param gradient defines the gradient to use (between 0 and 1)
  53223. * @param factor defines the drag value to affect to the specified gradient
  53224. * @returns the current particle system
  53225. */
  53226. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53227. /**
  53228. * Remove a specific drag gradient
  53229. * @param gradient defines the gradient to remove
  53230. * @returns the current particle system
  53231. */
  53232. removeDragGradient(gradient: number): GPUParticleSystem;
  53233. /**
  53234. * Not supported by GPUParticleSystem
  53235. * @param gradient defines the gradient to use (between 0 and 1)
  53236. * @param factor defines the emit rate value to affect to the specified gradient
  53237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53238. * @returns the current particle system
  53239. */
  53240. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53241. /**
  53242. * Not supported by GPUParticleSystem
  53243. * @param gradient defines the gradient to remove
  53244. * @returns the current particle system
  53245. */
  53246. removeEmitRateGradient(gradient: number): IParticleSystem;
  53247. /**
  53248. * Not supported by GPUParticleSystem
  53249. * @param gradient defines the gradient to use (between 0 and 1)
  53250. * @param factor defines the start size value to affect to the specified gradient
  53251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53252. * @returns the current particle system
  53253. */
  53254. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53255. /**
  53256. * Not supported by GPUParticleSystem
  53257. * @param gradient defines the gradient to remove
  53258. * @returns the current particle system
  53259. */
  53260. removeStartSizeGradient(gradient: number): IParticleSystem;
  53261. /**
  53262. * Not supported by GPUParticleSystem
  53263. * @param gradient defines the gradient to use (between 0 and 1)
  53264. * @param min defines the color remap minimal range
  53265. * @param max defines the color remap maximal range
  53266. * @returns the current particle system
  53267. */
  53268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53269. /**
  53270. * Not supported by GPUParticleSystem
  53271. * @param gradient defines the gradient to remove
  53272. * @returns the current particle system
  53273. */
  53274. removeColorRemapGradient(): IParticleSystem;
  53275. /**
  53276. * Not supported by GPUParticleSystem
  53277. * @param gradient defines the gradient to use (between 0 and 1)
  53278. * @param min defines the alpha remap minimal range
  53279. * @param max defines the alpha remap maximal range
  53280. * @returns the current particle system
  53281. */
  53282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53283. /**
  53284. * Not supported by GPUParticleSystem
  53285. * @param gradient defines the gradient to remove
  53286. * @returns the current particle system
  53287. */
  53288. removeAlphaRemapGradient(): IParticleSystem;
  53289. /**
  53290. * Not supported by GPUParticleSystem
  53291. * @param gradient defines the gradient to use (between 0 and 1)
  53292. * @param color defines the color to affect to the specified gradient
  53293. * @returns the current particle system
  53294. */
  53295. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53296. /**
  53297. * Not supported by GPUParticleSystem
  53298. * @param gradient defines the gradient to remove
  53299. * @returns the current particle system
  53300. */
  53301. removeRampGradient(): IParticleSystem;
  53302. /**
  53303. * Not supported by GPUParticleSystem
  53304. * @returns the list of ramp gradients
  53305. */
  53306. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53307. /**
  53308. * Not supported by GPUParticleSystem
  53309. * Gets or sets a boolean indicating that ramp gradients must be used
  53310. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53311. */
  53312. useRampGradients: boolean;
  53313. /**
  53314. * Not supported by GPUParticleSystem
  53315. * @param gradient defines the gradient to use (between 0 and 1)
  53316. * @param factor defines the life time factor to affect to the specified gradient
  53317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53318. * @returns the current particle system
  53319. */
  53320. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53321. /**
  53322. * Not supported by GPUParticleSystem
  53323. * @param gradient defines the gradient to remove
  53324. * @returns the current particle system
  53325. */
  53326. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53327. /**
  53328. * Instantiates a GPU particle system.
  53329. * 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.
  53330. * @param name The name of the particle system
  53331. * @param options The options used to create the system
  53332. * @param scene The scene the particle system belongs to
  53333. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53334. */
  53335. constructor(name: string, options: Partial<{
  53336. capacity: number;
  53337. randomTextureSize: number;
  53338. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53339. protected _reset(): void;
  53340. private _createUpdateVAO;
  53341. private _createRenderVAO;
  53342. private _initialize;
  53343. /** @hidden */
  53344. _recreateUpdateEffect(): void;
  53345. /** @hidden */
  53346. _recreateRenderEffect(): void;
  53347. /**
  53348. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53349. * @param preWarm defines if we are in the pre-warmimg phase
  53350. */
  53351. animate(preWarm?: boolean): void;
  53352. private _createFactorGradientTexture;
  53353. private _createSizeGradientTexture;
  53354. private _createAngularSpeedGradientTexture;
  53355. private _createVelocityGradientTexture;
  53356. private _createLimitVelocityGradientTexture;
  53357. private _createDragGradientTexture;
  53358. private _createColorGradientTexture;
  53359. /**
  53360. * Renders the particle system in its current state
  53361. * @param preWarm defines if the system should only update the particles but not render them
  53362. * @returns the current number of particles
  53363. */
  53364. render(preWarm?: boolean): number;
  53365. /**
  53366. * Rebuilds the particle system
  53367. */
  53368. rebuild(): void;
  53369. private _releaseBuffers;
  53370. private _releaseVAOs;
  53371. /**
  53372. * Disposes the particle system and free the associated resources
  53373. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53374. */
  53375. dispose(disposeTexture?: boolean): void;
  53376. /**
  53377. * Clones the particle system.
  53378. * @param name The name of the cloned object
  53379. * @param newEmitter The new emitter to use
  53380. * @returns the cloned particle system
  53381. */
  53382. clone(name: string, newEmitter: any): GPUParticleSystem;
  53383. /**
  53384. * Serializes the particle system to a JSON object.
  53385. * @returns the JSON object
  53386. */
  53387. serialize(): any;
  53388. /**
  53389. * Parses a JSON object to create a GPU particle system.
  53390. * @param parsedParticleSystem The JSON object to parse
  53391. * @param scene The scene to create the particle system in
  53392. * @param rootUrl The root url to use to load external dependencies like texture
  53393. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53394. * @returns the parsed GPU particle system
  53395. */
  53396. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53397. }
  53398. }
  53399. declare module "babylonjs/Particles/particleSystemSet" {
  53400. import { Nullable } from "babylonjs/types";
  53401. import { Color3 } from "babylonjs/Maths/math";
  53402. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53404. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53405. import { Scene, IDisposable } from "babylonjs/scene";
  53406. /**
  53407. * Represents a set of particle systems working together to create a specific effect
  53408. */
  53409. export class ParticleSystemSet implements IDisposable {
  53410. private _emitterCreationOptions;
  53411. private _emitterNode;
  53412. /**
  53413. * Gets the particle system list
  53414. */
  53415. systems: IParticleSystem[];
  53416. /**
  53417. * Gets the emitter node used with this set
  53418. */
  53419. readonly emitterNode: Nullable<TransformNode>;
  53420. /**
  53421. * Creates a new emitter mesh as a sphere
  53422. * @param options defines the options used to create the sphere
  53423. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53424. * @param scene defines the hosting scene
  53425. */
  53426. setEmitterAsSphere(options: {
  53427. diameter: number;
  53428. segments: number;
  53429. color: Color3;
  53430. }, renderingGroupId: number, scene: Scene): void;
  53431. /**
  53432. * Starts all particle systems of the set
  53433. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53434. */
  53435. start(emitter?: AbstractMesh): void;
  53436. /**
  53437. * Release all associated resources
  53438. */
  53439. dispose(): void;
  53440. /**
  53441. * Serialize the set into a JSON compatible object
  53442. * @returns a JSON compatible representation of the set
  53443. */
  53444. serialize(): any;
  53445. /**
  53446. * Parse a new ParticleSystemSet from a serialized source
  53447. * @param data defines a JSON compatible representation of the set
  53448. * @param scene defines the hosting scene
  53449. * @param gpu defines if we want GPU particles or CPU particles
  53450. * @returns a new ParticleSystemSet
  53451. */
  53452. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53453. }
  53454. }
  53455. declare module "babylonjs/Particles/particleHelper" {
  53456. import { Nullable } from "babylonjs/types";
  53457. import { Scene } from "babylonjs/scene";
  53458. import { Vector3 } from "babylonjs/Maths/math";
  53459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53460. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53461. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53462. /**
  53463. * This class is made for on one-liner static method to help creating particle system set.
  53464. */
  53465. export class ParticleHelper {
  53466. /**
  53467. * Gets or sets base Assets URL
  53468. */
  53469. static BaseAssetsUrl: string;
  53470. /**
  53471. * Create a default particle system that you can tweak
  53472. * @param emitter defines the emitter to use
  53473. * @param capacity defines the system capacity (default is 500 particles)
  53474. * @param scene defines the hosting scene
  53475. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53476. * @returns the new Particle system
  53477. */
  53478. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53479. /**
  53480. * This is the main static method (one-liner) of this helper to create different particle systems
  53481. * @param type This string represents the type to the particle system to create
  53482. * @param scene The scene where the particle system should live
  53483. * @param gpu If the system will use gpu
  53484. * @returns the ParticleSystemSet created
  53485. */
  53486. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53487. /**
  53488. * Static function used to export a particle system to a ParticleSystemSet variable.
  53489. * Please note that the emitter shape is not exported
  53490. * @param systems defines the particle systems to export
  53491. * @returns the created particle system set
  53492. */
  53493. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53494. }
  53495. }
  53496. declare module "babylonjs/Particles/particleSystemComponent" {
  53497. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53498. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53499. import "babylonjs/Shaders/particles.vertex";
  53500. module "babylonjs/Engines/engine" {
  53501. interface Engine {
  53502. /**
  53503. * Create an effect to use with particle systems.
  53504. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53505. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53506. * @param uniformsNames defines a list of attribute names
  53507. * @param samplers defines an array of string used to represent textures
  53508. * @param defines defines the string containing the defines to use to compile the shaders
  53509. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53510. * @param onCompiled defines a function to call when the effect creation is successful
  53511. * @param onError defines a function to call when the effect creation has failed
  53512. * @returns the new Effect
  53513. */
  53514. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53515. }
  53516. }
  53517. module "babylonjs/Meshes/mesh" {
  53518. interface Mesh {
  53519. /**
  53520. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53521. * @returns an array of IParticleSystem
  53522. */
  53523. getEmittedParticleSystems(): IParticleSystem[];
  53524. /**
  53525. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53526. * @returns an array of IParticleSystem
  53527. */
  53528. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53529. }
  53530. }
  53531. /**
  53532. * @hidden
  53533. */
  53534. export var _IDoNeedToBeInTheBuild: number;
  53535. }
  53536. declare module "babylonjs/Particles/index" {
  53537. export * from "babylonjs/Particles/baseParticleSystem";
  53538. export * from "babylonjs/Particles/EmitterTypes/index";
  53539. export * from "babylonjs/Particles/gpuParticleSystem";
  53540. export * from "babylonjs/Particles/IParticleSystem";
  53541. export * from "babylonjs/Particles/particle";
  53542. export * from "babylonjs/Particles/particleHelper";
  53543. export * from "babylonjs/Particles/particleSystem";
  53544. export * from "babylonjs/Particles/particleSystemComponent";
  53545. export * from "babylonjs/Particles/particleSystemSet";
  53546. export * from "babylonjs/Particles/solidParticle";
  53547. export * from "babylonjs/Particles/solidParticleSystem";
  53548. export * from "babylonjs/Particles/subEmitter";
  53549. }
  53550. declare module "babylonjs/Physics/physicsEngineComponent" {
  53551. import { Nullable } from "babylonjs/types";
  53552. import { Observable, Observer } from "babylonjs/Misc/observable";
  53553. import { Vector3 } from "babylonjs/Maths/math";
  53554. import { Mesh } from "babylonjs/Meshes/mesh";
  53555. import { ISceneComponent } from "babylonjs/sceneComponent";
  53556. import { Scene } from "babylonjs/scene";
  53557. import { Node } from "babylonjs/node";
  53558. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53559. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53560. module "babylonjs/scene" {
  53561. interface Scene {
  53562. /** @hidden (Backing field) */
  53563. _physicsEngine: Nullable<IPhysicsEngine>;
  53564. /**
  53565. * Gets the current physics engine
  53566. * @returns a IPhysicsEngine or null if none attached
  53567. */
  53568. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53569. /**
  53570. * Enables physics to the current scene
  53571. * @param gravity defines the scene's gravity for the physics engine
  53572. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53573. * @return a boolean indicating if the physics engine was initialized
  53574. */
  53575. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53576. /**
  53577. * Disables and disposes the physics engine associated with the scene
  53578. */
  53579. disablePhysicsEngine(): void;
  53580. /**
  53581. * Gets a boolean indicating if there is an active physics engine
  53582. * @returns a boolean indicating if there is an active physics engine
  53583. */
  53584. isPhysicsEnabled(): boolean;
  53585. /**
  53586. * Deletes a physics compound impostor
  53587. * @param compound defines the compound to delete
  53588. */
  53589. deleteCompoundImpostor(compound: any): void;
  53590. /**
  53591. * An event triggered when physic simulation is about to be run
  53592. */
  53593. onBeforePhysicsObservable: Observable<Scene>;
  53594. /**
  53595. * An event triggered when physic simulation has been done
  53596. */
  53597. onAfterPhysicsObservable: Observable<Scene>;
  53598. }
  53599. }
  53600. module "babylonjs/Meshes/abstractMesh" {
  53601. interface AbstractMesh {
  53602. /** @hidden */
  53603. _physicsImpostor: Nullable<PhysicsImpostor>;
  53604. /**
  53605. * Gets or sets impostor used for physic simulation
  53606. * @see http://doc.babylonjs.com/features/physics_engine
  53607. */
  53608. physicsImpostor: Nullable<PhysicsImpostor>;
  53609. /**
  53610. * Gets the current physics impostor
  53611. * @see http://doc.babylonjs.com/features/physics_engine
  53612. * @returns a physics impostor or null
  53613. */
  53614. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53615. /** Apply a physic impulse to the mesh
  53616. * @param force defines the force to apply
  53617. * @param contactPoint defines where to apply the force
  53618. * @returns the current mesh
  53619. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53620. */
  53621. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53622. /**
  53623. * Creates a physic joint between two meshes
  53624. * @param otherMesh defines the other mesh to use
  53625. * @param pivot1 defines the pivot to use on this mesh
  53626. * @param pivot2 defines the pivot to use on the other mesh
  53627. * @param options defines additional options (can be plugin dependent)
  53628. * @returns the current mesh
  53629. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53630. */
  53631. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53632. /** @hidden */
  53633. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53634. }
  53635. }
  53636. /**
  53637. * Defines the physics engine scene component responsible to manage a physics engine
  53638. */
  53639. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53640. /**
  53641. * The component name helpful to identify the component in the list of scene components.
  53642. */
  53643. readonly name: string;
  53644. /**
  53645. * The scene the component belongs to.
  53646. */
  53647. scene: Scene;
  53648. /**
  53649. * Creates a new instance of the component for the given scene
  53650. * @param scene Defines the scene to register the component in
  53651. */
  53652. constructor(scene: Scene);
  53653. /**
  53654. * Registers the component in a given scene
  53655. */
  53656. register(): void;
  53657. /**
  53658. * Rebuilds the elements related to this component in case of
  53659. * context lost for instance.
  53660. */
  53661. rebuild(): void;
  53662. /**
  53663. * Disposes the component and the associated ressources
  53664. */
  53665. dispose(): void;
  53666. }
  53667. }
  53668. declare module "babylonjs/Physics/physicsHelper" {
  53669. import { Nullable } from "babylonjs/types";
  53670. import { Vector3 } from "babylonjs/Maths/math";
  53671. import { Mesh } from "babylonjs/Meshes/mesh";
  53672. import { Scene } from "babylonjs/scene";
  53673. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53674. /**
  53675. * A helper for physics simulations
  53676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53677. */
  53678. export class PhysicsHelper {
  53679. private _scene;
  53680. private _physicsEngine;
  53681. /**
  53682. * Initializes the Physics helper
  53683. * @param scene Babylon.js scene
  53684. */
  53685. constructor(scene: Scene);
  53686. /**
  53687. * Applies a radial explosion impulse
  53688. * @param origin the origin of the explosion
  53689. * @param radiusOrEventOptions the radius or the options of radial explosion
  53690. * @param strength the explosion strength
  53691. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53692. * @returns A physics radial explosion event, or null
  53693. */
  53694. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53695. /**
  53696. * Applies a radial explosion force
  53697. * @param origin the origin of the explosion
  53698. * @param radiusOrEventOptions the radius or the options of radial explosion
  53699. * @param strength the explosion strength
  53700. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53701. * @returns A physics radial explosion event, or null
  53702. */
  53703. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53704. /**
  53705. * Creates a gravitational field
  53706. * @param origin the origin of the explosion
  53707. * @param radiusOrEventOptions the radius or the options of radial explosion
  53708. * @param strength the explosion strength
  53709. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53710. * @returns A physics gravitational field event, or null
  53711. */
  53712. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53713. /**
  53714. * Creates a physics updraft event
  53715. * @param origin the origin of the updraft
  53716. * @param radiusOrEventOptions the radius or the options of the updraft
  53717. * @param strength the strength of the updraft
  53718. * @param height the height of the updraft
  53719. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53720. * @returns A physics updraft event, or null
  53721. */
  53722. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53723. /**
  53724. * Creates a physics vortex event
  53725. * @param origin the of the vortex
  53726. * @param radiusOrEventOptions the radius or the options of the vortex
  53727. * @param strength the strength of the vortex
  53728. * @param height the height of the vortex
  53729. * @returns a Physics vortex event, or null
  53730. * A physics vortex event or null
  53731. */
  53732. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53733. }
  53734. /**
  53735. * Represents a physics radial explosion event
  53736. */
  53737. class PhysicsRadialExplosionEvent {
  53738. private _scene;
  53739. private _options;
  53740. private _sphere;
  53741. private _dataFetched;
  53742. /**
  53743. * Initializes a radial explosioin event
  53744. * @param _scene BabylonJS scene
  53745. * @param _options The options for the vortex event
  53746. */
  53747. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53748. /**
  53749. * Returns the data related to the radial explosion event (sphere).
  53750. * @returns The radial explosion event data
  53751. */
  53752. getData(): PhysicsRadialExplosionEventData;
  53753. /**
  53754. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53755. * @param impostor A physics imposter
  53756. * @param origin the origin of the explosion
  53757. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53758. */
  53759. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53760. /**
  53761. * Triggers affecterd impostors callbacks
  53762. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53763. */
  53764. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53765. /**
  53766. * Disposes the sphere.
  53767. * @param force Specifies if the sphere should be disposed by force
  53768. */
  53769. dispose(force?: boolean): void;
  53770. /*** Helpers ***/
  53771. private _prepareSphere;
  53772. private _intersectsWithSphere;
  53773. }
  53774. /**
  53775. * Represents a gravitational field event
  53776. */
  53777. class PhysicsGravitationalFieldEvent {
  53778. private _physicsHelper;
  53779. private _scene;
  53780. private _origin;
  53781. private _options;
  53782. private _tickCallback;
  53783. private _sphere;
  53784. private _dataFetched;
  53785. /**
  53786. * Initializes the physics gravitational field event
  53787. * @param _physicsHelper A physics helper
  53788. * @param _scene BabylonJS scene
  53789. * @param _origin The origin position of the gravitational field event
  53790. * @param _options The options for the vortex event
  53791. */
  53792. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53793. /**
  53794. * Returns the data related to the gravitational field event (sphere).
  53795. * @returns A gravitational field event
  53796. */
  53797. getData(): PhysicsGravitationalFieldEventData;
  53798. /**
  53799. * Enables the gravitational field.
  53800. */
  53801. enable(): void;
  53802. /**
  53803. * Disables the gravitational field.
  53804. */
  53805. disable(): void;
  53806. /**
  53807. * Disposes the sphere.
  53808. * @param force The force to dispose from the gravitational field event
  53809. */
  53810. dispose(force?: boolean): void;
  53811. private _tick;
  53812. }
  53813. /**
  53814. * Represents a physics updraft event
  53815. */
  53816. class PhysicsUpdraftEvent {
  53817. private _scene;
  53818. private _origin;
  53819. private _options;
  53820. private _physicsEngine;
  53821. private _originTop;
  53822. private _originDirection;
  53823. private _tickCallback;
  53824. private _cylinder;
  53825. private _cylinderPosition;
  53826. private _dataFetched;
  53827. /**
  53828. * Initializes the physics updraft event
  53829. * @param _scene BabylonJS scene
  53830. * @param _origin The origin position of the updraft
  53831. * @param _options The options for the updraft event
  53832. */
  53833. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53834. /**
  53835. * Returns the data related to the updraft event (cylinder).
  53836. * @returns A physics updraft event
  53837. */
  53838. getData(): PhysicsUpdraftEventData;
  53839. /**
  53840. * Enables the updraft.
  53841. */
  53842. enable(): void;
  53843. /**
  53844. * Disables the updraft.
  53845. */
  53846. disable(): void;
  53847. /**
  53848. * Disposes the cylinder.
  53849. * @param force Specifies if the updraft should be disposed by force
  53850. */
  53851. dispose(force?: boolean): void;
  53852. private getImpostorHitData;
  53853. private _tick;
  53854. /*** Helpers ***/
  53855. private _prepareCylinder;
  53856. private _intersectsWithCylinder;
  53857. }
  53858. /**
  53859. * Represents a physics vortex event
  53860. */
  53861. class PhysicsVortexEvent {
  53862. private _scene;
  53863. private _origin;
  53864. private _options;
  53865. private _physicsEngine;
  53866. private _originTop;
  53867. private _tickCallback;
  53868. private _cylinder;
  53869. private _cylinderPosition;
  53870. private _dataFetched;
  53871. /**
  53872. * Initializes the physics vortex event
  53873. * @param _scene The BabylonJS scene
  53874. * @param _origin The origin position of the vortex
  53875. * @param _options The options for the vortex event
  53876. */
  53877. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53878. /**
  53879. * Returns the data related to the vortex event (cylinder).
  53880. * @returns The physics vortex event data
  53881. */
  53882. getData(): PhysicsVortexEventData;
  53883. /**
  53884. * Enables the vortex.
  53885. */
  53886. enable(): void;
  53887. /**
  53888. * Disables the cortex.
  53889. */
  53890. disable(): void;
  53891. /**
  53892. * Disposes the sphere.
  53893. * @param force
  53894. */
  53895. dispose(force?: boolean): void;
  53896. private getImpostorHitData;
  53897. private _tick;
  53898. /*** Helpers ***/
  53899. private _prepareCylinder;
  53900. private _intersectsWithCylinder;
  53901. }
  53902. /**
  53903. * Options fot the radial explosion event
  53904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53905. */
  53906. export class PhysicsRadialExplosionEventOptions {
  53907. /**
  53908. * The radius of the sphere for the radial explosion.
  53909. */
  53910. radius: number;
  53911. /**
  53912. * The strenth of the explosion.
  53913. */
  53914. strength: number;
  53915. /**
  53916. * The strenght of the force in correspondence to the distance of the affected object
  53917. */
  53918. falloff: PhysicsRadialImpulseFalloff;
  53919. /**
  53920. * Sphere options for the radial explosion.
  53921. */
  53922. sphere: {
  53923. segments: number;
  53924. diameter: number;
  53925. };
  53926. /**
  53927. * Sphere options for the radial explosion.
  53928. */
  53929. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53930. }
  53931. /**
  53932. * Options fot the updraft event
  53933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53934. */
  53935. export class PhysicsUpdraftEventOptions {
  53936. /**
  53937. * The radius of the cylinder for the vortex
  53938. */
  53939. radius: number;
  53940. /**
  53941. * The strenth of the updraft.
  53942. */
  53943. strength: number;
  53944. /**
  53945. * The height of the cylinder for the updraft.
  53946. */
  53947. height: number;
  53948. /**
  53949. * The mode for the the updraft.
  53950. */
  53951. updraftMode: PhysicsUpdraftMode;
  53952. }
  53953. /**
  53954. * Options fot the vortex event
  53955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53956. */
  53957. export class PhysicsVortexEventOptions {
  53958. /**
  53959. * The radius of the cylinder for the vortex
  53960. */
  53961. radius: number;
  53962. /**
  53963. * The strenth of the vortex.
  53964. */
  53965. strength: number;
  53966. /**
  53967. * The height of the cylinder for the vortex.
  53968. */
  53969. height: number;
  53970. /**
  53971. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53972. */
  53973. centripetalForceThreshold: number;
  53974. /**
  53975. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53976. */
  53977. centripetalForceMultiplier: number;
  53978. /**
  53979. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53980. */
  53981. centrifugalForceMultiplier: number;
  53982. /**
  53983. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53984. */
  53985. updraftForceMultiplier: number;
  53986. }
  53987. /**
  53988. * The strenght of the force in correspondence to the distance of the affected object
  53989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53990. */
  53991. export enum PhysicsRadialImpulseFalloff {
  53992. /** Defines that impulse is constant in strength across it's whole radius */
  53993. Constant = 0,
  53994. /** Defines that impulse gets weaker if it's further from the origin */
  53995. Linear = 1
  53996. }
  53997. /**
  53998. * The strength of the force in correspondence to the distance of the affected object
  53999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54000. */
  54001. export enum PhysicsUpdraftMode {
  54002. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54003. Center = 0,
  54004. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54005. Perpendicular = 1
  54006. }
  54007. /**
  54008. * Interface for a physics hit data
  54009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54010. */
  54011. export interface PhysicsHitData {
  54012. /**
  54013. * The force applied at the contact point
  54014. */
  54015. force: Vector3;
  54016. /**
  54017. * The contact point
  54018. */
  54019. contactPoint: Vector3;
  54020. /**
  54021. * The distance from the origin to the contact point
  54022. */
  54023. distanceFromOrigin: number;
  54024. }
  54025. /**
  54026. * Interface for radial explosion event data
  54027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54028. */
  54029. export interface PhysicsRadialExplosionEventData {
  54030. /**
  54031. * A sphere used for the radial explosion event
  54032. */
  54033. sphere: Mesh;
  54034. }
  54035. /**
  54036. * Interface for gravitational field event data
  54037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54038. */
  54039. export interface PhysicsGravitationalFieldEventData {
  54040. /**
  54041. * A sphere mesh used for the gravitational field event
  54042. */
  54043. sphere: Mesh;
  54044. }
  54045. /**
  54046. * Interface for updraft event data
  54047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54048. */
  54049. export interface PhysicsUpdraftEventData {
  54050. /**
  54051. * A cylinder used for the updraft event
  54052. */
  54053. cylinder: Mesh;
  54054. }
  54055. /**
  54056. * Interface for vortex event data
  54057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54058. */
  54059. export interface PhysicsVortexEventData {
  54060. /**
  54061. * A cylinder used for the vortex event
  54062. */
  54063. cylinder: Mesh;
  54064. }
  54065. /**
  54066. * Interface for an affected physics impostor
  54067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54068. */
  54069. export interface PhysicsAffectedImpostorWithData {
  54070. /**
  54071. * The impostor affected by the effect
  54072. */
  54073. impostor: PhysicsImpostor;
  54074. /**
  54075. * The data about the hit/horce from the explosion
  54076. */
  54077. hitData: PhysicsHitData;
  54078. }
  54079. }
  54080. declare module "babylonjs/Physics/Plugins/index" {
  54081. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54082. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54083. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54084. }
  54085. declare module "babylonjs/Physics/index" {
  54086. export * from "babylonjs/Physics/IPhysicsEngine";
  54087. export * from "babylonjs/Physics/physicsEngine";
  54088. export * from "babylonjs/Physics/physicsEngineComponent";
  54089. export * from "babylonjs/Physics/physicsHelper";
  54090. export * from "babylonjs/Physics/physicsImpostor";
  54091. export * from "babylonjs/Physics/physicsJoint";
  54092. export * from "babylonjs/Physics/Plugins/index";
  54093. }
  54094. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54095. /** @hidden */
  54096. export var blackAndWhitePixelShader: {
  54097. name: string;
  54098. shader: string;
  54099. };
  54100. }
  54101. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54102. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54103. import { Camera } from "babylonjs/Cameras/camera";
  54104. import { Engine } from "babylonjs/Engines/engine";
  54105. import "babylonjs/Shaders/blackAndWhite.fragment";
  54106. /**
  54107. * Post process used to render in black and white
  54108. */
  54109. export class BlackAndWhitePostProcess extends PostProcess {
  54110. /**
  54111. * Linear about to convert he result to black and white (default: 1)
  54112. */
  54113. degree: number;
  54114. /**
  54115. * Creates a black and white post process
  54116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54117. * @param name The name of the effect.
  54118. * @param options The required width/height ratio to downsize to before computing the render pass.
  54119. * @param camera The camera to apply the render pass to.
  54120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54121. * @param engine The engine which the post process will be applied. (default: current engine)
  54122. * @param reusable If the post process can be reused on the same frame. (default: false)
  54123. */
  54124. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54125. }
  54126. }
  54127. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54128. import { Nullable } from "babylonjs/types";
  54129. import { Camera } from "babylonjs/Cameras/camera";
  54130. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54131. import { Engine } from "babylonjs/Engines/engine";
  54132. /**
  54133. * This represents a set of one or more post processes in Babylon.
  54134. * A post process can be used to apply a shader to a texture after it is rendered.
  54135. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54136. */
  54137. export class PostProcessRenderEffect {
  54138. private _postProcesses;
  54139. private _getPostProcesses;
  54140. private _singleInstance;
  54141. private _cameras;
  54142. private _indicesForCamera;
  54143. /**
  54144. * Name of the effect
  54145. * @hidden
  54146. */
  54147. _name: string;
  54148. /**
  54149. * Instantiates a post process render effect.
  54150. * A post process can be used to apply a shader to a texture after it is rendered.
  54151. * @param engine The engine the effect is tied to
  54152. * @param name The name of the effect
  54153. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54154. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54155. */
  54156. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54157. /**
  54158. * Checks if all the post processes in the effect are supported.
  54159. */
  54160. readonly isSupported: boolean;
  54161. /**
  54162. * Updates the current state of the effect
  54163. * @hidden
  54164. */
  54165. _update(): void;
  54166. /**
  54167. * Attaches the effect on cameras
  54168. * @param cameras The camera to attach to.
  54169. * @hidden
  54170. */
  54171. _attachCameras(cameras: Camera): void;
  54172. /**
  54173. * Attaches the effect on cameras
  54174. * @param cameras The camera to attach to.
  54175. * @hidden
  54176. */
  54177. _attachCameras(cameras: Camera[]): void;
  54178. /**
  54179. * Detatches the effect on cameras
  54180. * @param cameras The camera to detatch from.
  54181. * @hidden
  54182. */
  54183. _detachCameras(cameras: Camera): void;
  54184. /**
  54185. * Detatches the effect on cameras
  54186. * @param cameras The camera to detatch from.
  54187. * @hidden
  54188. */
  54189. _detachCameras(cameras: Camera[]): void;
  54190. /**
  54191. * Enables the effect on given cameras
  54192. * @param cameras The camera to enable.
  54193. * @hidden
  54194. */
  54195. _enable(cameras: Camera): void;
  54196. /**
  54197. * Enables the effect on given cameras
  54198. * @param cameras The camera to enable.
  54199. * @hidden
  54200. */
  54201. _enable(cameras: Nullable<Camera[]>): void;
  54202. /**
  54203. * Disables the effect on the given cameras
  54204. * @param cameras The camera to disable.
  54205. * @hidden
  54206. */
  54207. _disable(cameras: Camera): void;
  54208. /**
  54209. * Disables the effect on the given cameras
  54210. * @param cameras The camera to disable.
  54211. * @hidden
  54212. */
  54213. _disable(cameras: Nullable<Camera[]>): void;
  54214. /**
  54215. * Gets a list of the post processes contained in the effect.
  54216. * @param camera The camera to get the post processes on.
  54217. * @returns The list of the post processes in the effect.
  54218. */
  54219. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54220. }
  54221. }
  54222. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54224. /** @hidden */
  54225. export var extractHighlightsPixelShader: {
  54226. name: string;
  54227. shader: string;
  54228. };
  54229. }
  54230. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54231. import { Nullable } from "babylonjs/types";
  54232. import { Camera } from "babylonjs/Cameras/camera";
  54233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54234. import { Engine } from "babylonjs/Engines/engine";
  54235. import "babylonjs/Shaders/extractHighlights.fragment";
  54236. /**
  54237. * 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.
  54238. */
  54239. export class ExtractHighlightsPostProcess extends PostProcess {
  54240. /**
  54241. * The luminance threshold, pixels below this value will be set to black.
  54242. */
  54243. threshold: number;
  54244. /** @hidden */
  54245. _exposure: number;
  54246. /**
  54247. * Post process which has the input texture to be used when performing highlight extraction
  54248. * @hidden
  54249. */
  54250. _inputPostProcess: Nullable<PostProcess>;
  54251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54252. }
  54253. }
  54254. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54255. /** @hidden */
  54256. export var bloomMergePixelShader: {
  54257. name: string;
  54258. shader: string;
  54259. };
  54260. }
  54261. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54263. import { Nullable } from "babylonjs/types";
  54264. import { Engine } from "babylonjs/Engines/engine";
  54265. import { Camera } from "babylonjs/Cameras/camera";
  54266. import "babylonjs/Shaders/bloomMerge.fragment";
  54267. /**
  54268. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54269. */
  54270. export class BloomMergePostProcess extends PostProcess {
  54271. /** Weight of the bloom to be added to the original input. */
  54272. weight: number;
  54273. /**
  54274. * Creates a new instance of @see BloomMergePostProcess
  54275. * @param name The name of the effect.
  54276. * @param originalFromInput Post process which's input will be used for the merge.
  54277. * @param blurred Blurred highlights post process which's output will be used.
  54278. * @param weight Weight of the bloom to be added to the original input.
  54279. * @param options The required width/height ratio to downsize to before computing the render pass.
  54280. * @param camera The camera to apply the render pass to.
  54281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54282. * @param engine The engine which the post process will be applied. (default: current engine)
  54283. * @param reusable If the post process can be reused on the same frame. (default: false)
  54284. * @param textureType Type of textures used when performing the post process. (default: 0)
  54285. * @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)
  54286. */
  54287. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54288. /** Weight of the bloom to be added to the original input. */
  54289. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54290. }
  54291. }
  54292. declare module "babylonjs/PostProcesses/bloomEffect" {
  54293. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54294. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54295. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54296. import { Camera } from "babylonjs/Cameras/camera";
  54297. import { Scene } from "babylonjs/scene";
  54298. /**
  54299. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54300. */
  54301. export class BloomEffect extends PostProcessRenderEffect {
  54302. private bloomScale;
  54303. /**
  54304. * @hidden Internal
  54305. */
  54306. _effects: Array<PostProcess>;
  54307. /**
  54308. * @hidden Internal
  54309. */
  54310. _downscale: ExtractHighlightsPostProcess;
  54311. private _blurX;
  54312. private _blurY;
  54313. private _merge;
  54314. /**
  54315. * The luminance threshold to find bright areas of the image to bloom.
  54316. */
  54317. threshold: number;
  54318. /**
  54319. * The strength of the bloom.
  54320. */
  54321. weight: number;
  54322. /**
  54323. * Specifies the size of the bloom blur kernel, relative to the final output size
  54324. */
  54325. kernel: number;
  54326. /**
  54327. * Creates a new instance of @see BloomEffect
  54328. * @param scene The scene the effect belongs to.
  54329. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54330. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54331. * @param bloomWeight The the strength of bloom.
  54332. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54333. * @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)
  54334. */
  54335. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54336. /**
  54337. * Disposes each of the internal effects for a given camera.
  54338. * @param camera The camera to dispose the effect on.
  54339. */
  54340. disposeEffects(camera: Camera): void;
  54341. /**
  54342. * @hidden Internal
  54343. */
  54344. _updateEffects(): void;
  54345. /**
  54346. * Internal
  54347. * @returns if all the contained post processes are ready.
  54348. * @hidden
  54349. */
  54350. _isReady(): boolean;
  54351. }
  54352. }
  54353. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54354. /** @hidden */
  54355. export var chromaticAberrationPixelShader: {
  54356. name: string;
  54357. shader: string;
  54358. };
  54359. }
  54360. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54361. import { Vector2 } from "babylonjs/Maths/math";
  54362. import { Nullable } from "babylonjs/types";
  54363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54364. import { Camera } from "babylonjs/Cameras/camera";
  54365. import { Engine } from "babylonjs/Engines/engine";
  54366. import "babylonjs/Shaders/chromaticAberration.fragment";
  54367. /**
  54368. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54369. */
  54370. export class ChromaticAberrationPostProcess extends PostProcess {
  54371. /**
  54372. * The amount of seperation of rgb channels (default: 30)
  54373. */
  54374. aberrationAmount: number;
  54375. /**
  54376. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54377. */
  54378. radialIntensity: number;
  54379. /**
  54380. * 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))
  54381. */
  54382. direction: Vector2;
  54383. /**
  54384. * 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))
  54385. */
  54386. centerPosition: Vector2;
  54387. /**
  54388. * Creates a new instance ChromaticAberrationPostProcess
  54389. * @param name The name of the effect.
  54390. * @param screenWidth The width of the screen to apply the effect on.
  54391. * @param screenHeight The height of the screen to apply the effect on.
  54392. * @param options The required width/height ratio to downsize to before computing the render pass.
  54393. * @param camera The camera to apply the render pass to.
  54394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54395. * @param engine The engine which the post process will be applied. (default: current engine)
  54396. * @param reusable If the post process can be reused on the same frame. (default: false)
  54397. * @param textureType Type of textures used when performing the post process. (default: 0)
  54398. * @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)
  54399. */
  54400. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54401. }
  54402. }
  54403. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54404. /** @hidden */
  54405. export var circleOfConfusionPixelShader: {
  54406. name: string;
  54407. shader: string;
  54408. };
  54409. }
  54410. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54411. import { Nullable } from "babylonjs/types";
  54412. import { Engine } from "babylonjs/Engines/engine";
  54413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54415. import { Camera } from "babylonjs/Cameras/camera";
  54416. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54417. /**
  54418. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54419. */
  54420. export class CircleOfConfusionPostProcess extends PostProcess {
  54421. /**
  54422. * 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.
  54423. */
  54424. lensSize: number;
  54425. /**
  54426. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54427. */
  54428. fStop: number;
  54429. /**
  54430. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54431. */
  54432. focusDistance: number;
  54433. /**
  54434. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54435. */
  54436. focalLength: number;
  54437. private _depthTexture;
  54438. /**
  54439. * Creates a new instance CircleOfConfusionPostProcess
  54440. * @param name The name of the effect.
  54441. * @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.
  54442. * @param options The required width/height ratio to downsize to before computing the render pass.
  54443. * @param camera The camera to apply the render pass to.
  54444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54445. * @param engine The engine which the post process will be applied. (default: current engine)
  54446. * @param reusable If the post process can be reused on the same frame. (default: false)
  54447. * @param textureType Type of textures used when performing the post process. (default: 0)
  54448. * @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)
  54449. */
  54450. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54451. /**
  54452. * 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.
  54453. */
  54454. depthTexture: RenderTargetTexture;
  54455. }
  54456. }
  54457. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54458. /** @hidden */
  54459. export var colorCorrectionPixelShader: {
  54460. name: string;
  54461. shader: string;
  54462. };
  54463. }
  54464. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54466. import { Engine } from "babylonjs/Engines/engine";
  54467. import { Camera } from "babylonjs/Cameras/camera";
  54468. import "babylonjs/Shaders/colorCorrection.fragment";
  54469. /**
  54470. *
  54471. * This post-process allows the modification of rendered colors by using
  54472. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54473. *
  54474. * The object needs to be provided an url to a texture containing the color
  54475. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54476. * Use an image editing software to tweak the LUT to match your needs.
  54477. *
  54478. * For an example of a color LUT, see here:
  54479. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54480. * For explanations on color grading, see here:
  54481. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54482. *
  54483. */
  54484. export class ColorCorrectionPostProcess extends PostProcess {
  54485. private _colorTableTexture;
  54486. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54487. }
  54488. }
  54489. declare module "babylonjs/Shaders/convolution.fragment" {
  54490. /** @hidden */
  54491. export var convolutionPixelShader: {
  54492. name: string;
  54493. shader: string;
  54494. };
  54495. }
  54496. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54498. import { Nullable } from "babylonjs/types";
  54499. import { Camera } from "babylonjs/Cameras/camera";
  54500. import { Engine } from "babylonjs/Engines/engine";
  54501. import "babylonjs/Shaders/convolution.fragment";
  54502. /**
  54503. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54504. * input texture to perform effects such as edge detection or sharpening
  54505. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54506. */
  54507. export class ConvolutionPostProcess extends PostProcess {
  54508. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54509. kernel: number[];
  54510. /**
  54511. * Creates a new instance ConvolutionPostProcess
  54512. * @param name The name of the effect.
  54513. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54514. * @param options The required width/height ratio to downsize to before computing the render pass.
  54515. * @param camera The camera to apply the render pass to.
  54516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54517. * @param engine The engine which the post process will be applied. (default: current engine)
  54518. * @param reusable If the post process can be reused on the same frame. (default: false)
  54519. * @param textureType Type of textures used when performing the post process. (default: 0)
  54520. */
  54521. constructor(name: string,
  54522. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54523. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54524. /**
  54525. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54526. */
  54527. static EdgeDetect0Kernel: number[];
  54528. /**
  54529. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54530. */
  54531. static EdgeDetect1Kernel: number[];
  54532. /**
  54533. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54534. */
  54535. static EdgeDetect2Kernel: number[];
  54536. /**
  54537. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54538. */
  54539. static SharpenKernel: number[];
  54540. /**
  54541. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54542. */
  54543. static EmbossKernel: number[];
  54544. /**
  54545. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54546. */
  54547. static GaussianKernel: number[];
  54548. }
  54549. }
  54550. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54551. import { Nullable } from "babylonjs/types";
  54552. import { Vector2 } from "babylonjs/Maths/math";
  54553. import { Camera } from "babylonjs/Cameras/camera";
  54554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54555. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54556. import { Engine } from "babylonjs/Engines/engine";
  54557. import { Scene } from "babylonjs/scene";
  54558. /**
  54559. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54560. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54561. * based on samples that have a large difference in distance than the center pixel.
  54562. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54563. */
  54564. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54565. direction: Vector2;
  54566. /**
  54567. * Creates a new instance CircleOfConfusionPostProcess
  54568. * @param name The name of the effect.
  54569. * @param scene The scene the effect belongs to.
  54570. * @param direction The direction the blur should be applied.
  54571. * @param kernel The size of the kernel used to blur.
  54572. * @param options The required width/height ratio to downsize to before computing the render pass.
  54573. * @param camera The camera to apply the render pass to.
  54574. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54575. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54577. * @param engine The engine which the post process will be applied. (default: current engine)
  54578. * @param reusable If the post process can be reused on the same frame. (default: false)
  54579. * @param textureType Type of textures used when performing the post process. (default: 0)
  54580. * @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)
  54581. */
  54582. 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);
  54583. }
  54584. }
  54585. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54586. /** @hidden */
  54587. export var depthOfFieldMergePixelShader: {
  54588. name: string;
  54589. shader: string;
  54590. };
  54591. }
  54592. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54593. import { Nullable } from "babylonjs/types";
  54594. import { Camera } from "babylonjs/Cameras/camera";
  54595. import { Effect } from "babylonjs/Materials/effect";
  54596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54597. import { Engine } from "babylonjs/Engines/engine";
  54598. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54599. /**
  54600. * Options to be set when merging outputs from the default pipeline.
  54601. */
  54602. export class DepthOfFieldMergePostProcessOptions {
  54603. /**
  54604. * The original image to merge on top of
  54605. */
  54606. originalFromInput: PostProcess;
  54607. /**
  54608. * Parameters to perform the merge of the depth of field effect
  54609. */
  54610. depthOfField?: {
  54611. circleOfConfusion: PostProcess;
  54612. blurSteps: Array<PostProcess>;
  54613. };
  54614. /**
  54615. * Parameters to perform the merge of bloom effect
  54616. */
  54617. bloom?: {
  54618. blurred: PostProcess;
  54619. weight: number;
  54620. };
  54621. }
  54622. /**
  54623. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54624. */
  54625. export class DepthOfFieldMergePostProcess extends PostProcess {
  54626. private blurSteps;
  54627. /**
  54628. * Creates a new instance of DepthOfFieldMergePostProcess
  54629. * @param name The name of the effect.
  54630. * @param originalFromInput Post process which's input will be used for the merge.
  54631. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54632. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54633. * @param options The required width/height ratio to downsize to before computing the render pass.
  54634. * @param camera The camera to apply the render pass to.
  54635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54636. * @param engine The engine which the post process will be applied. (default: current engine)
  54637. * @param reusable If the post process can be reused on the same frame. (default: false)
  54638. * @param textureType Type of textures used when performing the post process. (default: 0)
  54639. * @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)
  54640. */
  54641. 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);
  54642. /**
  54643. * Updates the effect with the current post process compile time values and recompiles the shader.
  54644. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54645. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54646. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54647. * @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
  54648. * @param onCompiled Called when the shader has been compiled.
  54649. * @param onError Called if there is an error when compiling a shader.
  54650. */
  54651. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54652. }
  54653. }
  54654. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54655. import { Nullable } from "babylonjs/types";
  54656. import { Camera } from "babylonjs/Cameras/camera";
  54657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54659. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54660. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54661. import { Scene } from "babylonjs/scene";
  54662. /**
  54663. * Specifies the level of max blur that should be applied when using the depth of field effect
  54664. */
  54665. export enum DepthOfFieldEffectBlurLevel {
  54666. /**
  54667. * Subtle blur
  54668. */
  54669. Low = 0,
  54670. /**
  54671. * Medium blur
  54672. */
  54673. Medium = 1,
  54674. /**
  54675. * Large blur
  54676. */
  54677. High = 2
  54678. }
  54679. /**
  54680. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54681. */
  54682. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54683. private _circleOfConfusion;
  54684. /**
  54685. * @hidden Internal, blurs from high to low
  54686. */
  54687. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54688. private _depthOfFieldBlurY;
  54689. private _dofMerge;
  54690. /**
  54691. * @hidden Internal post processes in depth of field effect
  54692. */
  54693. _effects: Array<PostProcess>;
  54694. /**
  54695. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54696. */
  54697. focalLength: number;
  54698. /**
  54699. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54700. */
  54701. fStop: number;
  54702. /**
  54703. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54704. */
  54705. focusDistance: number;
  54706. /**
  54707. * 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.
  54708. */
  54709. lensSize: number;
  54710. /**
  54711. * Creates a new instance DepthOfFieldEffect
  54712. * @param scene The scene the effect belongs to.
  54713. * @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.
  54714. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54715. * @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)
  54716. */
  54717. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54718. /**
  54719. * 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.
  54720. */
  54721. depthTexture: RenderTargetTexture;
  54722. /**
  54723. * Disposes each of the internal effects for a given camera.
  54724. * @param camera The camera to dispose the effect on.
  54725. */
  54726. disposeEffects(camera: Camera): void;
  54727. /**
  54728. * @hidden Internal
  54729. */
  54730. _updateEffects(): void;
  54731. /**
  54732. * Internal
  54733. * @returns if all the contained post processes are ready.
  54734. * @hidden
  54735. */
  54736. _isReady(): boolean;
  54737. }
  54738. }
  54739. declare module "babylonjs/Shaders/displayPass.fragment" {
  54740. /** @hidden */
  54741. export var displayPassPixelShader: {
  54742. name: string;
  54743. shader: string;
  54744. };
  54745. }
  54746. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54747. import { Nullable } from "babylonjs/types";
  54748. import { Camera } from "babylonjs/Cameras/camera";
  54749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54750. import { Engine } from "babylonjs/Engines/engine";
  54751. import "babylonjs/Shaders/displayPass.fragment";
  54752. /**
  54753. * DisplayPassPostProcess which produces an output the same as it's input
  54754. */
  54755. export class DisplayPassPostProcess extends PostProcess {
  54756. /**
  54757. * Creates the DisplayPassPostProcess
  54758. * @param name The name of the effect.
  54759. * @param options The required width/height ratio to downsize to before computing the render pass.
  54760. * @param camera The camera to apply the render pass to.
  54761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54762. * @param engine The engine which the post process will be applied. (default: current engine)
  54763. * @param reusable If the post process can be reused on the same frame. (default: false)
  54764. */
  54765. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54766. }
  54767. }
  54768. declare module "babylonjs/Shaders/filter.fragment" {
  54769. /** @hidden */
  54770. export var filterPixelShader: {
  54771. name: string;
  54772. shader: string;
  54773. };
  54774. }
  54775. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54776. import { Nullable } from "babylonjs/types";
  54777. import { Matrix } from "babylonjs/Maths/math";
  54778. import { Camera } from "babylonjs/Cameras/camera";
  54779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54780. import { Engine } from "babylonjs/Engines/engine";
  54781. import "babylonjs/Shaders/filter.fragment";
  54782. /**
  54783. * Applies a kernel filter to the image
  54784. */
  54785. export class FilterPostProcess extends PostProcess {
  54786. /** The matrix to be applied to the image */
  54787. kernelMatrix: Matrix;
  54788. /**
  54789. *
  54790. * @param name The name of the effect.
  54791. * @param kernelMatrix The matrix to be applied to the image
  54792. * @param options The required width/height ratio to downsize to before computing the render pass.
  54793. * @param camera The camera to apply the render pass to.
  54794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54795. * @param engine The engine which the post process will be applied. (default: current engine)
  54796. * @param reusable If the post process can be reused on the same frame. (default: false)
  54797. */
  54798. constructor(name: string,
  54799. /** The matrix to be applied to the image */
  54800. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54801. }
  54802. }
  54803. declare module "babylonjs/Shaders/fxaa.fragment" {
  54804. /** @hidden */
  54805. export var fxaaPixelShader: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module "babylonjs/Shaders/fxaa.vertex" {
  54811. /** @hidden */
  54812. export var fxaaVertexShader: {
  54813. name: string;
  54814. shader: string;
  54815. };
  54816. }
  54817. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54818. import { Nullable } from "babylonjs/types";
  54819. import { Camera } from "babylonjs/Cameras/camera";
  54820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54821. import { Engine } from "babylonjs/Engines/engine";
  54822. import "babylonjs/Shaders/fxaa.fragment";
  54823. import "babylonjs/Shaders/fxaa.vertex";
  54824. /**
  54825. * Fxaa post process
  54826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54827. */
  54828. export class FxaaPostProcess extends PostProcess {
  54829. /** @hidden */
  54830. texelWidth: number;
  54831. /** @hidden */
  54832. texelHeight: number;
  54833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54834. private _getDefines;
  54835. }
  54836. }
  54837. declare module "babylonjs/Shaders/grain.fragment" {
  54838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54839. /** @hidden */
  54840. export var grainPixelShader: {
  54841. name: string;
  54842. shader: string;
  54843. };
  54844. }
  54845. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54846. import { Nullable } from "babylonjs/types";
  54847. import { Camera } from "babylonjs/Cameras/camera";
  54848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54849. import { Engine } from "babylonjs/Engines/engine";
  54850. import "babylonjs/Shaders/grain.fragment";
  54851. /**
  54852. * The GrainPostProcess adds noise to the image at mid luminance levels
  54853. */
  54854. export class GrainPostProcess extends PostProcess {
  54855. /**
  54856. * The intensity of the grain added (default: 30)
  54857. */
  54858. intensity: number;
  54859. /**
  54860. * If the grain should be randomized on every frame
  54861. */
  54862. animated: boolean;
  54863. /**
  54864. * Creates a new instance of @see GrainPostProcess
  54865. * @param name The name of the effect.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  54872. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  54873. */
  54874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54875. }
  54876. }
  54877. declare module "babylonjs/Shaders/highlights.fragment" {
  54878. /** @hidden */
  54879. export var highlightsPixelShader: {
  54880. name: string;
  54881. shader: string;
  54882. };
  54883. }
  54884. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54885. import { Nullable } from "babylonjs/types";
  54886. import { Camera } from "babylonjs/Cameras/camera";
  54887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54888. import { Engine } from "babylonjs/Engines/engine";
  54889. import "babylonjs/Shaders/highlights.fragment";
  54890. /**
  54891. * Extracts highlights from the image
  54892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54893. */
  54894. export class HighlightsPostProcess extends PostProcess {
  54895. /**
  54896. * Extracts highlights from the image
  54897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54898. * @param name The name of the effect.
  54899. * @param options The required width/height ratio to downsize to before computing the render pass.
  54900. * @param camera The camera to apply the render pass to.
  54901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54902. * @param engine The engine which the post process will be applied. (default: current engine)
  54903. * @param reusable If the post process can be reused on the same frame. (default: false)
  54904. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54905. */
  54906. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54907. }
  54908. }
  54909. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54910. /** @hidden */
  54911. export var mrtFragmentDeclaration: {
  54912. name: string;
  54913. shader: string;
  54914. };
  54915. }
  54916. declare module "babylonjs/Shaders/geometry.fragment" {
  54917. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54918. /** @hidden */
  54919. export var geometryPixelShader: {
  54920. name: string;
  54921. shader: string;
  54922. };
  54923. }
  54924. declare module "babylonjs/Shaders/geometry.vertex" {
  54925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54926. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54927. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54928. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54929. /** @hidden */
  54930. export var geometryVertexShader: {
  54931. name: string;
  54932. shader: string;
  54933. };
  54934. }
  54935. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54936. import { Matrix } from "babylonjs/Maths/math";
  54937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54938. import { Mesh } from "babylonjs/Meshes/mesh";
  54939. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54940. import { Effect } from "babylonjs/Materials/effect";
  54941. import { Scene } from "babylonjs/scene";
  54942. import "babylonjs/Shaders/geometry.fragment";
  54943. import "babylonjs/Shaders/geometry.vertex";
  54944. /**
  54945. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54946. */
  54947. export class GeometryBufferRenderer {
  54948. /**
  54949. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54950. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54951. */
  54952. static readonly POSITION_TEXTURE_TYPE: number;
  54953. /**
  54954. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54955. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54956. */
  54957. static readonly VELOCITY_TEXTURE_TYPE: number;
  54958. /**
  54959. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54960. * in order to compute objects velocities when enableVelocity is set to "true"
  54961. * @hidden
  54962. */
  54963. _previousTransformationMatrices: {
  54964. [index: number]: Matrix;
  54965. };
  54966. private _scene;
  54967. private _multiRenderTarget;
  54968. private _ratio;
  54969. private _enablePosition;
  54970. private _enableVelocity;
  54971. private _positionIndex;
  54972. private _velocityIndex;
  54973. protected _effect: Effect;
  54974. protected _cachedDefines: string;
  54975. /**
  54976. * Set the render list (meshes to be rendered) used in the G buffer.
  54977. */
  54978. renderList: Mesh[];
  54979. /**
  54980. * Gets wether or not G buffer are supported by the running hardware.
  54981. * This requires draw buffer supports
  54982. */
  54983. readonly isSupported: boolean;
  54984. /**
  54985. * Returns the index of the given texture type in the G-Buffer textures array
  54986. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54987. * @returns the index of the given texture type in the G-Buffer textures array
  54988. */
  54989. getTextureIndex(textureType: number): number;
  54990. /**
  54991. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54992. */
  54993. /**
  54994. * Sets whether or not objects positions are enabled for the G buffer.
  54995. */
  54996. enablePosition: boolean;
  54997. /**
  54998. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54999. */
  55000. /**
  55001. * Sets wether or not objects velocities are enabled for the G buffer.
  55002. */
  55003. enableVelocity: boolean;
  55004. /**
  55005. * Gets the scene associated with the buffer.
  55006. */
  55007. readonly scene: Scene;
  55008. /**
  55009. * Gets the ratio used by the buffer during its creation.
  55010. * How big is the buffer related to the main canvas.
  55011. */
  55012. readonly ratio: number;
  55013. /** @hidden */
  55014. static _SceneComponentInitialization: (scene: Scene) => void;
  55015. /**
  55016. * Creates a new G Buffer for the scene
  55017. * @param scene The scene the buffer belongs to
  55018. * @param ratio How big is the buffer related to the main canvas.
  55019. */
  55020. constructor(scene: Scene, ratio?: number);
  55021. /**
  55022. * Checks wether everything is ready to render a submesh to the G buffer.
  55023. * @param subMesh the submesh to check readiness for
  55024. * @param useInstances is the mesh drawn using instance or not
  55025. * @returns true if ready otherwise false
  55026. */
  55027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55028. /**
  55029. * Gets the current underlying G Buffer.
  55030. * @returns the buffer
  55031. */
  55032. getGBuffer(): MultiRenderTarget;
  55033. /**
  55034. * Gets the number of samples used to render the buffer (anti aliasing).
  55035. */
  55036. /**
  55037. * Sets the number of samples used to render the buffer (anti aliasing).
  55038. */
  55039. samples: number;
  55040. /**
  55041. * Disposes the renderer and frees up associated resources.
  55042. */
  55043. dispose(): void;
  55044. protected _createRenderTargets(): void;
  55045. }
  55046. }
  55047. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55048. import { Nullable } from "babylonjs/types";
  55049. import { Scene } from "babylonjs/scene";
  55050. import { ISceneComponent } from "babylonjs/sceneComponent";
  55051. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55052. module "babylonjs/scene" {
  55053. interface Scene {
  55054. /** @hidden (Backing field) */
  55055. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55056. /**
  55057. * Gets or Sets the current geometry buffer associated to the scene.
  55058. */
  55059. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55060. /**
  55061. * Enables a GeometryBufferRender and associates it with the scene
  55062. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55063. * @returns the GeometryBufferRenderer
  55064. */
  55065. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55066. /**
  55067. * Disables the GeometryBufferRender associated with the scene
  55068. */
  55069. disableGeometryBufferRenderer(): void;
  55070. }
  55071. }
  55072. /**
  55073. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55074. * in several rendering techniques.
  55075. */
  55076. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55077. /**
  55078. * The component name helpful to identify the component in the list of scene components.
  55079. */
  55080. readonly name: string;
  55081. /**
  55082. * The scene the component belongs to.
  55083. */
  55084. scene: Scene;
  55085. /**
  55086. * Creates a new instance of the component for the given scene
  55087. * @param scene Defines the scene to register the component in
  55088. */
  55089. constructor(scene: Scene);
  55090. /**
  55091. * Registers the component in a given scene
  55092. */
  55093. register(): void;
  55094. /**
  55095. * Rebuilds the elements related to this component in case of
  55096. * context lost for instance.
  55097. */
  55098. rebuild(): void;
  55099. /**
  55100. * Disposes the component and the associated ressources
  55101. */
  55102. dispose(): void;
  55103. private _gatherRenderTargets;
  55104. }
  55105. }
  55106. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55107. /** @hidden */
  55108. export var motionBlurPixelShader: {
  55109. name: string;
  55110. shader: string;
  55111. };
  55112. }
  55113. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55114. import { Nullable } from "babylonjs/types";
  55115. import { Camera } from "babylonjs/Cameras/camera";
  55116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55117. import { Scene } from "babylonjs/scene";
  55118. import "babylonjs/Animations/animatable";
  55119. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55120. import "babylonjs/Shaders/motionBlur.fragment";
  55121. import { Engine } from "babylonjs/Engines/engine";
  55122. /**
  55123. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55124. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55125. * As an example, all you have to do is to create the post-process:
  55126. * var mb = new BABYLON.MotionBlurPostProcess(
  55127. * 'mb', // The name of the effect.
  55128. * scene, // The scene containing the objects to blur according to their velocity.
  55129. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55130. * camera // The camera to apply the render pass to.
  55131. * );
  55132. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55133. */
  55134. export class MotionBlurPostProcess extends PostProcess {
  55135. /**
  55136. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55137. */
  55138. motionStrength: number;
  55139. /**
  55140. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55141. */
  55142. /**
  55143. * Sets the number of iterations to be used for motion blur quality
  55144. */
  55145. motionBlurSamples: number;
  55146. private _motionBlurSamples;
  55147. private _geometryBufferRenderer;
  55148. /**
  55149. * Creates a new instance MotionBlurPostProcess
  55150. * @param name The name of the effect.
  55151. * @param scene The scene containing the objects to blur according to their velocity.
  55152. * @param options The required width/height ratio to downsize to before computing the render pass.
  55153. * @param camera The camera to apply the render pass to.
  55154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55155. * @param engine The engine which the post process will be applied. (default: current engine)
  55156. * @param reusable If the post process can be reused on the same frame. (default: false)
  55157. * @param textureType Type of textures used when performing the post process. (default: 0)
  55158. * @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)
  55159. */
  55160. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55161. /**
  55162. * Disposes the post process.
  55163. * @param camera The camera to dispose the post process on.
  55164. */
  55165. dispose(camera?: Camera): void;
  55166. }
  55167. }
  55168. declare module "babylonjs/Shaders/refraction.fragment" {
  55169. /** @hidden */
  55170. export var refractionPixelShader: {
  55171. name: string;
  55172. shader: string;
  55173. };
  55174. }
  55175. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55176. import { Color3 } from "babylonjs/Maths/math";
  55177. import { Camera } from "babylonjs/Cameras/camera";
  55178. import { Texture } from "babylonjs/Materials/Textures/texture";
  55179. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55180. import { Engine } from "babylonjs/Engines/engine";
  55181. import "babylonjs/Shaders/refraction.fragment";
  55182. /**
  55183. * Post process which applies a refractin texture
  55184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55185. */
  55186. export class RefractionPostProcess extends PostProcess {
  55187. /** the base color of the refraction (used to taint the rendering) */
  55188. color: Color3;
  55189. /** simulated refraction depth */
  55190. depth: number;
  55191. /** the coefficient of the base color (0 to remove base color tainting) */
  55192. colorLevel: number;
  55193. private _refTexture;
  55194. private _ownRefractionTexture;
  55195. /**
  55196. * Gets or sets the refraction texture
  55197. * Please note that you are responsible for disposing the texture if you set it manually
  55198. */
  55199. refractionTexture: Texture;
  55200. /**
  55201. * Initializes the RefractionPostProcess
  55202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55203. * @param name The name of the effect.
  55204. * @param refractionTextureUrl Url of the refraction texture to use
  55205. * @param color the base color of the refraction (used to taint the rendering)
  55206. * @param depth simulated refraction depth
  55207. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55208. * @param camera The camera to apply the render pass to.
  55209. * @param options The required width/height ratio to downsize to before computing the render pass.
  55210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55211. * @param engine The engine which the post process will be applied. (default: current engine)
  55212. * @param reusable If the post process can be reused on the same frame. (default: false)
  55213. */
  55214. constructor(name: string, refractionTextureUrl: string,
  55215. /** the base color of the refraction (used to taint the rendering) */
  55216. color: Color3,
  55217. /** simulated refraction depth */
  55218. depth: number,
  55219. /** the coefficient of the base color (0 to remove base color tainting) */
  55220. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55221. /**
  55222. * Disposes of the post process
  55223. * @param camera Camera to dispose post process on
  55224. */
  55225. dispose(camera: Camera): void;
  55226. }
  55227. }
  55228. declare module "babylonjs/Shaders/sharpen.fragment" {
  55229. /** @hidden */
  55230. export var sharpenPixelShader: {
  55231. name: string;
  55232. shader: string;
  55233. };
  55234. }
  55235. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55236. import { Nullable } from "babylonjs/types";
  55237. import { Camera } from "babylonjs/Cameras/camera";
  55238. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55239. import "babylonjs/Shaders/sharpen.fragment";
  55240. import { Engine } from "babylonjs/Engines/engine";
  55241. /**
  55242. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55243. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55244. */
  55245. export class SharpenPostProcess extends PostProcess {
  55246. /**
  55247. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55248. */
  55249. colorAmount: number;
  55250. /**
  55251. * How much sharpness should be applied (default: 0.3)
  55252. */
  55253. edgeAmount: number;
  55254. /**
  55255. * Creates a new instance ConvolutionPostProcess
  55256. * @param name The name of the effect.
  55257. * @param options The required width/height ratio to downsize to before computing the render pass.
  55258. * @param camera The camera to apply the render pass to.
  55259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55260. * @param engine The engine which the post process will be applied. (default: current engine)
  55261. * @param reusable If the post process can be reused on the same frame. (default: false)
  55262. * @param textureType Type of textures used when performing the post process. (default: 0)
  55263. * @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)
  55264. */
  55265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55266. }
  55267. }
  55268. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55269. import { Nullable } from "babylonjs/types";
  55270. import { Camera } from "babylonjs/Cameras/camera";
  55271. import { Engine } from "babylonjs/Engines/engine";
  55272. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55273. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55274. /**
  55275. * PostProcessRenderPipeline
  55276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55277. */
  55278. export class PostProcessRenderPipeline {
  55279. private engine;
  55280. private _renderEffects;
  55281. private _renderEffectsForIsolatedPass;
  55282. /**
  55283. * List of inspectable custom properties (used by the Inspector)
  55284. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55285. */
  55286. inspectableCustomProperties: IInspectable[];
  55287. /**
  55288. * @hidden
  55289. */
  55290. protected _cameras: Camera[];
  55291. /** @hidden */
  55292. _name: string;
  55293. /**
  55294. * Gets pipeline name
  55295. */
  55296. readonly name: string;
  55297. /**
  55298. * Initializes a PostProcessRenderPipeline
  55299. * @param engine engine to add the pipeline to
  55300. * @param name name of the pipeline
  55301. */
  55302. constructor(engine: Engine, name: string);
  55303. /**
  55304. * Gets the class name
  55305. * @returns "PostProcessRenderPipeline"
  55306. */
  55307. getClassName(): string;
  55308. /**
  55309. * If all the render effects in the pipeline are supported
  55310. */
  55311. readonly isSupported: boolean;
  55312. /**
  55313. * Adds an effect to the pipeline
  55314. * @param renderEffect the effect to add
  55315. */
  55316. addEffect(renderEffect: PostProcessRenderEffect): void;
  55317. /** @hidden */
  55318. _rebuild(): void;
  55319. /** @hidden */
  55320. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55321. /** @hidden */
  55322. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55323. /** @hidden */
  55324. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55325. /** @hidden */
  55326. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55327. /** @hidden */
  55328. _attachCameras(cameras: Camera, unique: boolean): void;
  55329. /** @hidden */
  55330. _attachCameras(cameras: Camera[], unique: boolean): void;
  55331. /** @hidden */
  55332. _detachCameras(cameras: Camera): void;
  55333. /** @hidden */
  55334. _detachCameras(cameras: Nullable<Camera[]>): void;
  55335. /** @hidden */
  55336. _update(): void;
  55337. /** @hidden */
  55338. _reset(): void;
  55339. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55340. /**
  55341. * Disposes of the pipeline
  55342. */
  55343. dispose(): void;
  55344. }
  55345. }
  55346. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55347. import { Camera } from "babylonjs/Cameras/camera";
  55348. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55349. /**
  55350. * PostProcessRenderPipelineManager class
  55351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55352. */
  55353. export class PostProcessRenderPipelineManager {
  55354. private _renderPipelines;
  55355. /**
  55356. * Initializes a PostProcessRenderPipelineManager
  55357. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55358. */
  55359. constructor();
  55360. /**
  55361. * Gets the list of supported render pipelines
  55362. */
  55363. readonly supportedPipelines: PostProcessRenderPipeline[];
  55364. /**
  55365. * Adds a pipeline to the manager
  55366. * @param renderPipeline The pipeline to add
  55367. */
  55368. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55369. /**
  55370. * Attaches a camera to the pipeline
  55371. * @param renderPipelineName The name of the pipeline to attach to
  55372. * @param cameras the camera to attach
  55373. * @param unique if the camera can be attached multiple times to the pipeline
  55374. */
  55375. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55376. /**
  55377. * Detaches a camera from the pipeline
  55378. * @param renderPipelineName The name of the pipeline to detach from
  55379. * @param cameras the camera to detach
  55380. */
  55381. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55382. /**
  55383. * Enables an effect by name on a pipeline
  55384. * @param renderPipelineName the name of the pipeline to enable the effect in
  55385. * @param renderEffectName the name of the effect to enable
  55386. * @param cameras the cameras that the effect should be enabled on
  55387. */
  55388. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55389. /**
  55390. * Disables an effect by name on a pipeline
  55391. * @param renderPipelineName the name of the pipeline to disable the effect in
  55392. * @param renderEffectName the name of the effect to disable
  55393. * @param cameras the cameras that the effect should be disabled on
  55394. */
  55395. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55396. /**
  55397. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55398. */
  55399. update(): void;
  55400. /** @hidden */
  55401. _rebuild(): void;
  55402. /**
  55403. * Disposes of the manager and pipelines
  55404. */
  55405. dispose(): void;
  55406. }
  55407. }
  55408. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55409. import { ISceneComponent } from "babylonjs/sceneComponent";
  55410. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55411. import { Scene } from "babylonjs/scene";
  55412. module "babylonjs/scene" {
  55413. interface Scene {
  55414. /** @hidden (Backing field) */
  55415. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55416. /**
  55417. * Gets the postprocess render pipeline manager
  55418. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55419. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55420. */
  55421. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55422. }
  55423. }
  55424. /**
  55425. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55426. */
  55427. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55428. /**
  55429. * The component name helpfull to identify the component in the list of scene components.
  55430. */
  55431. readonly name: string;
  55432. /**
  55433. * The scene the component belongs to.
  55434. */
  55435. scene: Scene;
  55436. /**
  55437. * Creates a new instance of the component for the given scene
  55438. * @param scene Defines the scene to register the component in
  55439. */
  55440. constructor(scene: Scene);
  55441. /**
  55442. * Registers the component in a given scene
  55443. */
  55444. register(): void;
  55445. /**
  55446. * Rebuilds the elements related to this component in case of
  55447. * context lost for instance.
  55448. */
  55449. rebuild(): void;
  55450. /**
  55451. * Disposes the component and the associated ressources
  55452. */
  55453. dispose(): void;
  55454. private _gatherRenderTargets;
  55455. }
  55456. }
  55457. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55458. import { IAnimatable } from "babylonjs/Misc/tools";
  55459. import { Camera } from "babylonjs/Cameras/camera";
  55460. import { IDisposable } from "babylonjs/scene";
  55461. import { Scene } from "babylonjs/scene";
  55462. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55463. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55464. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55465. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55466. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55467. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55468. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55469. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55470. import { Animation } from "babylonjs/Animations/animation";
  55471. /**
  55472. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55473. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55474. */
  55475. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55476. private _scene;
  55477. private _camerasToBeAttached;
  55478. /**
  55479. * ID of the sharpen post process,
  55480. */
  55481. private readonly SharpenPostProcessId;
  55482. /**
  55483. * @ignore
  55484. * ID of the image processing post process;
  55485. */
  55486. readonly ImageProcessingPostProcessId: string;
  55487. /**
  55488. * @ignore
  55489. * ID of the Fast Approximate Anti-Aliasing post process;
  55490. */
  55491. readonly FxaaPostProcessId: string;
  55492. /**
  55493. * ID of the chromatic aberration post process,
  55494. */
  55495. private readonly ChromaticAberrationPostProcessId;
  55496. /**
  55497. * ID of the grain post process
  55498. */
  55499. private readonly GrainPostProcessId;
  55500. /**
  55501. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55502. */
  55503. sharpen: SharpenPostProcess;
  55504. private _sharpenEffect;
  55505. private bloom;
  55506. /**
  55507. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55508. */
  55509. depthOfField: DepthOfFieldEffect;
  55510. /**
  55511. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55512. */
  55513. fxaa: FxaaPostProcess;
  55514. /**
  55515. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55516. */
  55517. imageProcessing: ImageProcessingPostProcess;
  55518. /**
  55519. * Chromatic aberration post process which will shift rgb colors in the image
  55520. */
  55521. chromaticAberration: ChromaticAberrationPostProcess;
  55522. private _chromaticAberrationEffect;
  55523. /**
  55524. * Grain post process which add noise to the image
  55525. */
  55526. grain: GrainPostProcess;
  55527. private _grainEffect;
  55528. /**
  55529. * Glow post process which adds a glow to emissive areas of the image
  55530. */
  55531. private _glowLayer;
  55532. /**
  55533. * Animations which can be used to tweak settings over a period of time
  55534. */
  55535. animations: Animation[];
  55536. private _imageProcessingConfigurationObserver;
  55537. private _sharpenEnabled;
  55538. private _bloomEnabled;
  55539. private _depthOfFieldEnabled;
  55540. private _depthOfFieldBlurLevel;
  55541. private _fxaaEnabled;
  55542. private _imageProcessingEnabled;
  55543. private _defaultPipelineTextureType;
  55544. private _bloomScale;
  55545. private _chromaticAberrationEnabled;
  55546. private _grainEnabled;
  55547. private _buildAllowed;
  55548. /**
  55549. * Gets active scene
  55550. */
  55551. readonly scene: Scene;
  55552. /**
  55553. * Enable or disable the sharpen process from the pipeline
  55554. */
  55555. sharpenEnabled: boolean;
  55556. private _resizeObserver;
  55557. private _hardwareScaleLevel;
  55558. private _bloomKernel;
  55559. /**
  55560. * Specifies the size of the bloom blur kernel, relative to the final output size
  55561. */
  55562. bloomKernel: number;
  55563. /**
  55564. * Specifies the weight of the bloom in the final rendering
  55565. */
  55566. private _bloomWeight;
  55567. /**
  55568. * Specifies the luma threshold for the area that will be blurred by the bloom
  55569. */
  55570. private _bloomThreshold;
  55571. private _hdr;
  55572. /**
  55573. * The strength of the bloom.
  55574. */
  55575. bloomWeight: number;
  55576. /**
  55577. * The strength of the bloom.
  55578. */
  55579. bloomThreshold: number;
  55580. /**
  55581. * The scale of the bloom, lower value will provide better performance.
  55582. */
  55583. bloomScale: number;
  55584. /**
  55585. * Enable or disable the bloom from the pipeline
  55586. */
  55587. bloomEnabled: boolean;
  55588. private _rebuildBloom;
  55589. /**
  55590. * If the depth of field is enabled.
  55591. */
  55592. depthOfFieldEnabled: boolean;
  55593. /**
  55594. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55595. */
  55596. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55597. /**
  55598. * If the anti aliasing is enabled.
  55599. */
  55600. fxaaEnabled: boolean;
  55601. private _samples;
  55602. /**
  55603. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55604. */
  55605. samples: number;
  55606. /**
  55607. * If image processing is enabled.
  55608. */
  55609. imageProcessingEnabled: boolean;
  55610. /**
  55611. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55612. */
  55613. glowLayerEnabled: boolean;
  55614. /**
  55615. * Enable or disable the chromaticAberration process from the pipeline
  55616. */
  55617. chromaticAberrationEnabled: boolean;
  55618. /**
  55619. * Enable or disable the grain process from the pipeline
  55620. */
  55621. grainEnabled: boolean;
  55622. /**
  55623. * @constructor
  55624. * @param name - The rendering pipeline name (default: "")
  55625. * @param hdr - If high dynamic range textures should be used (default: true)
  55626. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55627. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55628. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55629. */
  55630. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55631. /**
  55632. * Get the class name
  55633. * @returns "DefaultRenderingPipeline"
  55634. */
  55635. getClassName(): string;
  55636. /**
  55637. * Force the compilation of the entire pipeline.
  55638. */
  55639. prepare(): void;
  55640. private _hasCleared;
  55641. private _prevPostProcess;
  55642. private _prevPrevPostProcess;
  55643. private _setAutoClearAndTextureSharing;
  55644. private _depthOfFieldSceneObserver;
  55645. private _buildPipeline;
  55646. private _disposePostProcesses;
  55647. /**
  55648. * Adds a camera to the pipeline
  55649. * @param camera the camera to be added
  55650. */
  55651. addCamera(camera: Camera): void;
  55652. /**
  55653. * Removes a camera from the pipeline
  55654. * @param camera the camera to remove
  55655. */
  55656. removeCamera(camera: Camera): void;
  55657. /**
  55658. * Dispose of the pipeline and stop all post processes
  55659. */
  55660. dispose(): void;
  55661. /**
  55662. * Serialize the rendering pipeline (Used when exporting)
  55663. * @returns the serialized object
  55664. */
  55665. serialize(): any;
  55666. /**
  55667. * Parse the serialized pipeline
  55668. * @param source Source pipeline.
  55669. * @param scene The scene to load the pipeline to.
  55670. * @param rootUrl The URL of the serialized pipeline.
  55671. * @returns An instantiated pipeline from the serialized object.
  55672. */
  55673. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55674. }
  55675. }
  55676. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55677. /** @hidden */
  55678. export var lensHighlightsPixelShader: {
  55679. name: string;
  55680. shader: string;
  55681. };
  55682. }
  55683. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55684. /** @hidden */
  55685. export var depthOfFieldPixelShader: {
  55686. name: string;
  55687. shader: string;
  55688. };
  55689. }
  55690. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55691. import { Camera } from "babylonjs/Cameras/camera";
  55692. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55693. import { Scene } from "babylonjs/scene";
  55694. import "babylonjs/Shaders/chromaticAberration.fragment";
  55695. import "babylonjs/Shaders/lensHighlights.fragment";
  55696. import "babylonjs/Shaders/depthOfField.fragment";
  55697. /**
  55698. * BABYLON.JS Chromatic Aberration GLSL Shader
  55699. * Author: Olivier Guyot
  55700. * Separates very slightly R, G and B colors on the edges of the screen
  55701. * Inspired by Francois Tarlier & Martins Upitis
  55702. */
  55703. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55704. /**
  55705. * @ignore
  55706. * The chromatic aberration PostProcess id in the pipeline
  55707. */
  55708. LensChromaticAberrationEffect: string;
  55709. /**
  55710. * @ignore
  55711. * The highlights enhancing PostProcess id in the pipeline
  55712. */
  55713. HighlightsEnhancingEffect: string;
  55714. /**
  55715. * @ignore
  55716. * The depth-of-field PostProcess id in the pipeline
  55717. */
  55718. LensDepthOfFieldEffect: string;
  55719. private _scene;
  55720. private _depthTexture;
  55721. private _grainTexture;
  55722. private _chromaticAberrationPostProcess;
  55723. private _highlightsPostProcess;
  55724. private _depthOfFieldPostProcess;
  55725. private _edgeBlur;
  55726. private _grainAmount;
  55727. private _chromaticAberration;
  55728. private _distortion;
  55729. private _highlightsGain;
  55730. private _highlightsThreshold;
  55731. private _dofDistance;
  55732. private _dofAperture;
  55733. private _dofDarken;
  55734. private _dofPentagon;
  55735. private _blurNoise;
  55736. /**
  55737. * @constructor
  55738. *
  55739. * Effect parameters are as follow:
  55740. * {
  55741. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55742. * edge_blur: number; // from 0 to x (1 for realism)
  55743. * distortion: number; // from 0 to x (1 for realism)
  55744. * grain_amount: number; // from 0 to 1
  55745. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55746. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55747. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55748. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55749. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55750. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55751. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55752. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55753. * }
  55754. * Note: if an effect parameter is unset, effect is disabled
  55755. *
  55756. * @param name The rendering pipeline name
  55757. * @param parameters - An object containing all parameters (see above)
  55758. * @param scene The scene linked to this pipeline
  55759. * @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)
  55760. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55761. */
  55762. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55763. /**
  55764. * Get the class name
  55765. * @returns "LensRenderingPipeline"
  55766. */
  55767. getClassName(): string;
  55768. /**
  55769. * Gets associated scene
  55770. */
  55771. readonly scene: Scene;
  55772. /**
  55773. * Gets or sets the edge blur
  55774. */
  55775. edgeBlur: number;
  55776. /**
  55777. * Gets or sets the grain amount
  55778. */
  55779. grainAmount: number;
  55780. /**
  55781. * Gets or sets the chromatic aberration amount
  55782. */
  55783. chromaticAberration: number;
  55784. /**
  55785. * Gets or sets the depth of field aperture
  55786. */
  55787. dofAperture: number;
  55788. /**
  55789. * Gets or sets the edge distortion
  55790. */
  55791. edgeDistortion: number;
  55792. /**
  55793. * Gets or sets the depth of field distortion
  55794. */
  55795. dofDistortion: number;
  55796. /**
  55797. * Gets or sets the darken out of focus amount
  55798. */
  55799. darkenOutOfFocus: number;
  55800. /**
  55801. * Gets or sets a boolean indicating if blur noise is enabled
  55802. */
  55803. blurNoise: boolean;
  55804. /**
  55805. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55806. */
  55807. pentagonBokeh: boolean;
  55808. /**
  55809. * Gets or sets the highlight grain amount
  55810. */
  55811. highlightsGain: number;
  55812. /**
  55813. * Gets or sets the highlight threshold
  55814. */
  55815. highlightsThreshold: number;
  55816. /**
  55817. * Sets the amount of blur at the edges
  55818. * @param amount blur amount
  55819. */
  55820. setEdgeBlur(amount: number): void;
  55821. /**
  55822. * Sets edge blur to 0
  55823. */
  55824. disableEdgeBlur(): void;
  55825. /**
  55826. * Sets the amout of grain
  55827. * @param amount Amount of grain
  55828. */
  55829. setGrainAmount(amount: number): void;
  55830. /**
  55831. * Set grain amount to 0
  55832. */
  55833. disableGrain(): void;
  55834. /**
  55835. * Sets the chromatic aberration amount
  55836. * @param amount amount of chromatic aberration
  55837. */
  55838. setChromaticAberration(amount: number): void;
  55839. /**
  55840. * Sets chromatic aberration amount to 0
  55841. */
  55842. disableChromaticAberration(): void;
  55843. /**
  55844. * Sets the EdgeDistortion amount
  55845. * @param amount amount of EdgeDistortion
  55846. */
  55847. setEdgeDistortion(amount: number): void;
  55848. /**
  55849. * Sets edge distortion to 0
  55850. */
  55851. disableEdgeDistortion(): void;
  55852. /**
  55853. * Sets the FocusDistance amount
  55854. * @param amount amount of FocusDistance
  55855. */
  55856. setFocusDistance(amount: number): void;
  55857. /**
  55858. * Disables depth of field
  55859. */
  55860. disableDepthOfField(): void;
  55861. /**
  55862. * Sets the Aperture amount
  55863. * @param amount amount of Aperture
  55864. */
  55865. setAperture(amount: number): void;
  55866. /**
  55867. * Sets the DarkenOutOfFocus amount
  55868. * @param amount amount of DarkenOutOfFocus
  55869. */
  55870. setDarkenOutOfFocus(amount: number): void;
  55871. private _pentagonBokehIsEnabled;
  55872. /**
  55873. * Creates a pentagon bokeh effect
  55874. */
  55875. enablePentagonBokeh(): void;
  55876. /**
  55877. * Disables the pentagon bokeh effect
  55878. */
  55879. disablePentagonBokeh(): void;
  55880. /**
  55881. * Enables noise blur
  55882. */
  55883. enableNoiseBlur(): void;
  55884. /**
  55885. * Disables noise blur
  55886. */
  55887. disableNoiseBlur(): void;
  55888. /**
  55889. * Sets the HighlightsGain amount
  55890. * @param amount amount of HighlightsGain
  55891. */
  55892. setHighlightsGain(amount: number): void;
  55893. /**
  55894. * Sets the HighlightsThreshold amount
  55895. * @param amount amount of HighlightsThreshold
  55896. */
  55897. setHighlightsThreshold(amount: number): void;
  55898. /**
  55899. * Disables highlights
  55900. */
  55901. disableHighlights(): void;
  55902. /**
  55903. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55904. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55905. */
  55906. dispose(disableDepthRender?: boolean): void;
  55907. private _createChromaticAberrationPostProcess;
  55908. private _createHighlightsPostProcess;
  55909. private _createDepthOfFieldPostProcess;
  55910. private _createGrainTexture;
  55911. }
  55912. }
  55913. declare module "babylonjs/Shaders/ssao2.fragment" {
  55914. /** @hidden */
  55915. export var ssao2PixelShader: {
  55916. name: string;
  55917. shader: string;
  55918. };
  55919. }
  55920. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55921. /** @hidden */
  55922. export var ssaoCombinePixelShader: {
  55923. name: string;
  55924. shader: string;
  55925. };
  55926. }
  55927. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55928. import { Camera } from "babylonjs/Cameras/camera";
  55929. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55930. import { Scene } from "babylonjs/scene";
  55931. import "babylonjs/Shaders/ssao2.fragment";
  55932. import "babylonjs/Shaders/ssaoCombine.fragment";
  55933. /**
  55934. * Render pipeline to produce ssao effect
  55935. */
  55936. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55937. /**
  55938. * @ignore
  55939. * The PassPostProcess id in the pipeline that contains the original scene color
  55940. */
  55941. SSAOOriginalSceneColorEffect: string;
  55942. /**
  55943. * @ignore
  55944. * The SSAO PostProcess id in the pipeline
  55945. */
  55946. SSAORenderEffect: string;
  55947. /**
  55948. * @ignore
  55949. * The horizontal blur PostProcess id in the pipeline
  55950. */
  55951. SSAOBlurHRenderEffect: string;
  55952. /**
  55953. * @ignore
  55954. * The vertical blur PostProcess id in the pipeline
  55955. */
  55956. SSAOBlurVRenderEffect: string;
  55957. /**
  55958. * @ignore
  55959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55960. */
  55961. SSAOCombineRenderEffect: string;
  55962. /**
  55963. * The output strength of the SSAO post-process. Default value is 1.0.
  55964. */
  55965. totalStrength: number;
  55966. /**
  55967. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55968. */
  55969. maxZ: number;
  55970. /**
  55971. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55972. */
  55973. minZAspect: number;
  55974. private _samples;
  55975. /**
  55976. * Number of samples used for the SSAO calculations. Default value is 8
  55977. */
  55978. samples: number;
  55979. private _textureSamples;
  55980. /**
  55981. * Number of samples to use for antialiasing
  55982. */
  55983. textureSamples: number;
  55984. /**
  55985. * Ratio object used for SSAO ratio and blur ratio
  55986. */
  55987. private _ratio;
  55988. /**
  55989. * Dynamically generated sphere sampler.
  55990. */
  55991. private _sampleSphere;
  55992. /**
  55993. * Blur filter offsets
  55994. */
  55995. private _samplerOffsets;
  55996. private _expensiveBlur;
  55997. /**
  55998. * If bilateral blur should be used
  55999. */
  56000. expensiveBlur: boolean;
  56001. /**
  56002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56003. */
  56004. radius: number;
  56005. /**
  56006. * The base color of the SSAO post-process
  56007. * The final result is "base + ssao" between [0, 1]
  56008. */
  56009. base: number;
  56010. /**
  56011. * Support test.
  56012. */
  56013. static readonly IsSupported: boolean;
  56014. private _scene;
  56015. private _depthTexture;
  56016. private _normalTexture;
  56017. private _randomTexture;
  56018. private _originalColorPostProcess;
  56019. private _ssaoPostProcess;
  56020. private _blurHPostProcess;
  56021. private _blurVPostProcess;
  56022. private _ssaoCombinePostProcess;
  56023. private _firstUpdate;
  56024. /**
  56025. * Gets active scene
  56026. */
  56027. readonly scene: Scene;
  56028. /**
  56029. * @constructor
  56030. * @param name The rendering pipeline name
  56031. * @param scene The scene linked to this pipeline
  56032. * @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 }
  56033. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56034. */
  56035. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56036. /**
  56037. * Get the class name
  56038. * @returns "SSAO2RenderingPipeline"
  56039. */
  56040. getClassName(): string;
  56041. /**
  56042. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56043. */
  56044. dispose(disableGeometryBufferRenderer?: boolean): void;
  56045. private _createBlurPostProcess;
  56046. /** @hidden */
  56047. _rebuild(): void;
  56048. private _bits;
  56049. private _radicalInverse_VdC;
  56050. private _hammersley;
  56051. private _hemisphereSample_uniform;
  56052. private _generateHemisphere;
  56053. private _createSSAOPostProcess;
  56054. private _createSSAOCombinePostProcess;
  56055. private _createRandomTexture;
  56056. /**
  56057. * Serialize the rendering pipeline (Used when exporting)
  56058. * @returns the serialized object
  56059. */
  56060. serialize(): any;
  56061. /**
  56062. * Parse the serialized pipeline
  56063. * @param source Source pipeline.
  56064. * @param scene The scene to load the pipeline to.
  56065. * @param rootUrl The URL of the serialized pipeline.
  56066. * @returns An instantiated pipeline from the serialized object.
  56067. */
  56068. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56069. }
  56070. }
  56071. declare module "babylonjs/Shaders/ssao.fragment" {
  56072. /** @hidden */
  56073. export var ssaoPixelShader: {
  56074. name: string;
  56075. shader: string;
  56076. };
  56077. }
  56078. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56079. import { Camera } from "babylonjs/Cameras/camera";
  56080. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56081. import { Scene } from "babylonjs/scene";
  56082. import "babylonjs/Shaders/ssao.fragment";
  56083. import "babylonjs/Shaders/ssaoCombine.fragment";
  56084. /**
  56085. * Render pipeline to produce ssao effect
  56086. */
  56087. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56088. /**
  56089. * @ignore
  56090. * The PassPostProcess id in the pipeline that contains the original scene color
  56091. */
  56092. SSAOOriginalSceneColorEffect: string;
  56093. /**
  56094. * @ignore
  56095. * The SSAO PostProcess id in the pipeline
  56096. */
  56097. SSAORenderEffect: string;
  56098. /**
  56099. * @ignore
  56100. * The horizontal blur PostProcess id in the pipeline
  56101. */
  56102. SSAOBlurHRenderEffect: string;
  56103. /**
  56104. * @ignore
  56105. * The vertical blur PostProcess id in the pipeline
  56106. */
  56107. SSAOBlurVRenderEffect: string;
  56108. /**
  56109. * @ignore
  56110. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56111. */
  56112. SSAOCombineRenderEffect: string;
  56113. /**
  56114. * The output strength of the SSAO post-process. Default value is 1.0.
  56115. */
  56116. totalStrength: number;
  56117. /**
  56118. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56119. */
  56120. radius: number;
  56121. /**
  56122. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56123. * Must not be equal to fallOff and superior to fallOff.
  56124. * Default value is 0.0075
  56125. */
  56126. area: number;
  56127. /**
  56128. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56129. * Must not be equal to area and inferior to area.
  56130. * Default value is 0.000001
  56131. */
  56132. fallOff: number;
  56133. /**
  56134. * The base color of the SSAO post-process
  56135. * The final result is "base + ssao" between [0, 1]
  56136. */
  56137. base: number;
  56138. private _scene;
  56139. private _depthTexture;
  56140. private _randomTexture;
  56141. private _originalColorPostProcess;
  56142. private _ssaoPostProcess;
  56143. private _blurHPostProcess;
  56144. private _blurVPostProcess;
  56145. private _ssaoCombinePostProcess;
  56146. private _firstUpdate;
  56147. /**
  56148. * Gets active scene
  56149. */
  56150. readonly scene: Scene;
  56151. /**
  56152. * @constructor
  56153. * @param name - The rendering pipeline name
  56154. * @param scene - The scene linked to this pipeline
  56155. * @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 }
  56156. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56157. */
  56158. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56159. /**
  56160. * Get the class name
  56161. * @returns "SSAORenderingPipeline"
  56162. */
  56163. getClassName(): string;
  56164. /**
  56165. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56166. */
  56167. dispose(disableDepthRender?: boolean): void;
  56168. private _createBlurPostProcess;
  56169. /** @hidden */
  56170. _rebuild(): void;
  56171. private _createSSAOPostProcess;
  56172. private _createSSAOCombinePostProcess;
  56173. private _createRandomTexture;
  56174. }
  56175. }
  56176. declare module "babylonjs/Shaders/standard.fragment" {
  56177. /** @hidden */
  56178. export var standardPixelShader: {
  56179. name: string;
  56180. shader: string;
  56181. };
  56182. }
  56183. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56184. import { Nullable } from "babylonjs/types";
  56185. import { IAnimatable } from "babylonjs/Misc/tools";
  56186. import { Camera } from "babylonjs/Cameras/camera";
  56187. import { Texture } from "babylonjs/Materials/Textures/texture";
  56188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56190. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56191. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56192. import { IDisposable } from "babylonjs/scene";
  56193. import { SpotLight } from "babylonjs/Lights/spotLight";
  56194. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56195. import { Scene } from "babylonjs/scene";
  56196. import { Animation } from "babylonjs/Animations/animation";
  56197. import "babylonjs/Shaders/standard.fragment";
  56198. /**
  56199. * Standard rendering pipeline
  56200. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56201. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56202. */
  56203. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56204. /**
  56205. * Public members
  56206. */
  56207. /**
  56208. * Post-process which contains the original scene color before the pipeline applies all the effects
  56209. */
  56210. originalPostProcess: Nullable<PostProcess>;
  56211. /**
  56212. * Post-process used to down scale an image x4
  56213. */
  56214. downSampleX4PostProcess: Nullable<PostProcess>;
  56215. /**
  56216. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56217. */
  56218. brightPassPostProcess: Nullable<PostProcess>;
  56219. /**
  56220. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56221. */
  56222. blurHPostProcesses: PostProcess[];
  56223. /**
  56224. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56225. */
  56226. blurVPostProcesses: PostProcess[];
  56227. /**
  56228. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56229. */
  56230. textureAdderPostProcess: Nullable<PostProcess>;
  56231. /**
  56232. * Post-process used to create volumetric lighting effect
  56233. */
  56234. volumetricLightPostProcess: Nullable<PostProcess>;
  56235. /**
  56236. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56237. */
  56238. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56239. /**
  56240. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56241. */
  56242. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56243. /**
  56244. * Post-process used to merge the volumetric light effect and the real scene color
  56245. */
  56246. volumetricLightMergePostProces: Nullable<PostProcess>;
  56247. /**
  56248. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56249. */
  56250. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56251. /**
  56252. * Base post-process used to calculate the average luminance of the final image for HDR
  56253. */
  56254. luminancePostProcess: Nullable<PostProcess>;
  56255. /**
  56256. * Post-processes used to create down sample post-processes in order to get
  56257. * the average luminance of the final image for HDR
  56258. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56259. */
  56260. luminanceDownSamplePostProcesses: PostProcess[];
  56261. /**
  56262. * Post-process used to create a HDR effect (light adaptation)
  56263. */
  56264. hdrPostProcess: Nullable<PostProcess>;
  56265. /**
  56266. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56267. */
  56268. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56269. /**
  56270. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56271. */
  56272. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56273. /**
  56274. * Post-process used to merge the final HDR post-process and the real scene color
  56275. */
  56276. hdrFinalPostProcess: Nullable<PostProcess>;
  56277. /**
  56278. * Post-process used to create a lens flare effect
  56279. */
  56280. lensFlarePostProcess: Nullable<PostProcess>;
  56281. /**
  56282. * Post-process that merges the result of the lens flare post-process and the real scene color
  56283. */
  56284. lensFlareComposePostProcess: Nullable<PostProcess>;
  56285. /**
  56286. * Post-process used to create a motion blur effect
  56287. */
  56288. motionBlurPostProcess: Nullable<PostProcess>;
  56289. /**
  56290. * Post-process used to create a depth of field effect
  56291. */
  56292. depthOfFieldPostProcess: Nullable<PostProcess>;
  56293. /**
  56294. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56295. */
  56296. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56297. /**
  56298. * Represents the brightness threshold in order to configure the illuminated surfaces
  56299. */
  56300. brightThreshold: number;
  56301. /**
  56302. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56303. */
  56304. blurWidth: number;
  56305. /**
  56306. * Sets if the blur for highlighted surfaces must be only horizontal
  56307. */
  56308. horizontalBlur: boolean;
  56309. /**
  56310. * Gets the overall exposure used by the pipeline
  56311. */
  56312. /**
  56313. * Sets the overall exposure used by the pipeline
  56314. */
  56315. exposure: number;
  56316. /**
  56317. * Texture used typically to simulate "dirty" on camera lens
  56318. */
  56319. lensTexture: Nullable<Texture>;
  56320. /**
  56321. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56322. */
  56323. volumetricLightCoefficient: number;
  56324. /**
  56325. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56326. */
  56327. volumetricLightPower: number;
  56328. /**
  56329. * Used the set the blur intensity to smooth the volumetric lights
  56330. */
  56331. volumetricLightBlurScale: number;
  56332. /**
  56333. * Light (spot or directional) used to generate the volumetric lights rays
  56334. * The source light must have a shadow generate so the pipeline can get its
  56335. * depth map
  56336. */
  56337. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56338. /**
  56339. * For eye adaptation, represents the minimum luminance the eye can see
  56340. */
  56341. hdrMinimumLuminance: number;
  56342. /**
  56343. * For eye adaptation, represents the decrease luminance speed
  56344. */
  56345. hdrDecreaseRate: number;
  56346. /**
  56347. * For eye adaptation, represents the increase luminance speed
  56348. */
  56349. hdrIncreaseRate: number;
  56350. /**
  56351. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56352. */
  56353. /**
  56354. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56355. */
  56356. hdrAutoExposure: boolean;
  56357. /**
  56358. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56359. */
  56360. lensColorTexture: Nullable<Texture>;
  56361. /**
  56362. * The overall strengh for the lens flare effect
  56363. */
  56364. lensFlareStrength: number;
  56365. /**
  56366. * Dispersion coefficient for lens flare ghosts
  56367. */
  56368. lensFlareGhostDispersal: number;
  56369. /**
  56370. * Main lens flare halo width
  56371. */
  56372. lensFlareHaloWidth: number;
  56373. /**
  56374. * Based on the lens distortion effect, defines how much the lens flare result
  56375. * is distorted
  56376. */
  56377. lensFlareDistortionStrength: number;
  56378. /**
  56379. * Lens star texture must be used to simulate rays on the flares and is available
  56380. * in the documentation
  56381. */
  56382. lensStarTexture: Nullable<Texture>;
  56383. /**
  56384. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56385. * flare effect by taking account of the dirt texture
  56386. */
  56387. lensFlareDirtTexture: Nullable<Texture>;
  56388. /**
  56389. * Represents the focal length for the depth of field effect
  56390. */
  56391. depthOfFieldDistance: number;
  56392. /**
  56393. * Represents the blur intensity for the blurred part of the depth of field effect
  56394. */
  56395. depthOfFieldBlurWidth: number;
  56396. /**
  56397. * For motion blur, defines how much the image is blurred by the movement
  56398. */
  56399. motionStrength: number;
  56400. /**
  56401. * List of animations for the pipeline (IAnimatable implementation)
  56402. */
  56403. animations: Animation[];
  56404. /**
  56405. * Private members
  56406. */
  56407. private _scene;
  56408. private _currentDepthOfFieldSource;
  56409. private _basePostProcess;
  56410. private _fixedExposure;
  56411. private _currentExposure;
  56412. private _hdrAutoExposure;
  56413. private _hdrCurrentLuminance;
  56414. private _floatTextureType;
  56415. private _ratio;
  56416. private _bloomEnabled;
  56417. private _depthOfFieldEnabled;
  56418. private _vlsEnabled;
  56419. private _lensFlareEnabled;
  56420. private _hdrEnabled;
  56421. private _motionBlurEnabled;
  56422. private _fxaaEnabled;
  56423. private _motionBlurSamples;
  56424. private _volumetricLightStepsCount;
  56425. private _samples;
  56426. /**
  56427. * @ignore
  56428. * Specifies if the bloom pipeline is enabled
  56429. */
  56430. BloomEnabled: boolean;
  56431. /**
  56432. * @ignore
  56433. * Specifies if the depth of field pipeline is enabed
  56434. */
  56435. DepthOfFieldEnabled: boolean;
  56436. /**
  56437. * @ignore
  56438. * Specifies if the lens flare pipeline is enabed
  56439. */
  56440. LensFlareEnabled: boolean;
  56441. /**
  56442. * @ignore
  56443. * Specifies if the HDR pipeline is enabled
  56444. */
  56445. HDREnabled: boolean;
  56446. /**
  56447. * @ignore
  56448. * Specifies if the volumetric lights scattering effect is enabled
  56449. */
  56450. VLSEnabled: boolean;
  56451. /**
  56452. * @ignore
  56453. * Specifies if the motion blur effect is enabled
  56454. */
  56455. MotionBlurEnabled: boolean;
  56456. /**
  56457. * Specifies if anti-aliasing is enabled
  56458. */
  56459. fxaaEnabled: boolean;
  56460. /**
  56461. * Specifies the number of steps used to calculate the volumetric lights
  56462. * Typically in interval [50, 200]
  56463. */
  56464. volumetricLightStepsCount: number;
  56465. /**
  56466. * Specifies the number of samples used for the motion blur effect
  56467. * Typically in interval [16, 64]
  56468. */
  56469. motionBlurSamples: number;
  56470. /**
  56471. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56472. */
  56473. samples: number;
  56474. /**
  56475. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56476. * @constructor
  56477. * @param name The rendering pipeline name
  56478. * @param scene The scene linked to this pipeline
  56479. * @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)
  56480. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56481. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56482. */
  56483. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56484. private _buildPipeline;
  56485. private _createDownSampleX4PostProcess;
  56486. private _createBrightPassPostProcess;
  56487. private _createBlurPostProcesses;
  56488. private _createTextureAdderPostProcess;
  56489. private _createVolumetricLightPostProcess;
  56490. private _createLuminancePostProcesses;
  56491. private _createHdrPostProcess;
  56492. private _createLensFlarePostProcess;
  56493. private _createDepthOfFieldPostProcess;
  56494. private _createMotionBlurPostProcess;
  56495. private _getDepthTexture;
  56496. private _disposePostProcesses;
  56497. /**
  56498. * Dispose of the pipeline and stop all post processes
  56499. */
  56500. dispose(): void;
  56501. /**
  56502. * Serialize the rendering pipeline (Used when exporting)
  56503. * @returns the serialized object
  56504. */
  56505. serialize(): any;
  56506. /**
  56507. * Parse the serialized pipeline
  56508. * @param source Source pipeline.
  56509. * @param scene The scene to load the pipeline to.
  56510. * @param rootUrl The URL of the serialized pipeline.
  56511. * @returns An instantiated pipeline from the serialized object.
  56512. */
  56513. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56514. /**
  56515. * Luminance steps
  56516. */
  56517. static LuminanceSteps: number;
  56518. }
  56519. }
  56520. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56521. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56522. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56523. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56524. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56525. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56526. }
  56527. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56528. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56529. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56530. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56531. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56532. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56533. }
  56534. declare module "babylonjs/Shaders/tonemap.fragment" {
  56535. /** @hidden */
  56536. export var tonemapPixelShader: {
  56537. name: string;
  56538. shader: string;
  56539. };
  56540. }
  56541. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56542. import { Camera } from "babylonjs/Cameras/camera";
  56543. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56544. import "babylonjs/Shaders/tonemap.fragment";
  56545. import { Engine } from "babylonjs/Engines/engine";
  56546. /** Defines operator used for tonemapping */
  56547. export enum TonemappingOperator {
  56548. /** Hable */
  56549. Hable = 0,
  56550. /** Reinhard */
  56551. Reinhard = 1,
  56552. /** HejiDawson */
  56553. HejiDawson = 2,
  56554. /** Photographic */
  56555. Photographic = 3
  56556. }
  56557. /**
  56558. * Defines a post process to apply tone mapping
  56559. */
  56560. export class TonemapPostProcess extends PostProcess {
  56561. private _operator;
  56562. /** Defines the required exposure adjustement */
  56563. exposureAdjustment: number;
  56564. /**
  56565. * Creates a new TonemapPostProcess
  56566. * @param name defines the name of the postprocess
  56567. * @param _operator defines the operator to use
  56568. * @param exposureAdjustment defines the required exposure adjustement
  56569. * @param camera defines the camera to use (can be null)
  56570. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56571. * @param engine defines the hosting engine (can be ignore if camera is set)
  56572. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56573. */
  56574. constructor(name: string, _operator: TonemappingOperator,
  56575. /** Defines the required exposure adjustement */
  56576. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56577. }
  56578. }
  56579. declare module "babylonjs/Shaders/depth.vertex" {
  56580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56581. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56582. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56583. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56584. /** @hidden */
  56585. export var depthVertexShader: {
  56586. name: string;
  56587. shader: string;
  56588. };
  56589. }
  56590. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56591. /** @hidden */
  56592. export var volumetricLightScatteringPixelShader: {
  56593. name: string;
  56594. shader: string;
  56595. };
  56596. }
  56597. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56598. /** @hidden */
  56599. export var volumetricLightScatteringPassPixelShader: {
  56600. name: string;
  56601. shader: string;
  56602. };
  56603. }
  56604. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56605. import { Vector3 } from "babylonjs/Maths/math";
  56606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56607. import { Mesh } from "babylonjs/Meshes/mesh";
  56608. import { Camera } from "babylonjs/Cameras/camera";
  56609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56610. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56611. import { Scene } from "babylonjs/scene";
  56612. import "babylonjs/Meshes/Builders/planeBuilder";
  56613. import "babylonjs/Shaders/depth.vertex";
  56614. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56615. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56616. import { Engine } from "babylonjs/Engines/engine";
  56617. /**
  56618. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56619. */
  56620. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56621. private _volumetricLightScatteringPass;
  56622. private _volumetricLightScatteringRTT;
  56623. private _viewPort;
  56624. private _screenCoordinates;
  56625. private _cachedDefines;
  56626. /**
  56627. * If not undefined, the mesh position is computed from the attached node position
  56628. */
  56629. attachedNode: {
  56630. position: Vector3;
  56631. };
  56632. /**
  56633. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56634. */
  56635. customMeshPosition: Vector3;
  56636. /**
  56637. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56638. */
  56639. useCustomMeshPosition: boolean;
  56640. /**
  56641. * If the post-process should inverse the light scattering direction
  56642. */
  56643. invert: boolean;
  56644. /**
  56645. * The internal mesh used by the post-process
  56646. */
  56647. mesh: Mesh;
  56648. /**
  56649. * @hidden
  56650. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56651. */
  56652. useDiffuseColor: boolean;
  56653. /**
  56654. * Array containing the excluded meshes not rendered in the internal pass
  56655. */
  56656. excludedMeshes: AbstractMesh[];
  56657. /**
  56658. * Controls the overall intensity of the post-process
  56659. */
  56660. exposure: number;
  56661. /**
  56662. * Dissipates each sample's contribution in range [0, 1]
  56663. */
  56664. decay: number;
  56665. /**
  56666. * Controls the overall intensity of each sample
  56667. */
  56668. weight: number;
  56669. /**
  56670. * Controls the density of each sample
  56671. */
  56672. density: number;
  56673. /**
  56674. * @constructor
  56675. * @param name The post-process name
  56676. * @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)
  56677. * @param camera The camera that the post-process will be attached to
  56678. * @param mesh The mesh used to create the light scattering
  56679. * @param samples The post-process quality, default 100
  56680. * @param samplingModeThe post-process filtering mode
  56681. * @param engine The babylon engine
  56682. * @param reusable If the post-process is reusable
  56683. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56684. */
  56685. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56686. /**
  56687. * Returns the string "VolumetricLightScatteringPostProcess"
  56688. * @returns "VolumetricLightScatteringPostProcess"
  56689. */
  56690. getClassName(): string;
  56691. private _isReady;
  56692. /**
  56693. * Sets the new light position for light scattering effect
  56694. * @param position The new custom light position
  56695. */
  56696. setCustomMeshPosition(position: Vector3): void;
  56697. /**
  56698. * Returns the light position for light scattering effect
  56699. * @return Vector3 The custom light position
  56700. */
  56701. getCustomMeshPosition(): Vector3;
  56702. /**
  56703. * Disposes the internal assets and detaches the post-process from the camera
  56704. */
  56705. dispose(camera: Camera): void;
  56706. /**
  56707. * Returns the render target texture used by the post-process
  56708. * @return the render target texture used by the post-process
  56709. */
  56710. getPass(): RenderTargetTexture;
  56711. private _meshExcluded;
  56712. private _createPass;
  56713. private _updateMeshScreenCoordinates;
  56714. /**
  56715. * Creates a default mesh for the Volumeric Light Scattering post-process
  56716. * @param name The mesh name
  56717. * @param scene The scene where to create the mesh
  56718. * @return the default mesh
  56719. */
  56720. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56721. }
  56722. }
  56723. declare module "babylonjs/PostProcesses/index" {
  56724. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56725. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56726. export * from "babylonjs/PostProcesses/bloomEffect";
  56727. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56728. export * from "babylonjs/PostProcesses/blurPostProcess";
  56729. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56730. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56731. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56732. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56733. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56734. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56735. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56736. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56737. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56738. export * from "babylonjs/PostProcesses/filterPostProcess";
  56739. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56740. export * from "babylonjs/PostProcesses/grainPostProcess";
  56741. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56742. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56743. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56744. export * from "babylonjs/PostProcesses/passPostProcess";
  56745. export * from "babylonjs/PostProcesses/postProcess";
  56746. export * from "babylonjs/PostProcesses/postProcessManager";
  56747. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56748. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56749. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56750. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56751. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56752. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56753. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56754. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56755. }
  56756. declare module "babylonjs/Probes/index" {
  56757. export * from "babylonjs/Probes/reflectionProbe";
  56758. }
  56759. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56760. import { Scene } from "babylonjs/scene";
  56761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56762. import { Color3 } from "babylonjs/Maths/math";
  56763. import { SmartArray } from "babylonjs/Misc/smartArray";
  56764. import { ISceneComponent } from "babylonjs/sceneComponent";
  56765. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56766. import "babylonjs/Meshes/Builders/boxBuilder";
  56767. import "babylonjs/Shaders/color.fragment";
  56768. import "babylonjs/Shaders/color.vertex";
  56769. module "babylonjs/scene" {
  56770. interface Scene {
  56771. /** @hidden (Backing field) */
  56772. _boundingBoxRenderer: BoundingBoxRenderer;
  56773. /** @hidden (Backing field) */
  56774. _forceShowBoundingBoxes: boolean;
  56775. /**
  56776. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56777. */
  56778. forceShowBoundingBoxes: boolean;
  56779. /**
  56780. * Gets the bounding box renderer associated with the scene
  56781. * @returns a BoundingBoxRenderer
  56782. */
  56783. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56784. }
  56785. }
  56786. module "babylonjs/Meshes/abstractMesh" {
  56787. interface AbstractMesh {
  56788. /** @hidden (Backing field) */
  56789. _showBoundingBox: boolean;
  56790. /**
  56791. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56792. */
  56793. showBoundingBox: boolean;
  56794. }
  56795. }
  56796. /**
  56797. * Component responsible of rendering the bounding box of the meshes in a scene.
  56798. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56799. */
  56800. export class BoundingBoxRenderer implements ISceneComponent {
  56801. /**
  56802. * The component name helpfull to identify the component in the list of scene components.
  56803. */
  56804. readonly name: string;
  56805. /**
  56806. * The scene the component belongs to.
  56807. */
  56808. scene: Scene;
  56809. /**
  56810. * Color of the bounding box lines placed in front of an object
  56811. */
  56812. frontColor: Color3;
  56813. /**
  56814. * Color of the bounding box lines placed behind an object
  56815. */
  56816. backColor: Color3;
  56817. /**
  56818. * Defines if the renderer should show the back lines or not
  56819. */
  56820. showBackLines: boolean;
  56821. /**
  56822. * @hidden
  56823. */
  56824. renderList: SmartArray<BoundingBox>;
  56825. private _colorShader;
  56826. private _vertexBuffers;
  56827. private _indexBuffer;
  56828. /**
  56829. * Instantiates a new bounding box renderer in a scene.
  56830. * @param scene the scene the renderer renders in
  56831. */
  56832. constructor(scene: Scene);
  56833. /**
  56834. * Registers the component in a given scene
  56835. */
  56836. register(): void;
  56837. private _evaluateSubMesh;
  56838. private _activeMesh;
  56839. private _prepareRessources;
  56840. private _createIndexBuffer;
  56841. /**
  56842. * Rebuilds the elements related to this component in case of
  56843. * context lost for instance.
  56844. */
  56845. rebuild(): void;
  56846. /**
  56847. * @hidden
  56848. */
  56849. reset(): void;
  56850. /**
  56851. * Render the bounding boxes of a specific rendering group
  56852. * @param renderingGroupId defines the rendering group to render
  56853. */
  56854. render(renderingGroupId: number): void;
  56855. /**
  56856. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56857. * @param mesh Define the mesh to render the occlusion bounding box for
  56858. */
  56859. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56860. /**
  56861. * Dispose and release the resources attached to this renderer.
  56862. */
  56863. dispose(): void;
  56864. }
  56865. }
  56866. declare module "babylonjs/Shaders/depth.fragment" {
  56867. /** @hidden */
  56868. export var depthPixelShader: {
  56869. name: string;
  56870. shader: string;
  56871. };
  56872. }
  56873. declare module "babylonjs/Rendering/depthRenderer" {
  56874. import { Nullable } from "babylonjs/types";
  56875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56876. import { Scene } from "babylonjs/scene";
  56877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56878. import { Camera } from "babylonjs/Cameras/camera";
  56879. import "babylonjs/Shaders/depth.fragment";
  56880. import "babylonjs/Shaders/depth.vertex";
  56881. /**
  56882. * This represents a depth renderer in Babylon.
  56883. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56884. */
  56885. export class DepthRenderer {
  56886. private _scene;
  56887. private _depthMap;
  56888. private _effect;
  56889. private _cachedDefines;
  56890. private _camera;
  56891. /**
  56892. * Specifiess that the depth renderer will only be used within
  56893. * the camera it is created for.
  56894. * This can help forcing its rendering during the camera processing.
  56895. */
  56896. useOnlyInActiveCamera: boolean;
  56897. /** @hidden */
  56898. static _SceneComponentInitialization: (scene: Scene) => void;
  56899. /**
  56900. * Instantiates a depth renderer
  56901. * @param scene The scene the renderer belongs to
  56902. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56903. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56904. */
  56905. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56906. /**
  56907. * Creates the depth rendering effect and checks if the effect is ready.
  56908. * @param subMesh The submesh to be used to render the depth map of
  56909. * @param useInstances If multiple world instances should be used
  56910. * @returns if the depth renderer is ready to render the depth map
  56911. */
  56912. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56913. /**
  56914. * Gets the texture which the depth map will be written to.
  56915. * @returns The depth map texture
  56916. */
  56917. getDepthMap(): RenderTargetTexture;
  56918. /**
  56919. * Disposes of the depth renderer.
  56920. */
  56921. dispose(): void;
  56922. }
  56923. }
  56924. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56925. import { Nullable } from "babylonjs/types";
  56926. import { Scene } from "babylonjs/scene";
  56927. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56928. import { Camera } from "babylonjs/Cameras/camera";
  56929. import { ISceneComponent } from "babylonjs/sceneComponent";
  56930. module "babylonjs/scene" {
  56931. interface Scene {
  56932. /** @hidden (Backing field) */
  56933. _depthRenderer: {
  56934. [id: string]: DepthRenderer;
  56935. };
  56936. /**
  56937. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56938. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56939. * @returns the created depth renderer
  56940. */
  56941. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56942. /**
  56943. * Disables a depth renderer for a given camera
  56944. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56945. */
  56946. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56947. }
  56948. }
  56949. /**
  56950. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56951. * in several rendering techniques.
  56952. */
  56953. export class DepthRendererSceneComponent implements ISceneComponent {
  56954. /**
  56955. * The component name helpfull to identify the component in the list of scene components.
  56956. */
  56957. readonly name: string;
  56958. /**
  56959. * The scene the component belongs to.
  56960. */
  56961. scene: Scene;
  56962. /**
  56963. * Creates a new instance of the component for the given scene
  56964. * @param scene Defines the scene to register the component in
  56965. */
  56966. constructor(scene: Scene);
  56967. /**
  56968. * Registers the component in a given scene
  56969. */
  56970. register(): void;
  56971. /**
  56972. * Rebuilds the elements related to this component in case of
  56973. * context lost for instance.
  56974. */
  56975. rebuild(): void;
  56976. /**
  56977. * Disposes the component and the associated ressources
  56978. */
  56979. dispose(): void;
  56980. private _gatherRenderTargets;
  56981. private _gatherActiveCameraRenderTargets;
  56982. }
  56983. }
  56984. declare module "babylonjs/Shaders/outline.fragment" {
  56985. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56986. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56987. /** @hidden */
  56988. export var outlinePixelShader: {
  56989. name: string;
  56990. shader: string;
  56991. };
  56992. }
  56993. declare module "babylonjs/Shaders/outline.vertex" {
  56994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56995. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56996. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56997. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56998. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56999. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57000. /** @hidden */
  57001. export var outlineVertexShader: {
  57002. name: string;
  57003. shader: string;
  57004. };
  57005. }
  57006. declare module "babylonjs/Rendering/outlineRenderer" {
  57007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57008. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57009. import { Scene } from "babylonjs/scene";
  57010. import { ISceneComponent } from "babylonjs/sceneComponent";
  57011. import "babylonjs/Shaders/outline.fragment";
  57012. import "babylonjs/Shaders/outline.vertex";
  57013. module "babylonjs/scene" {
  57014. interface Scene {
  57015. /** @hidden */
  57016. _outlineRenderer: OutlineRenderer;
  57017. /**
  57018. * Gets the outline renderer associated with the scene
  57019. * @returns a OutlineRenderer
  57020. */
  57021. getOutlineRenderer(): OutlineRenderer;
  57022. }
  57023. }
  57024. module "babylonjs/Meshes/abstractMesh" {
  57025. interface AbstractMesh {
  57026. /** @hidden (Backing field) */
  57027. _renderOutline: boolean;
  57028. /**
  57029. * Gets or sets a boolean indicating if the outline must be rendered as well
  57030. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57031. */
  57032. renderOutline: boolean;
  57033. /** @hidden (Backing field) */
  57034. _renderOverlay: boolean;
  57035. /**
  57036. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57037. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57038. */
  57039. renderOverlay: boolean;
  57040. }
  57041. }
  57042. /**
  57043. * This class is responsible to draw bothe outline/overlay of meshes.
  57044. * It should not be used directly but through the available method on mesh.
  57045. */
  57046. export class OutlineRenderer implements ISceneComponent {
  57047. /**
  57048. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57049. */
  57050. private static _StencilReference;
  57051. /**
  57052. * The name of the component. Each component must have a unique name.
  57053. */
  57054. name: string;
  57055. /**
  57056. * The scene the component belongs to.
  57057. */
  57058. scene: Scene;
  57059. /**
  57060. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57061. */
  57062. zOffset: number;
  57063. private _engine;
  57064. private _effect;
  57065. private _cachedDefines;
  57066. private _savedDepthWrite;
  57067. /**
  57068. * Instantiates a new outline renderer. (There could be only one per scene).
  57069. * @param scene Defines the scene it belongs to
  57070. */
  57071. constructor(scene: Scene);
  57072. /**
  57073. * Register the component to one instance of a scene.
  57074. */
  57075. register(): void;
  57076. /**
  57077. * Rebuilds the elements related to this component in case of
  57078. * context lost for instance.
  57079. */
  57080. rebuild(): void;
  57081. /**
  57082. * Disposes the component and the associated ressources.
  57083. */
  57084. dispose(): void;
  57085. /**
  57086. * Renders the outline in the canvas.
  57087. * @param subMesh Defines the sumesh to render
  57088. * @param batch Defines the batch of meshes in case of instances
  57089. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57090. */
  57091. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57092. /**
  57093. * Returns whether or not the outline renderer is ready for a given submesh.
  57094. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57095. * @param subMesh Defines the submesh to check readyness for
  57096. * @param useInstances Defines wheter wee are trying to render instances or not
  57097. * @returns true if ready otherwise false
  57098. */
  57099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57100. private _beforeRenderingMesh;
  57101. private _afterRenderingMesh;
  57102. }
  57103. }
  57104. declare module "babylonjs/Rendering/index" {
  57105. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57106. export * from "babylonjs/Rendering/depthRenderer";
  57107. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57108. export * from "babylonjs/Rendering/edgesRenderer";
  57109. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57110. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57111. export * from "babylonjs/Rendering/outlineRenderer";
  57112. export * from "babylonjs/Rendering/renderingGroup";
  57113. export * from "babylonjs/Rendering/renderingManager";
  57114. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57115. }
  57116. declare module "babylonjs/Sprites/index" {
  57117. export * from "babylonjs/Sprites/sprite";
  57118. export * from "babylonjs/Sprites/spriteManager";
  57119. export * from "babylonjs/Sprites/spriteSceneComponent";
  57120. }
  57121. declare module "babylonjs/Misc/assetsManager" {
  57122. import { Scene } from "babylonjs/scene";
  57123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57124. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57125. import { Skeleton } from "babylonjs/Bones/skeleton";
  57126. import { Observable } from "babylonjs/Misc/observable";
  57127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57128. import { Texture } from "babylonjs/Materials/Textures/texture";
  57129. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57130. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57131. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57132. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57133. /**
  57134. * Defines the list of states available for a task inside a AssetsManager
  57135. */
  57136. export enum AssetTaskState {
  57137. /**
  57138. * Initialization
  57139. */
  57140. INIT = 0,
  57141. /**
  57142. * Running
  57143. */
  57144. RUNNING = 1,
  57145. /**
  57146. * Done
  57147. */
  57148. DONE = 2,
  57149. /**
  57150. * Error
  57151. */
  57152. ERROR = 3
  57153. }
  57154. /**
  57155. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57156. */
  57157. export abstract class AbstractAssetTask {
  57158. /**
  57159. * Task name
  57160. */ name: string;
  57161. /**
  57162. * Callback called when the task is successful
  57163. */
  57164. onSuccess: (task: any) => void;
  57165. /**
  57166. * Callback called when the task is not successful
  57167. */
  57168. onError: (task: any, message?: string, exception?: any) => void;
  57169. /**
  57170. * Creates a new AssetsManager
  57171. * @param name defines the name of the task
  57172. */
  57173. constructor(
  57174. /**
  57175. * Task name
  57176. */ name: string);
  57177. private _isCompleted;
  57178. private _taskState;
  57179. private _errorObject;
  57180. /**
  57181. * Get if the task is completed
  57182. */
  57183. readonly isCompleted: boolean;
  57184. /**
  57185. * Gets the current state of the task
  57186. */
  57187. readonly taskState: AssetTaskState;
  57188. /**
  57189. * Gets the current error object (if task is in error)
  57190. */
  57191. readonly errorObject: {
  57192. message?: string;
  57193. exception?: any;
  57194. };
  57195. /**
  57196. * Internal only
  57197. * @hidden
  57198. */
  57199. _setErrorObject(message?: string, exception?: any): void;
  57200. /**
  57201. * Execute the current task
  57202. * @param scene defines the scene where you want your assets to be loaded
  57203. * @param onSuccess is a callback called when the task is successfully executed
  57204. * @param onError is a callback called if an error occurs
  57205. */
  57206. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57207. /**
  57208. * Execute the current task
  57209. * @param scene defines the scene where you want your assets to be loaded
  57210. * @param onSuccess is a callback called when the task is successfully executed
  57211. * @param onError is a callback called if an error occurs
  57212. */
  57213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57214. /**
  57215. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57216. * This can be used with failed tasks that have the reason for failure fixed.
  57217. */
  57218. reset(): void;
  57219. private onErrorCallback;
  57220. private onDoneCallback;
  57221. }
  57222. /**
  57223. * Define the interface used by progress events raised during assets loading
  57224. */
  57225. export interface IAssetsProgressEvent {
  57226. /**
  57227. * Defines the number of remaining tasks to process
  57228. */
  57229. remainingCount: number;
  57230. /**
  57231. * Defines the total number of tasks
  57232. */
  57233. totalCount: number;
  57234. /**
  57235. * Defines the task that was just processed
  57236. */
  57237. task: AbstractAssetTask;
  57238. }
  57239. /**
  57240. * Class used to share progress information about assets loading
  57241. */
  57242. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57243. /**
  57244. * Defines the number of remaining tasks to process
  57245. */
  57246. remainingCount: number;
  57247. /**
  57248. * Defines the total number of tasks
  57249. */
  57250. totalCount: number;
  57251. /**
  57252. * Defines the task that was just processed
  57253. */
  57254. task: AbstractAssetTask;
  57255. /**
  57256. * Creates a AssetsProgressEvent
  57257. * @param remainingCount defines the number of remaining tasks to process
  57258. * @param totalCount defines the total number of tasks
  57259. * @param task defines the task that was just processed
  57260. */
  57261. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57262. }
  57263. /**
  57264. * Define a task used by AssetsManager to load meshes
  57265. */
  57266. export class MeshAssetTask extends AbstractAssetTask {
  57267. /**
  57268. * Defines the name of the task
  57269. */
  57270. name: string;
  57271. /**
  57272. * Defines the list of mesh's names you want to load
  57273. */
  57274. meshesNames: any;
  57275. /**
  57276. * Defines the root url to use as a base to load your meshes and associated resources
  57277. */
  57278. rootUrl: string;
  57279. /**
  57280. * Defines the filename of the scene to load from
  57281. */
  57282. sceneFilename: string;
  57283. /**
  57284. * Gets the list of loaded meshes
  57285. */
  57286. loadedMeshes: Array<AbstractMesh>;
  57287. /**
  57288. * Gets the list of loaded particle systems
  57289. */
  57290. loadedParticleSystems: Array<IParticleSystem>;
  57291. /**
  57292. * Gets the list of loaded skeletons
  57293. */
  57294. loadedSkeletons: Array<Skeleton>;
  57295. /**
  57296. * Gets the list of loaded animation groups
  57297. */
  57298. loadedAnimationGroups: Array<AnimationGroup>;
  57299. /**
  57300. * Callback called when the task is successful
  57301. */
  57302. onSuccess: (task: MeshAssetTask) => void;
  57303. /**
  57304. * Callback called when the task is successful
  57305. */
  57306. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57307. /**
  57308. * Creates a new MeshAssetTask
  57309. * @param name defines the name of the task
  57310. * @param meshesNames defines the list of mesh's names you want to load
  57311. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57312. * @param sceneFilename defines the filename of the scene to load from
  57313. */
  57314. constructor(
  57315. /**
  57316. * Defines the name of the task
  57317. */
  57318. name: string,
  57319. /**
  57320. * Defines the list of mesh's names you want to load
  57321. */
  57322. meshesNames: any,
  57323. /**
  57324. * Defines the root url to use as a base to load your meshes and associated resources
  57325. */
  57326. rootUrl: string,
  57327. /**
  57328. * Defines the filename of the scene to load from
  57329. */
  57330. sceneFilename: string);
  57331. /**
  57332. * Execute the current task
  57333. * @param scene defines the scene where you want your assets to be loaded
  57334. * @param onSuccess is a callback called when the task is successfully executed
  57335. * @param onError is a callback called if an error occurs
  57336. */
  57337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57338. }
  57339. /**
  57340. * Define a task used by AssetsManager to load text content
  57341. */
  57342. export class TextFileAssetTask extends AbstractAssetTask {
  57343. /**
  57344. * Defines the name of the task
  57345. */
  57346. name: string;
  57347. /**
  57348. * Defines the location of the file to load
  57349. */
  57350. url: string;
  57351. /**
  57352. * Gets the loaded text string
  57353. */
  57354. text: string;
  57355. /**
  57356. * Callback called when the task is successful
  57357. */
  57358. onSuccess: (task: TextFileAssetTask) => void;
  57359. /**
  57360. * Callback called when the task is successful
  57361. */
  57362. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57363. /**
  57364. * Creates a new TextFileAssetTask object
  57365. * @param name defines the name of the task
  57366. * @param url defines the location of the file to load
  57367. */
  57368. constructor(
  57369. /**
  57370. * Defines the name of the task
  57371. */
  57372. name: string,
  57373. /**
  57374. * Defines the location of the file to load
  57375. */
  57376. url: string);
  57377. /**
  57378. * Execute the current task
  57379. * @param scene defines the scene where you want your assets to be loaded
  57380. * @param onSuccess is a callback called when the task is successfully executed
  57381. * @param onError is a callback called if an error occurs
  57382. */
  57383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57384. }
  57385. /**
  57386. * Define a task used by AssetsManager to load binary data
  57387. */
  57388. export class BinaryFileAssetTask extends AbstractAssetTask {
  57389. /**
  57390. * Defines the name of the task
  57391. */
  57392. name: string;
  57393. /**
  57394. * Defines the location of the file to load
  57395. */
  57396. url: string;
  57397. /**
  57398. * Gets the lodaded data (as an array buffer)
  57399. */
  57400. data: ArrayBuffer;
  57401. /**
  57402. * Callback called when the task is successful
  57403. */
  57404. onSuccess: (task: BinaryFileAssetTask) => void;
  57405. /**
  57406. * Callback called when the task is successful
  57407. */
  57408. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57409. /**
  57410. * Creates a new BinaryFileAssetTask object
  57411. * @param name defines the name of the new task
  57412. * @param url defines the location of the file to load
  57413. */
  57414. constructor(
  57415. /**
  57416. * Defines the name of the task
  57417. */
  57418. name: string,
  57419. /**
  57420. * Defines the location of the file to load
  57421. */
  57422. url: string);
  57423. /**
  57424. * Execute the current task
  57425. * @param scene defines the scene where you want your assets to be loaded
  57426. * @param onSuccess is a callback called when the task is successfully executed
  57427. * @param onError is a callback called if an error occurs
  57428. */
  57429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57430. }
  57431. /**
  57432. * Define a task used by AssetsManager to load images
  57433. */
  57434. export class ImageAssetTask extends AbstractAssetTask {
  57435. /**
  57436. * Defines the name of the task
  57437. */
  57438. name: string;
  57439. /**
  57440. * Defines the location of the image to load
  57441. */
  57442. url: string;
  57443. /**
  57444. * Gets the loaded images
  57445. */
  57446. image: HTMLImageElement;
  57447. /**
  57448. * Callback called when the task is successful
  57449. */
  57450. onSuccess: (task: ImageAssetTask) => void;
  57451. /**
  57452. * Callback called when the task is successful
  57453. */
  57454. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57455. /**
  57456. * Creates a new ImageAssetTask
  57457. * @param name defines the name of the task
  57458. * @param url defines the location of the image to load
  57459. */
  57460. constructor(
  57461. /**
  57462. * Defines the name of the task
  57463. */
  57464. name: string,
  57465. /**
  57466. * Defines the location of the image to load
  57467. */
  57468. url: string);
  57469. /**
  57470. * Execute the current task
  57471. * @param scene defines the scene where you want your assets to be loaded
  57472. * @param onSuccess is a callback called when the task is successfully executed
  57473. * @param onError is a callback called if an error occurs
  57474. */
  57475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57476. }
  57477. /**
  57478. * Defines the interface used by texture loading tasks
  57479. */
  57480. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57481. /**
  57482. * Gets the loaded texture
  57483. */
  57484. texture: TEX;
  57485. }
  57486. /**
  57487. * Define a task used by AssetsManager to load 2D textures
  57488. */
  57489. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57490. /**
  57491. * Defines the name of the task
  57492. */
  57493. name: string;
  57494. /**
  57495. * Defines the location of the file to load
  57496. */
  57497. url: string;
  57498. /**
  57499. * Defines if mipmap should not be generated (default is false)
  57500. */
  57501. noMipmap?: boolean | undefined;
  57502. /**
  57503. * Defines if texture must be inverted on Y axis (default is false)
  57504. */
  57505. invertY?: boolean | undefined;
  57506. /**
  57507. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57508. */
  57509. samplingMode: number;
  57510. /**
  57511. * Gets the loaded texture
  57512. */
  57513. texture: Texture;
  57514. /**
  57515. * Callback called when the task is successful
  57516. */
  57517. onSuccess: (task: TextureAssetTask) => void;
  57518. /**
  57519. * Callback called when the task is successful
  57520. */
  57521. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57522. /**
  57523. * Creates a new TextureAssetTask object
  57524. * @param name defines the name of the task
  57525. * @param url defines the location of the file to load
  57526. * @param noMipmap defines if mipmap should not be generated (default is false)
  57527. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57528. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57529. */
  57530. constructor(
  57531. /**
  57532. * Defines the name of the task
  57533. */
  57534. name: string,
  57535. /**
  57536. * Defines the location of the file to load
  57537. */
  57538. url: string,
  57539. /**
  57540. * Defines if mipmap should not be generated (default is false)
  57541. */
  57542. noMipmap?: boolean | undefined,
  57543. /**
  57544. * Defines if texture must be inverted on Y axis (default is false)
  57545. */
  57546. invertY?: boolean | undefined,
  57547. /**
  57548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57549. */
  57550. samplingMode?: number);
  57551. /**
  57552. * Execute the current task
  57553. * @param scene defines the scene where you want your assets to be loaded
  57554. * @param onSuccess is a callback called when the task is successfully executed
  57555. * @param onError is a callback called if an error occurs
  57556. */
  57557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57558. }
  57559. /**
  57560. * Define a task used by AssetsManager to load cube textures
  57561. */
  57562. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57563. /**
  57564. * Defines the name of the task
  57565. */
  57566. name: string;
  57567. /**
  57568. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57569. */
  57570. url: string;
  57571. /**
  57572. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57573. */
  57574. extensions?: string[] | undefined;
  57575. /**
  57576. * Defines if mipmaps should not be generated (default is false)
  57577. */
  57578. noMipmap?: boolean | undefined;
  57579. /**
  57580. * Defines the explicit list of files (undefined by default)
  57581. */
  57582. files?: string[] | undefined;
  57583. /**
  57584. * Gets the loaded texture
  57585. */
  57586. texture: CubeTexture;
  57587. /**
  57588. * Callback called when the task is successful
  57589. */
  57590. onSuccess: (task: CubeTextureAssetTask) => void;
  57591. /**
  57592. * Callback called when the task is successful
  57593. */
  57594. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57595. /**
  57596. * Creates a new CubeTextureAssetTask
  57597. * @param name defines the name of the task
  57598. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57599. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57601. * @param files defines the explicit list of files (undefined by default)
  57602. */
  57603. constructor(
  57604. /**
  57605. * Defines the name of the task
  57606. */
  57607. name: string,
  57608. /**
  57609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57610. */
  57611. url: string,
  57612. /**
  57613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57614. */
  57615. extensions?: string[] | undefined,
  57616. /**
  57617. * Defines if mipmaps should not be generated (default is false)
  57618. */
  57619. noMipmap?: boolean | undefined,
  57620. /**
  57621. * Defines the explicit list of files (undefined by default)
  57622. */
  57623. files?: string[] | undefined);
  57624. /**
  57625. * Execute the current task
  57626. * @param scene defines the scene where you want your assets to be loaded
  57627. * @param onSuccess is a callback called when the task is successfully executed
  57628. * @param onError is a callback called if an error occurs
  57629. */
  57630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57631. }
  57632. /**
  57633. * Define a task used by AssetsManager to load HDR cube textures
  57634. */
  57635. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57636. /**
  57637. * Defines the name of the task
  57638. */
  57639. name: string;
  57640. /**
  57641. * Defines the location of the file to load
  57642. */
  57643. url: string;
  57644. /**
  57645. * Defines the desired size (the more it increases the longer the generation will be)
  57646. */
  57647. size: number;
  57648. /**
  57649. * Defines if mipmaps should not be generated (default is false)
  57650. */
  57651. noMipmap: boolean;
  57652. /**
  57653. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57654. */
  57655. generateHarmonics: boolean;
  57656. /**
  57657. * 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)
  57658. */
  57659. gammaSpace: boolean;
  57660. /**
  57661. * Internal Use Only
  57662. */
  57663. reserved: boolean;
  57664. /**
  57665. * Gets the loaded texture
  57666. */
  57667. texture: HDRCubeTexture;
  57668. /**
  57669. * Callback called when the task is successful
  57670. */
  57671. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57672. /**
  57673. * Callback called when the task is successful
  57674. */
  57675. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57676. /**
  57677. * Creates a new HDRCubeTextureAssetTask object
  57678. * @param name defines the name of the task
  57679. * @param url defines the location of the file to load
  57680. * @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.
  57681. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57682. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57683. * @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)
  57684. * @param reserved Internal use only
  57685. */
  57686. constructor(
  57687. /**
  57688. * Defines the name of the task
  57689. */
  57690. name: string,
  57691. /**
  57692. * Defines the location of the file to load
  57693. */
  57694. url: string,
  57695. /**
  57696. * Defines the desired size (the more it increases the longer the generation will be)
  57697. */
  57698. size: number,
  57699. /**
  57700. * Defines if mipmaps should not be generated (default is false)
  57701. */
  57702. noMipmap?: boolean,
  57703. /**
  57704. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57705. */
  57706. generateHarmonics?: boolean,
  57707. /**
  57708. * 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)
  57709. */
  57710. gammaSpace?: boolean,
  57711. /**
  57712. * Internal Use Only
  57713. */
  57714. reserved?: boolean);
  57715. /**
  57716. * Execute the current task
  57717. * @param scene defines the scene where you want your assets to be loaded
  57718. * @param onSuccess is a callback called when the task is successfully executed
  57719. * @param onError is a callback called if an error occurs
  57720. */
  57721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57722. }
  57723. /**
  57724. * Define a task used by AssetsManager to load Equirectangular cube textures
  57725. */
  57726. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57727. /**
  57728. * Defines the name of the task
  57729. */
  57730. name: string;
  57731. /**
  57732. * Defines the location of the file to load
  57733. */
  57734. url: string;
  57735. /**
  57736. * Defines the desired size (the more it increases the longer the generation will be)
  57737. */
  57738. size: number;
  57739. /**
  57740. * Defines if mipmaps should not be generated (default is false)
  57741. */
  57742. noMipmap: boolean;
  57743. /**
  57744. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57745. * but the standard material would require them in Gamma space) (default is true)
  57746. */
  57747. gammaSpace: boolean;
  57748. /**
  57749. * Gets the loaded texture
  57750. */
  57751. texture: EquiRectangularCubeTexture;
  57752. /**
  57753. * Callback called when the task is successful
  57754. */
  57755. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57756. /**
  57757. * Callback called when the task is successful
  57758. */
  57759. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57760. /**
  57761. * Creates a new EquiRectangularCubeTextureAssetTask object
  57762. * @param name defines the name of the task
  57763. * @param url defines the location of the file to load
  57764. * @param size defines the desired size (the more it increases the longer the generation will be)
  57765. * If the size is omitted this implies you are using a preprocessed cubemap.
  57766. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57767. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57768. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57769. * (default is true)
  57770. */
  57771. constructor(
  57772. /**
  57773. * Defines the name of the task
  57774. */
  57775. name: string,
  57776. /**
  57777. * Defines the location of the file to load
  57778. */
  57779. url: string,
  57780. /**
  57781. * Defines the desired size (the more it increases the longer the generation will be)
  57782. */
  57783. size: number,
  57784. /**
  57785. * Defines if mipmaps should not be generated (default is false)
  57786. */
  57787. noMipmap?: boolean,
  57788. /**
  57789. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57790. * but the standard material would require them in Gamma space) (default is true)
  57791. */
  57792. gammaSpace?: boolean);
  57793. /**
  57794. * Execute the current task
  57795. * @param scene defines the scene where you want your assets to be loaded
  57796. * @param onSuccess is a callback called when the task is successfully executed
  57797. * @param onError is a callback called if an error occurs
  57798. */
  57799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57800. }
  57801. /**
  57802. * This class can be used to easily import assets into a scene
  57803. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57804. */
  57805. export class AssetsManager {
  57806. private _scene;
  57807. private _isLoading;
  57808. protected _tasks: AbstractAssetTask[];
  57809. protected _waitingTasksCount: number;
  57810. protected _totalTasksCount: number;
  57811. /**
  57812. * Callback called when all tasks are processed
  57813. */
  57814. onFinish: (tasks: AbstractAssetTask[]) => void;
  57815. /**
  57816. * Callback called when a task is successful
  57817. */
  57818. onTaskSuccess: (task: AbstractAssetTask) => void;
  57819. /**
  57820. * Callback called when a task had an error
  57821. */
  57822. onTaskError: (task: AbstractAssetTask) => void;
  57823. /**
  57824. * Callback called when a task is done (whatever the result is)
  57825. */
  57826. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57827. /**
  57828. * Observable called when all tasks are processed
  57829. */
  57830. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57831. /**
  57832. * Observable called when a task had an error
  57833. */
  57834. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57835. /**
  57836. * Observable called when all tasks were executed
  57837. */
  57838. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57839. /**
  57840. * Observable called when a task is done (whatever the result is)
  57841. */
  57842. onProgressObservable: Observable<IAssetsProgressEvent>;
  57843. /**
  57844. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57846. */
  57847. useDefaultLoadingScreen: boolean;
  57848. /**
  57849. * Creates a new AssetsManager
  57850. * @param scene defines the scene to work on
  57851. */
  57852. constructor(scene: Scene);
  57853. /**
  57854. * Add a MeshAssetTask to the list of active tasks
  57855. * @param taskName defines the name of the new task
  57856. * @param meshesNames defines the name of meshes to load
  57857. * @param rootUrl defines the root url to use to locate files
  57858. * @param sceneFilename defines the filename of the scene file
  57859. * @returns a new MeshAssetTask object
  57860. */
  57861. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57862. /**
  57863. * Add a TextFileAssetTask to the list of active tasks
  57864. * @param taskName defines the name of the new task
  57865. * @param url defines the url of the file to load
  57866. * @returns a new TextFileAssetTask object
  57867. */
  57868. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57869. /**
  57870. * Add a BinaryFileAssetTask to the list of active tasks
  57871. * @param taskName defines the name of the new task
  57872. * @param url defines the url of the file to load
  57873. * @returns a new BinaryFileAssetTask object
  57874. */
  57875. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57876. /**
  57877. * Add a ImageAssetTask to the list of active tasks
  57878. * @param taskName defines the name of the new task
  57879. * @param url defines the url of the file to load
  57880. * @returns a new ImageAssetTask object
  57881. */
  57882. addImageTask(taskName: string, url: string): ImageAssetTask;
  57883. /**
  57884. * Add a TextureAssetTask to the list of active tasks
  57885. * @param taskName defines the name of the new task
  57886. * @param url defines the url of the file to load
  57887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57888. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57889. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57890. * @returns a new TextureAssetTask object
  57891. */
  57892. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57893. /**
  57894. * Add a CubeTextureAssetTask to the list of active tasks
  57895. * @param taskName defines the name of the new task
  57896. * @param url defines the url of the file to load
  57897. * @param extensions defines the extension to use to load the cube map (can be null)
  57898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57899. * @param files defines the list of files to load (can be null)
  57900. * @returns a new CubeTextureAssetTask object
  57901. */
  57902. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57903. /**
  57904. *
  57905. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57906. * @param taskName defines the name of the new task
  57907. * @param url defines the url of the file to load
  57908. * @param size defines the size you want for the cubemap (can be null)
  57909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57910. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57911. * @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)
  57912. * @param reserved Internal use only
  57913. * @returns a new HDRCubeTextureAssetTask object
  57914. */
  57915. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57916. /**
  57917. *
  57918. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57919. * @param taskName defines the name of the new task
  57920. * @param url defines the url of the file to load
  57921. * @param size defines the size you want for the cubemap (can be null)
  57922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57923. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57924. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57925. * @returns a new EquiRectangularCubeTextureAssetTask object
  57926. */
  57927. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57928. /**
  57929. * Remove a task from the assets manager.
  57930. * @param task the task to remove
  57931. */
  57932. removeTask(task: AbstractAssetTask): void;
  57933. private _decreaseWaitingTasksCount;
  57934. private _runTask;
  57935. /**
  57936. * Reset the AssetsManager and remove all tasks
  57937. * @return the current instance of the AssetsManager
  57938. */
  57939. reset(): AssetsManager;
  57940. /**
  57941. * Start the loading process
  57942. * @return the current instance of the AssetsManager
  57943. */
  57944. load(): AssetsManager;
  57945. /**
  57946. * Start the loading process as an async operation
  57947. * @return a promise returning the list of failed tasks
  57948. */
  57949. loadAsync(): Promise<void>;
  57950. }
  57951. }
  57952. declare module "babylonjs/Misc/deferred" {
  57953. /**
  57954. * Wrapper class for promise with external resolve and reject.
  57955. */
  57956. export class Deferred<T> {
  57957. /**
  57958. * The promise associated with this deferred object.
  57959. */
  57960. readonly promise: Promise<T>;
  57961. private _resolve;
  57962. private _reject;
  57963. /**
  57964. * The resolve method of the promise associated with this deferred object.
  57965. */
  57966. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57967. /**
  57968. * The reject method of the promise associated with this deferred object.
  57969. */
  57970. readonly reject: (reason?: any) => void;
  57971. /**
  57972. * Constructor for this deferred object.
  57973. */
  57974. constructor();
  57975. }
  57976. }
  57977. declare module "babylonjs/Misc/meshExploder" {
  57978. import { Mesh } from "babylonjs/Meshes/mesh";
  57979. /**
  57980. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57981. */
  57982. export class MeshExploder {
  57983. private _centerMesh;
  57984. private _meshes;
  57985. private _meshesOrigins;
  57986. private _toCenterVectors;
  57987. private _scaledDirection;
  57988. private _newPosition;
  57989. private _centerPosition;
  57990. /**
  57991. * Explodes meshes from a center mesh.
  57992. * @param meshes The meshes to explode.
  57993. * @param centerMesh The mesh to be center of explosion.
  57994. */
  57995. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57996. private _setCenterMesh;
  57997. /**
  57998. * Get class name
  57999. * @returns "MeshExploder"
  58000. */
  58001. getClassName(): string;
  58002. /**
  58003. * "Exploded meshes"
  58004. * @returns Array of meshes with the centerMesh at index 0.
  58005. */
  58006. getMeshes(): Array<Mesh>;
  58007. /**
  58008. * Explodes meshes giving a specific direction
  58009. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58010. */
  58011. explode(direction?: number): void;
  58012. }
  58013. }
  58014. declare module "babylonjs/Misc/filesInput" {
  58015. import { Engine } from "babylonjs/Engines/engine";
  58016. import { Scene } from "babylonjs/scene";
  58017. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58018. /**
  58019. * Class used to help managing file picking and drag'n'drop
  58020. */
  58021. export class FilesInput {
  58022. /**
  58023. * List of files ready to be loaded
  58024. */
  58025. static readonly FilesToLoad: {
  58026. [key: string]: File;
  58027. };
  58028. /**
  58029. * Callback called when a file is processed
  58030. */
  58031. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58032. private _engine;
  58033. private _currentScene;
  58034. private _sceneLoadedCallback;
  58035. private _progressCallback;
  58036. private _additionalRenderLoopLogicCallback;
  58037. private _textureLoadingCallback;
  58038. private _startingProcessingFilesCallback;
  58039. private _onReloadCallback;
  58040. private _errorCallback;
  58041. private _elementToMonitor;
  58042. private _sceneFileToLoad;
  58043. private _filesToLoad;
  58044. /**
  58045. * Creates a new FilesInput
  58046. * @param engine defines the rendering engine
  58047. * @param scene defines the hosting scene
  58048. * @param sceneLoadedCallback callback called when scene is loaded
  58049. * @param progressCallback callback called to track progress
  58050. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58051. * @param textureLoadingCallback callback called when a texture is loading
  58052. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58053. * @param onReloadCallback callback called when a reload is requested
  58054. * @param errorCallback callback call if an error occurs
  58055. */
  58056. 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);
  58057. private _dragEnterHandler;
  58058. private _dragOverHandler;
  58059. private _dropHandler;
  58060. /**
  58061. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58062. * @param elementToMonitor defines the DOM element to track
  58063. */
  58064. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58065. /**
  58066. * Release all associated resources
  58067. */
  58068. dispose(): void;
  58069. private renderFunction;
  58070. private drag;
  58071. private drop;
  58072. private _traverseFolder;
  58073. private _processFiles;
  58074. /**
  58075. * Load files from a drop event
  58076. * @param event defines the drop event to use as source
  58077. */
  58078. loadFiles(event: any): void;
  58079. private _processReload;
  58080. /**
  58081. * Reload the current scene from the loaded files
  58082. */
  58083. reload(): void;
  58084. }
  58085. }
  58086. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58087. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58088. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58089. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58090. }
  58091. declare module "babylonjs/Misc/sceneOptimizer" {
  58092. import { Scene, IDisposable } from "babylonjs/scene";
  58093. import { Observable } from "babylonjs/Misc/observable";
  58094. /**
  58095. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58097. */
  58098. export class SceneOptimization {
  58099. /**
  58100. * Defines the priority of this optimization (0 by default which means first in the list)
  58101. */
  58102. priority: number;
  58103. /**
  58104. * Gets a string describing the action executed by the current optimization
  58105. * @returns description string
  58106. */
  58107. getDescription(): string;
  58108. /**
  58109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58110. * @param scene defines the current scene where to apply this optimization
  58111. * @param optimizer defines the current optimizer
  58112. * @returns true if everything that can be done was applied
  58113. */
  58114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58115. /**
  58116. * Creates the SceneOptimization object
  58117. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58118. * @param desc defines the description associated with the optimization
  58119. */
  58120. constructor(
  58121. /**
  58122. * Defines the priority of this optimization (0 by default which means first in the list)
  58123. */
  58124. priority?: number);
  58125. }
  58126. /**
  58127. * Defines an optimization used to reduce the size of render target textures
  58128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58129. */
  58130. export class TextureOptimization extends SceneOptimization {
  58131. /**
  58132. * Defines the priority of this optimization (0 by default which means first in the list)
  58133. */
  58134. priority: number;
  58135. /**
  58136. * 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
  58137. */
  58138. maximumSize: number;
  58139. /**
  58140. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58141. */
  58142. step: number;
  58143. /**
  58144. * Gets a string describing the action executed by the current optimization
  58145. * @returns description string
  58146. */
  58147. getDescription(): string;
  58148. /**
  58149. * Creates the TextureOptimization object
  58150. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58151. * @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
  58152. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58153. */
  58154. constructor(
  58155. /**
  58156. * Defines the priority of this optimization (0 by default which means first in the list)
  58157. */
  58158. priority?: number,
  58159. /**
  58160. * 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
  58161. */
  58162. maximumSize?: number,
  58163. /**
  58164. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58165. */
  58166. step?: number);
  58167. /**
  58168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58169. * @param scene defines the current scene where to apply this optimization
  58170. * @param optimizer defines the current optimizer
  58171. * @returns true if everything that can be done was applied
  58172. */
  58173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58174. }
  58175. /**
  58176. * Defines an optimization used to increase or decrease the rendering resolution
  58177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58178. */
  58179. export class HardwareScalingOptimization extends SceneOptimization {
  58180. /**
  58181. * Defines the priority of this optimization (0 by default which means first in the list)
  58182. */
  58183. priority: number;
  58184. /**
  58185. * Defines the maximum scale to use (2 by default)
  58186. */
  58187. maximumScale: number;
  58188. /**
  58189. * Defines the step to use between two passes (0.5 by default)
  58190. */
  58191. step: number;
  58192. private _currentScale;
  58193. private _directionOffset;
  58194. /**
  58195. * Gets a string describing the action executed by the current optimization
  58196. * @return description string
  58197. */
  58198. getDescription(): string;
  58199. /**
  58200. * Creates the HardwareScalingOptimization object
  58201. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58202. * @param maximumScale defines the maximum scale to use (2 by default)
  58203. * @param step defines the step to use between two passes (0.5 by default)
  58204. */
  58205. constructor(
  58206. /**
  58207. * Defines the priority of this optimization (0 by default which means first in the list)
  58208. */
  58209. priority?: number,
  58210. /**
  58211. * Defines the maximum scale to use (2 by default)
  58212. */
  58213. maximumScale?: number,
  58214. /**
  58215. * Defines the step to use between two passes (0.5 by default)
  58216. */
  58217. step?: number);
  58218. /**
  58219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58220. * @param scene defines the current scene where to apply this optimization
  58221. * @param optimizer defines the current optimizer
  58222. * @returns true if everything that can be done was applied
  58223. */
  58224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58225. }
  58226. /**
  58227. * Defines an optimization used to remove shadows
  58228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58229. */
  58230. export class ShadowsOptimization extends SceneOptimization {
  58231. /**
  58232. * Gets a string describing the action executed by the current optimization
  58233. * @return description string
  58234. */
  58235. getDescription(): string;
  58236. /**
  58237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58238. * @param scene defines the current scene where to apply this optimization
  58239. * @param optimizer defines the current optimizer
  58240. * @returns true if everything that can be done was applied
  58241. */
  58242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58243. }
  58244. /**
  58245. * Defines an optimization used to turn post-processes off
  58246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58247. */
  58248. export class PostProcessesOptimization extends SceneOptimization {
  58249. /**
  58250. * Gets a string describing the action executed by the current optimization
  58251. * @return description string
  58252. */
  58253. getDescription(): string;
  58254. /**
  58255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58256. * @param scene defines the current scene where to apply this optimization
  58257. * @param optimizer defines the current optimizer
  58258. * @returns true if everything that can be done was applied
  58259. */
  58260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58261. }
  58262. /**
  58263. * Defines an optimization used to turn lens flares off
  58264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58265. */
  58266. export class LensFlaresOptimization extends SceneOptimization {
  58267. /**
  58268. * Gets a string describing the action executed by the current optimization
  58269. * @return description string
  58270. */
  58271. getDescription(): string;
  58272. /**
  58273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58274. * @param scene defines the current scene where to apply this optimization
  58275. * @param optimizer defines the current optimizer
  58276. * @returns true if everything that can be done was applied
  58277. */
  58278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58279. }
  58280. /**
  58281. * Defines an optimization based on user defined callback.
  58282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58283. */
  58284. export class CustomOptimization extends SceneOptimization {
  58285. /**
  58286. * Callback called to apply the custom optimization.
  58287. */
  58288. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58289. /**
  58290. * Callback called to get custom description
  58291. */
  58292. onGetDescription: () => string;
  58293. /**
  58294. * Gets a string describing the action executed by the current optimization
  58295. * @returns description string
  58296. */
  58297. getDescription(): string;
  58298. /**
  58299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58300. * @param scene defines the current scene where to apply this optimization
  58301. * @param optimizer defines the current optimizer
  58302. * @returns true if everything that can be done was applied
  58303. */
  58304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58305. }
  58306. /**
  58307. * Defines an optimization used to turn particles off
  58308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58309. */
  58310. export class ParticlesOptimization extends SceneOptimization {
  58311. /**
  58312. * Gets a string describing the action executed by the current optimization
  58313. * @return description string
  58314. */
  58315. getDescription(): string;
  58316. /**
  58317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58318. * @param scene defines the current scene where to apply this optimization
  58319. * @param optimizer defines the current optimizer
  58320. * @returns true if everything that can be done was applied
  58321. */
  58322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58323. }
  58324. /**
  58325. * Defines an optimization used to turn render targets off
  58326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58327. */
  58328. export class RenderTargetsOptimization extends SceneOptimization {
  58329. /**
  58330. * Gets a string describing the action executed by the current optimization
  58331. * @return description string
  58332. */
  58333. getDescription(): string;
  58334. /**
  58335. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58336. * @param scene defines the current scene where to apply this optimization
  58337. * @param optimizer defines the current optimizer
  58338. * @returns true if everything that can be done was applied
  58339. */
  58340. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58341. }
  58342. /**
  58343. * Defines an optimization used to merge meshes with compatible materials
  58344. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58345. */
  58346. export class MergeMeshesOptimization extends SceneOptimization {
  58347. private static _UpdateSelectionTree;
  58348. /**
  58349. * Gets or sets a boolean which defines if optimization octree has to be updated
  58350. */
  58351. /**
  58352. * Gets or sets a boolean which defines if optimization octree has to be updated
  58353. */
  58354. static UpdateSelectionTree: boolean;
  58355. /**
  58356. * Gets a string describing the action executed by the current optimization
  58357. * @return description string
  58358. */
  58359. getDescription(): string;
  58360. private _canBeMerged;
  58361. /**
  58362. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58363. * @param scene defines the current scene where to apply this optimization
  58364. * @param optimizer defines the current optimizer
  58365. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58366. * @returns true if everything that can be done was applied
  58367. */
  58368. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58369. }
  58370. /**
  58371. * Defines a list of options used by SceneOptimizer
  58372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58373. */
  58374. export class SceneOptimizerOptions {
  58375. /**
  58376. * Defines the target frame rate to reach (60 by default)
  58377. */
  58378. targetFrameRate: number;
  58379. /**
  58380. * Defines the interval between two checkes (2000ms by default)
  58381. */
  58382. trackerDuration: number;
  58383. /**
  58384. * Gets the list of optimizations to apply
  58385. */
  58386. optimizations: SceneOptimization[];
  58387. /**
  58388. * Creates a new list of options used by SceneOptimizer
  58389. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58390. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58391. */
  58392. constructor(
  58393. /**
  58394. * Defines the target frame rate to reach (60 by default)
  58395. */
  58396. targetFrameRate?: number,
  58397. /**
  58398. * Defines the interval between two checkes (2000ms by default)
  58399. */
  58400. trackerDuration?: number);
  58401. /**
  58402. * Add a new optimization
  58403. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58404. * @returns the current SceneOptimizerOptions
  58405. */
  58406. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58407. /**
  58408. * Add a new custom optimization
  58409. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58410. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58411. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58412. * @returns the current SceneOptimizerOptions
  58413. */
  58414. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58415. /**
  58416. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58417. * @param targetFrameRate defines the target frame rate (60 by default)
  58418. * @returns a SceneOptimizerOptions object
  58419. */
  58420. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58421. /**
  58422. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58423. * @param targetFrameRate defines the target frame rate (60 by default)
  58424. * @returns a SceneOptimizerOptions object
  58425. */
  58426. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58427. /**
  58428. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58429. * @param targetFrameRate defines the target frame rate (60 by default)
  58430. * @returns a SceneOptimizerOptions object
  58431. */
  58432. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58433. }
  58434. /**
  58435. * Class used to run optimizations in order to reach a target frame rate
  58436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58437. */
  58438. export class SceneOptimizer implements IDisposable {
  58439. private _isRunning;
  58440. private _options;
  58441. private _scene;
  58442. private _currentPriorityLevel;
  58443. private _targetFrameRate;
  58444. private _trackerDuration;
  58445. private _currentFrameRate;
  58446. private _sceneDisposeObserver;
  58447. private _improvementMode;
  58448. /**
  58449. * Defines an observable called when the optimizer reaches the target frame rate
  58450. */
  58451. onSuccessObservable: Observable<SceneOptimizer>;
  58452. /**
  58453. * Defines an observable called when the optimizer enables an optimization
  58454. */
  58455. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58456. /**
  58457. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58458. */
  58459. onFailureObservable: Observable<SceneOptimizer>;
  58460. /**
  58461. * Gets a boolean indicating if the optimizer is in improvement mode
  58462. */
  58463. readonly isInImprovementMode: boolean;
  58464. /**
  58465. * Gets the current priority level (0 at start)
  58466. */
  58467. readonly currentPriorityLevel: number;
  58468. /**
  58469. * Gets the current frame rate checked by the SceneOptimizer
  58470. */
  58471. readonly currentFrameRate: number;
  58472. /**
  58473. * Gets or sets the current target frame rate (60 by default)
  58474. */
  58475. /**
  58476. * Gets or sets the current target frame rate (60 by default)
  58477. */
  58478. targetFrameRate: number;
  58479. /**
  58480. * Gets or sets the current interval between two checks (every 2000ms by default)
  58481. */
  58482. /**
  58483. * Gets or sets the current interval between two checks (every 2000ms by default)
  58484. */
  58485. trackerDuration: number;
  58486. /**
  58487. * Gets the list of active optimizations
  58488. */
  58489. readonly optimizations: SceneOptimization[];
  58490. /**
  58491. * Creates a new SceneOptimizer
  58492. * @param scene defines the scene to work on
  58493. * @param options defines the options to use with the SceneOptimizer
  58494. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58495. * @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)
  58496. */
  58497. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58498. /**
  58499. * Stops the current optimizer
  58500. */
  58501. stop(): void;
  58502. /**
  58503. * Reset the optimizer to initial step (current priority level = 0)
  58504. */
  58505. reset(): void;
  58506. /**
  58507. * Start the optimizer. By default it will try to reach a specific framerate
  58508. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58509. */
  58510. start(): void;
  58511. private _checkCurrentState;
  58512. /**
  58513. * Release all resources
  58514. */
  58515. dispose(): void;
  58516. /**
  58517. * Helper function to create a SceneOptimizer with one single line of code
  58518. * @param scene defines the scene to work on
  58519. * @param options defines the options to use with the SceneOptimizer
  58520. * @param onSuccess defines a callback to call on success
  58521. * @param onFailure defines a callback to call on failure
  58522. * @returns the new SceneOptimizer object
  58523. */
  58524. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58525. }
  58526. }
  58527. declare module "babylonjs/Misc/sceneSerializer" {
  58528. import { Scene } from "babylonjs/scene";
  58529. /**
  58530. * Class used to serialize a scene into a string
  58531. */
  58532. export class SceneSerializer {
  58533. /**
  58534. * Clear cache used by a previous serialization
  58535. */
  58536. static ClearCache(): void;
  58537. /**
  58538. * Serialize a scene into a JSON compatible object
  58539. * @param scene defines the scene to serialize
  58540. * @returns a JSON compatible object
  58541. */
  58542. static Serialize(scene: Scene): any;
  58543. /**
  58544. * Serialize a mesh into a JSON compatible object
  58545. * @param toSerialize defines the mesh to serialize
  58546. * @param withParents defines if parents must be serialized as well
  58547. * @param withChildren defines if children must be serialized as well
  58548. * @returns a JSON compatible object
  58549. */
  58550. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58551. }
  58552. }
  58553. declare module "babylonjs/Misc/textureTools" {
  58554. import { Texture } from "babylonjs/Materials/Textures/texture";
  58555. /**
  58556. * Class used to host texture specific utilities
  58557. */
  58558. export class TextureTools {
  58559. /**
  58560. * Uses the GPU to create a copy texture rescaled at a given size
  58561. * @param texture Texture to copy from
  58562. * @param width defines the desired width
  58563. * @param height defines the desired height
  58564. * @param useBilinearMode defines if bilinear mode has to be used
  58565. * @return the generated texture
  58566. */
  58567. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58568. }
  58569. }
  58570. declare module "babylonjs/Misc/videoRecorder" {
  58571. import { Nullable } from "babylonjs/types";
  58572. import { Engine } from "babylonjs/Engines/engine";
  58573. /**
  58574. * This represents the different options avilable for the video capture.
  58575. */
  58576. export interface VideoRecorderOptions {
  58577. /** Defines the mime type of the video */
  58578. mimeType: string;
  58579. /** Defines the video the video should be recorded at */
  58580. fps: number;
  58581. /** Defines the chunk size for the recording data */
  58582. recordChunckSize: number;
  58583. /** The audio tracks to attach to the record */
  58584. audioTracks?: MediaStreamTrack[];
  58585. }
  58586. /**
  58587. * This can helps recording videos from BabylonJS.
  58588. * This is based on the available WebRTC functionalities of the browser.
  58589. *
  58590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58591. */
  58592. export class VideoRecorder {
  58593. private static readonly _defaultOptions;
  58594. /**
  58595. * Returns wehther or not the VideoRecorder is available in your browser.
  58596. * @param engine Defines the Babylon Engine to check the support for
  58597. * @returns true if supported otherwise false
  58598. */
  58599. static IsSupported(engine: Engine): boolean;
  58600. private readonly _options;
  58601. private _canvas;
  58602. private _mediaRecorder;
  58603. private _recordedChunks;
  58604. private _fileName;
  58605. private _resolve;
  58606. private _reject;
  58607. /**
  58608. * True wether a recording is already in progress.
  58609. */
  58610. readonly isRecording: boolean;
  58611. /**
  58612. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58613. * a video file.
  58614. * @param engine Defines the BabylonJS Engine you wish to record
  58615. * @param options Defines options that can be used to customized the capture
  58616. */
  58617. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58618. /**
  58619. * Stops the current recording before the default capture timeout passed in the startRecording
  58620. * functions.
  58621. */
  58622. stopRecording(): void;
  58623. /**
  58624. * Starts recording the canvas for a max duration specified in parameters.
  58625. * @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.
  58626. * @param maxDuration Defines the maximum recording time in seconds.
  58627. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58628. * @return a promise callback at the end of the recording with the video data in Blob.
  58629. */
  58630. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58631. /**
  58632. * Releases internal resources used during the recording.
  58633. */
  58634. dispose(): void;
  58635. private _handleDataAvailable;
  58636. private _handleError;
  58637. private _handleStop;
  58638. }
  58639. }
  58640. declare module "babylonjs/Misc/workerPool" {
  58641. import { IDisposable } from "babylonjs/scene";
  58642. /**
  58643. * Helper class to push actions to a pool of workers.
  58644. */
  58645. export class WorkerPool implements IDisposable {
  58646. private _workerInfos;
  58647. private _pendingActions;
  58648. /**
  58649. * Constructor
  58650. * @param workers Array of workers to use for actions
  58651. */
  58652. constructor(workers: Array<Worker>);
  58653. /**
  58654. * Terminates all workers and clears any pending actions.
  58655. */
  58656. dispose(): void;
  58657. /**
  58658. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58659. * pended until a worker has completed its action.
  58660. * @param action The action to perform. Call onComplete when the action is complete.
  58661. */
  58662. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58663. private _execute;
  58664. }
  58665. }
  58666. declare module "babylonjs/Misc/screenshotTools" {
  58667. import { Camera } from "babylonjs/Cameras/camera";
  58668. import { Engine } from "babylonjs/Engines/engine";
  58669. /**
  58670. * Class containing a set of static utilities functions for screenshots
  58671. */
  58672. export class ScreenshotTools {
  58673. /**
  58674. * Captures a screenshot of the current rendering
  58675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58676. * @param engine defines the rendering engine
  58677. * @param camera defines the source camera
  58678. * @param size This parameter can be set to a single number or to an object with the
  58679. * following (optional) properties: precision, width, height. If a single number is passed,
  58680. * it will be used for both width and height. If an object is passed, the screenshot size
  58681. * will be derived from the parameters. The precision property is a multiplier allowing
  58682. * rendering at a higher or lower resolution
  58683. * @param successCallback defines the callback receives a single parameter which contains the
  58684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58685. * src parameter of an <img> to display it
  58686. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58687. * Check your browser for supported MIME types
  58688. */
  58689. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58690. /**
  58691. * Generates an image screenshot from the specified camera.
  58692. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58693. * @param engine The engine to use for rendering
  58694. * @param camera The camera to use for rendering
  58695. * @param size This parameter can be set to a single number or to an object with the
  58696. * following (optional) properties: precision, width, height. If a single number is passed,
  58697. * it will be used for both width and height. If an object is passed, the screenshot size
  58698. * will be derived from the parameters. The precision property is a multiplier allowing
  58699. * rendering at a higher or lower resolution
  58700. * @param successCallback The callback receives a single parameter which contains the
  58701. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58702. * src parameter of an <img> to display it
  58703. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58704. * Check your browser for supported MIME types
  58705. * @param samples Texture samples (default: 1)
  58706. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58707. * @param fileName A name for for the downloaded file.
  58708. */
  58709. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58710. }
  58711. }
  58712. declare module "babylonjs/Misc/index" {
  58713. export * from "babylonjs/Misc/andOrNotEvaluator";
  58714. export * from "babylonjs/Misc/assetsManager";
  58715. export * from "babylonjs/Misc/dds";
  58716. export * from "babylonjs/Misc/decorators";
  58717. export * from "babylonjs/Misc/deferred";
  58718. export * from "babylonjs/Misc/environmentTextureTools";
  58719. export * from "babylonjs/Misc/meshExploder";
  58720. export * from "babylonjs/Misc/filesInput";
  58721. export * from "babylonjs/Misc/HighDynamicRange/index";
  58722. export * from "babylonjs/Misc/khronosTextureContainer";
  58723. export * from "babylonjs/Misc/observable";
  58724. export * from "babylonjs/Misc/performanceMonitor";
  58725. export * from "babylonjs/Misc/promise";
  58726. export * from "babylonjs/Misc/sceneOptimizer";
  58727. export * from "babylonjs/Misc/sceneSerializer";
  58728. export * from "babylonjs/Misc/smartArray";
  58729. export * from "babylonjs/Misc/stringDictionary";
  58730. export * from "babylonjs/Misc/tags";
  58731. export * from "babylonjs/Misc/textureTools";
  58732. export * from "babylonjs/Misc/tga";
  58733. export * from "babylonjs/Misc/tools";
  58734. export * from "babylonjs/Misc/videoRecorder";
  58735. export * from "babylonjs/Misc/virtualJoystick";
  58736. export * from "babylonjs/Misc/workerPool";
  58737. export * from "babylonjs/Misc/logger";
  58738. export * from "babylonjs/Misc/typeStore";
  58739. export * from "babylonjs/Misc/filesInputStore";
  58740. export * from "babylonjs/Misc/deepCopier";
  58741. export * from "babylonjs/Misc/pivotTools";
  58742. export * from "babylonjs/Misc/precisionDate";
  58743. export * from "babylonjs/Misc/screenshotTools";
  58744. export * from "babylonjs/Misc/typeStore";
  58745. export * from "babylonjs/Misc/webRequest";
  58746. export * from "babylonjs/Misc/iInspectable";
  58747. }
  58748. declare module "babylonjs/index" {
  58749. export * from "babylonjs/abstractScene";
  58750. export * from "babylonjs/Actions/index";
  58751. export * from "babylonjs/Animations/index";
  58752. export * from "babylonjs/assetContainer";
  58753. export * from "babylonjs/Audio/index";
  58754. export * from "babylonjs/Behaviors/index";
  58755. export * from "babylonjs/Bones/index";
  58756. export * from "babylonjs/Cameras/index";
  58757. export * from "babylonjs/Collisions/index";
  58758. export * from "babylonjs/Culling/index";
  58759. export * from "babylonjs/Debug/index";
  58760. export * from "babylonjs/Engines/index";
  58761. export * from "babylonjs/Events/index";
  58762. export * from "babylonjs/Gamepads/index";
  58763. export * from "babylonjs/Gizmos/index";
  58764. export * from "babylonjs/Helpers/index";
  58765. export * from "babylonjs/Instrumentation/index";
  58766. export * from "babylonjs/Layers/index";
  58767. export * from "babylonjs/LensFlares/index";
  58768. export * from "babylonjs/Lights/index";
  58769. export * from "babylonjs/Loading/index";
  58770. export * from "babylonjs/Materials/index";
  58771. export * from "babylonjs/Maths/index";
  58772. export * from "babylonjs/Meshes/index";
  58773. export * from "babylonjs/Morph/index";
  58774. export * from "babylonjs/node";
  58775. export * from "babylonjs/Offline/index";
  58776. export * from "babylonjs/Particles/index";
  58777. export * from "babylonjs/Physics/index";
  58778. export * from "babylonjs/PostProcesses/index";
  58779. export * from "babylonjs/Probes/index";
  58780. export * from "babylonjs/Rendering/index";
  58781. export * from "babylonjs/scene";
  58782. export * from "babylonjs/sceneComponent";
  58783. export * from "babylonjs/Sprites/index";
  58784. export * from "babylonjs/States/index";
  58785. export * from "babylonjs/Misc/index";
  58786. export * from "babylonjs/types";
  58787. }
  58788. declare module "babylonjs/Animations/pathCursor" {
  58789. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58790. /**
  58791. * A cursor which tracks a point on a path
  58792. */
  58793. export class PathCursor {
  58794. private path;
  58795. /**
  58796. * Stores path cursor callbacks for when an onchange event is triggered
  58797. */
  58798. private _onchange;
  58799. /**
  58800. * The value of the path cursor
  58801. */
  58802. value: number;
  58803. /**
  58804. * The animation array of the path cursor
  58805. */
  58806. animations: Animation[];
  58807. /**
  58808. * Initializes the path cursor
  58809. * @param path The path to track
  58810. */
  58811. constructor(path: Path2);
  58812. /**
  58813. * Gets the cursor point on the path
  58814. * @returns A point on the path cursor at the cursor location
  58815. */
  58816. getPoint(): Vector3;
  58817. /**
  58818. * Moves the cursor ahead by the step amount
  58819. * @param step The amount to move the cursor forward
  58820. * @returns This path cursor
  58821. */
  58822. moveAhead(step?: number): PathCursor;
  58823. /**
  58824. * Moves the cursor behind by the step amount
  58825. * @param step The amount to move the cursor back
  58826. * @returns This path cursor
  58827. */
  58828. moveBack(step?: number): PathCursor;
  58829. /**
  58830. * Moves the cursor by the step amount
  58831. * If the step amount is greater than one, an exception is thrown
  58832. * @param step The amount to move the cursor
  58833. * @returns This path cursor
  58834. */
  58835. move(step: number): PathCursor;
  58836. /**
  58837. * Ensures that the value is limited between zero and one
  58838. * @returns This path cursor
  58839. */
  58840. private ensureLimits;
  58841. /**
  58842. * Runs onchange callbacks on change (used by the animation engine)
  58843. * @returns This path cursor
  58844. */
  58845. private raiseOnChange;
  58846. /**
  58847. * Executes a function on change
  58848. * @param f A path cursor onchange callback
  58849. * @returns This path cursor
  58850. */
  58851. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58852. }
  58853. }
  58854. declare module "babylonjs/Legacy/legacy" {
  58855. import * as Babylon from "babylonjs/index";
  58856. export * from "babylonjs/index";
  58857. }
  58858. declare module "babylonjs/Shaders/blur.fragment" {
  58859. /** @hidden */
  58860. export var blurPixelShader: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58866. /** @hidden */
  58867. export var bones300Declaration: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58873. /** @hidden */
  58874. export var instances300Declaration: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58880. /** @hidden */
  58881. export var pointCloudVertexDeclaration: {
  58882. name: string;
  58883. shader: string;
  58884. };
  58885. }
  58886. // Mixins
  58887. interface Window {
  58888. mozIndexedDB: IDBFactory;
  58889. webkitIndexedDB: IDBFactory;
  58890. msIndexedDB: IDBFactory;
  58891. webkitURL: typeof URL;
  58892. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58893. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58894. WebGLRenderingContext: WebGLRenderingContext;
  58895. MSGesture: MSGesture;
  58896. CANNON: any;
  58897. AudioContext: AudioContext;
  58898. webkitAudioContext: AudioContext;
  58899. PointerEvent: any;
  58900. Math: Math;
  58901. Uint8Array: Uint8ArrayConstructor;
  58902. Float32Array: Float32ArrayConstructor;
  58903. mozURL: typeof URL;
  58904. msURL: typeof URL;
  58905. VRFrameData: any; // WebVR, from specs 1.1
  58906. DracoDecoderModule: any;
  58907. setImmediate(handler: (...args: any[]) => void): number;
  58908. }
  58909. interface HTMLCanvasElement {
  58910. requestPointerLock(): void;
  58911. msRequestPointerLock?(): void;
  58912. mozRequestPointerLock?(): void;
  58913. webkitRequestPointerLock?(): void;
  58914. /** Track wether a record is in progress */
  58915. isRecording: boolean;
  58916. /** Capture Stream method defined by some browsers */
  58917. captureStream(fps?: number): MediaStream;
  58918. }
  58919. interface CanvasRenderingContext2D {
  58920. msImageSmoothingEnabled: boolean;
  58921. }
  58922. interface MouseEvent {
  58923. mozMovementX: number;
  58924. mozMovementY: number;
  58925. webkitMovementX: number;
  58926. webkitMovementY: number;
  58927. msMovementX: number;
  58928. msMovementY: number;
  58929. }
  58930. interface Navigator {
  58931. mozGetVRDevices: (any: any) => any;
  58932. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58933. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58934. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58935. webkitGetGamepads(): Gamepad[];
  58936. msGetGamepads(): Gamepad[];
  58937. webkitGamepads(): Gamepad[];
  58938. }
  58939. interface HTMLVideoElement {
  58940. mozSrcObject: any;
  58941. }
  58942. interface Math {
  58943. fround(x: number): number;
  58944. imul(a: number, b: number): number;
  58945. }
  58946. interface WebGLProgram {
  58947. context?: WebGLRenderingContext;
  58948. vertexShader?: WebGLShader;
  58949. fragmentShader?: WebGLShader;
  58950. isParallelCompiled: boolean;
  58951. onCompiled?: () => void;
  58952. }
  58953. interface WebGLRenderingContext {
  58954. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58955. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58956. vertexAttribDivisor(index: number, divisor: number): void;
  58957. createVertexArray(): any;
  58958. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58959. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58960. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58961. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58962. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58963. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58964. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58965. // Queries
  58966. createQuery(): WebGLQuery;
  58967. deleteQuery(query: WebGLQuery): void;
  58968. beginQuery(target: number, query: WebGLQuery): void;
  58969. endQuery(target: number): void;
  58970. getQueryParameter(query: WebGLQuery, pname: number): any;
  58971. getQuery(target: number, pname: number): any;
  58972. MAX_SAMPLES: number;
  58973. RGBA8: number;
  58974. READ_FRAMEBUFFER: number;
  58975. DRAW_FRAMEBUFFER: number;
  58976. UNIFORM_BUFFER: number;
  58977. HALF_FLOAT_OES: number;
  58978. RGBA16F: number;
  58979. RGBA32F: number;
  58980. R32F: number;
  58981. RG32F: number;
  58982. RGB32F: number;
  58983. R16F: number;
  58984. RG16F: number;
  58985. RGB16F: number;
  58986. RED: number;
  58987. RG: number;
  58988. R8: number;
  58989. RG8: number;
  58990. UNSIGNED_INT_24_8: number;
  58991. DEPTH24_STENCIL8: number;
  58992. /* Multiple Render Targets */
  58993. drawBuffers(buffers: number[]): void;
  58994. readBuffer(src: number): void;
  58995. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58996. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58997. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58998. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58999. // Occlusion Query
  59000. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59001. ANY_SAMPLES_PASSED: number;
  59002. QUERY_RESULT_AVAILABLE: number;
  59003. QUERY_RESULT: number;
  59004. }
  59005. interface WebGLBuffer {
  59006. references: number;
  59007. capacity: number;
  59008. is32Bits: boolean;
  59009. }
  59010. interface WebGLProgram {
  59011. transformFeedback?: WebGLTransformFeedback | null;
  59012. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59013. }
  59014. interface EXT_disjoint_timer_query {
  59015. QUERY_COUNTER_BITS_EXT: number;
  59016. TIME_ELAPSED_EXT: number;
  59017. TIMESTAMP_EXT: number;
  59018. GPU_DISJOINT_EXT: number;
  59019. QUERY_RESULT_EXT: number;
  59020. QUERY_RESULT_AVAILABLE_EXT: number;
  59021. queryCounterEXT(query: WebGLQuery, target: number): void;
  59022. createQueryEXT(): WebGLQuery;
  59023. beginQueryEXT(target: number, query: WebGLQuery): void;
  59024. endQueryEXT(target: number): void;
  59025. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59026. deleteQueryEXT(query: WebGLQuery): void;
  59027. }
  59028. interface WebGLUniformLocation {
  59029. _currentState: any;
  59030. }
  59031. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59032. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59033. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59034. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59035. interface WebGLRenderingContext {
  59036. readonly RASTERIZER_DISCARD: number;
  59037. readonly DEPTH_COMPONENT24: number;
  59038. readonly TEXTURE_3D: number;
  59039. readonly TEXTURE_2D_ARRAY: number;
  59040. readonly TEXTURE_COMPARE_FUNC: number;
  59041. readonly TEXTURE_COMPARE_MODE: number;
  59042. readonly COMPARE_REF_TO_TEXTURE: number;
  59043. readonly TEXTURE_WRAP_R: number;
  59044. readonly HALF_FLOAT: number;
  59045. readonly RGB8: number;
  59046. readonly RED_INTEGER: number;
  59047. readonly RG_INTEGER: number;
  59048. readonly RGB_INTEGER: number;
  59049. readonly RGBA_INTEGER: number;
  59050. readonly R8_SNORM: number;
  59051. readonly RG8_SNORM: number;
  59052. readonly RGB8_SNORM: number;
  59053. readonly RGBA8_SNORM: number;
  59054. readonly R8I: number;
  59055. readonly RG8I: number;
  59056. readonly RGB8I: number;
  59057. readonly RGBA8I: number;
  59058. readonly R8UI: number;
  59059. readonly RG8UI: number;
  59060. readonly RGB8UI: number;
  59061. readonly RGBA8UI: number;
  59062. readonly R16I: number;
  59063. readonly RG16I: number;
  59064. readonly RGB16I: number;
  59065. readonly RGBA16I: number;
  59066. readonly R16UI: number;
  59067. readonly RG16UI: number;
  59068. readonly RGB16UI: number;
  59069. readonly RGBA16UI: number;
  59070. readonly R32I: number;
  59071. readonly RG32I: number;
  59072. readonly RGB32I: number;
  59073. readonly RGBA32I: number;
  59074. readonly R32UI: number;
  59075. readonly RG32UI: number;
  59076. readonly RGB32UI: number;
  59077. readonly RGBA32UI: number;
  59078. readonly RGB10_A2UI: number;
  59079. readonly R11F_G11F_B10F: number;
  59080. readonly RGB9_E5: number;
  59081. readonly RGB10_A2: number;
  59082. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59083. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59084. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59085. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59086. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59087. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59088. 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;
  59089. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59090. readonly TRANSFORM_FEEDBACK: number;
  59091. readonly INTERLEAVED_ATTRIBS: number;
  59092. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59093. createTransformFeedback(): WebGLTransformFeedback;
  59094. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59095. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59096. beginTransformFeedback(primitiveMode: number): void;
  59097. endTransformFeedback(): void;
  59098. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59099. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59100. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59101. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59102. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59103. }
  59104. interface ImageBitmap {
  59105. readonly width: number;
  59106. readonly height: number;
  59107. close(): void;
  59108. }
  59109. interface WebGLQuery extends WebGLObject {
  59110. }
  59111. declare var WebGLQuery: {
  59112. prototype: WebGLQuery;
  59113. new(): WebGLQuery;
  59114. };
  59115. interface WebGLSampler extends WebGLObject {
  59116. }
  59117. declare var WebGLSampler: {
  59118. prototype: WebGLSampler;
  59119. new(): WebGLSampler;
  59120. };
  59121. interface WebGLSync extends WebGLObject {
  59122. }
  59123. declare var WebGLSync: {
  59124. prototype: WebGLSync;
  59125. new(): WebGLSync;
  59126. };
  59127. interface WebGLTransformFeedback extends WebGLObject {
  59128. }
  59129. declare var WebGLTransformFeedback: {
  59130. prototype: WebGLTransformFeedback;
  59131. new(): WebGLTransformFeedback;
  59132. };
  59133. interface WebGLVertexArrayObject extends WebGLObject {
  59134. }
  59135. declare var WebGLVertexArrayObject: {
  59136. prototype: WebGLVertexArrayObject;
  59137. new(): WebGLVertexArrayObject;
  59138. };
  59139. // Type definitions for WebVR API
  59140. // Project: https://w3c.github.io/webvr/
  59141. // Definitions by: six a <https://github.com/lostfictions>
  59142. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59143. interface VRDisplay extends EventTarget {
  59144. /**
  59145. * Dictionary of capabilities describing the VRDisplay.
  59146. */
  59147. readonly capabilities: VRDisplayCapabilities;
  59148. /**
  59149. * z-depth defining the far plane of the eye view frustum
  59150. * enables mapping of values in the render target depth
  59151. * attachment to scene coordinates. Initially set to 10000.0.
  59152. */
  59153. depthFar: number;
  59154. /**
  59155. * z-depth defining the near plane of the eye view frustum
  59156. * enables mapping of values in the render target depth
  59157. * attachment to scene coordinates. Initially set to 0.01.
  59158. */
  59159. depthNear: number;
  59160. /**
  59161. * An identifier for this distinct VRDisplay. Used as an
  59162. * association point in the Gamepad API.
  59163. */
  59164. readonly displayId: number;
  59165. /**
  59166. * A display name, a user-readable name identifying it.
  59167. */
  59168. readonly displayName: string;
  59169. readonly isConnected: boolean;
  59170. readonly isPresenting: boolean;
  59171. /**
  59172. * If this VRDisplay supports room-scale experiences, the optional
  59173. * stage attribute contains details on the room-scale parameters.
  59174. */
  59175. readonly stageParameters: VRStageParameters | null;
  59176. /**
  59177. * Passing the value returned by `requestAnimationFrame` to
  59178. * `cancelAnimationFrame` will unregister the callback.
  59179. * @param handle Define the hanle of the request to cancel
  59180. */
  59181. cancelAnimationFrame(handle: number): void;
  59182. /**
  59183. * Stops presenting to the VRDisplay.
  59184. * @returns a promise to know when it stopped
  59185. */
  59186. exitPresent(): Promise<void>;
  59187. /**
  59188. * Return the current VREyeParameters for the given eye.
  59189. * @param whichEye Define the eye we want the parameter for
  59190. * @returns the eye parameters
  59191. */
  59192. getEyeParameters(whichEye: string): VREyeParameters;
  59193. /**
  59194. * Populates the passed VRFrameData with the information required to render
  59195. * the current frame.
  59196. * @param frameData Define the data structure to populate
  59197. * @returns true if ok otherwise false
  59198. */
  59199. getFrameData(frameData: VRFrameData): boolean;
  59200. /**
  59201. * Get the layers currently being presented.
  59202. * @returns the list of VR layers
  59203. */
  59204. getLayers(): VRLayer[];
  59205. /**
  59206. * Return a VRPose containing the future predicted pose of the VRDisplay
  59207. * when the current frame will be presented. The value returned will not
  59208. * change until JavaScript has returned control to the browser.
  59209. *
  59210. * The VRPose will contain the position, orientation, velocity,
  59211. * and acceleration of each of these properties.
  59212. * @returns the pose object
  59213. */
  59214. getPose(): VRPose;
  59215. /**
  59216. * Return the current instantaneous pose of the VRDisplay, with no
  59217. * prediction applied.
  59218. * @returns the current instantaneous pose
  59219. */
  59220. getImmediatePose(): VRPose;
  59221. /**
  59222. * The callback passed to `requestAnimationFrame` will be called
  59223. * any time a new frame should be rendered. When the VRDisplay is
  59224. * presenting the callback will be called at the native refresh
  59225. * rate of the HMD. When not presenting this function acts
  59226. * identically to how window.requestAnimationFrame acts. Content should
  59227. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59228. * asynchronously from other displays and at differing refresh rates.
  59229. * @param callback Define the eaction to run next frame
  59230. * @returns the request handle it
  59231. */
  59232. requestAnimationFrame(callback: FrameRequestCallback): number;
  59233. /**
  59234. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59235. * Repeat calls while already presenting will update the VRLayers being displayed.
  59236. * @param layers Define the list of layer to present
  59237. * @returns a promise to know when the request has been fulfilled
  59238. */
  59239. requestPresent(layers: VRLayer[]): Promise<void>;
  59240. /**
  59241. * Reset the pose for this display, treating its current position and
  59242. * orientation as the "origin/zero" values. VRPose.position,
  59243. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59244. * updated when calling resetPose(). This should be called in only
  59245. * sitting-space experiences.
  59246. */
  59247. resetPose(): void;
  59248. /**
  59249. * The VRLayer provided to the VRDisplay will be captured and presented
  59250. * in the HMD. Calling this function has the same effect on the source
  59251. * canvas as any other operation that uses its source image, and canvases
  59252. * created without preserveDrawingBuffer set to true will be cleared.
  59253. * @param pose Define the pose to submit
  59254. */
  59255. submitFrame(pose?: VRPose): void;
  59256. }
  59257. declare var VRDisplay: {
  59258. prototype: VRDisplay;
  59259. new(): VRDisplay;
  59260. };
  59261. interface VRLayer {
  59262. leftBounds?: number[] | Float32Array | null;
  59263. rightBounds?: number[] | Float32Array | null;
  59264. source?: HTMLCanvasElement | null;
  59265. }
  59266. interface VRDisplayCapabilities {
  59267. readonly canPresent: boolean;
  59268. readonly hasExternalDisplay: boolean;
  59269. readonly hasOrientation: boolean;
  59270. readonly hasPosition: boolean;
  59271. readonly maxLayers: number;
  59272. }
  59273. interface VREyeParameters {
  59274. /** @deprecated */
  59275. readonly fieldOfView: VRFieldOfView;
  59276. readonly offset: Float32Array;
  59277. readonly renderHeight: number;
  59278. readonly renderWidth: number;
  59279. }
  59280. interface VRFieldOfView {
  59281. readonly downDegrees: number;
  59282. readonly leftDegrees: number;
  59283. readonly rightDegrees: number;
  59284. readonly upDegrees: number;
  59285. }
  59286. interface VRFrameData {
  59287. readonly leftProjectionMatrix: Float32Array;
  59288. readonly leftViewMatrix: Float32Array;
  59289. readonly pose: VRPose;
  59290. readonly rightProjectionMatrix: Float32Array;
  59291. readonly rightViewMatrix: Float32Array;
  59292. readonly timestamp: number;
  59293. }
  59294. interface VRPose {
  59295. readonly angularAcceleration: Float32Array | null;
  59296. readonly angularVelocity: Float32Array | null;
  59297. readonly linearAcceleration: Float32Array | null;
  59298. readonly linearVelocity: Float32Array | null;
  59299. readonly orientation: Float32Array | null;
  59300. readonly position: Float32Array | null;
  59301. readonly timestamp: number;
  59302. }
  59303. interface VRStageParameters {
  59304. sittingToStandingTransform?: Float32Array;
  59305. sizeX?: number;
  59306. sizeY?: number;
  59307. }
  59308. interface Navigator {
  59309. getVRDisplays(): Promise<VRDisplay[]>;
  59310. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59311. }
  59312. interface Window {
  59313. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59314. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59315. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59316. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59317. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59318. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59319. }
  59320. interface Gamepad {
  59321. readonly displayId: number;
  59322. }
  59323. interface XRDevice {
  59324. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59325. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59326. }
  59327. interface XRSession {
  59328. getInputSources(): Array<any>;
  59329. baseLayer: XRWebGLLayer;
  59330. requestFrameOfReference(type: string): Promise<void>;
  59331. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59332. end(): Promise<void>;
  59333. requestAnimationFrame: Function;
  59334. addEventListener: Function;
  59335. }
  59336. interface XRSessionCreationOptions {
  59337. outputContext?: WebGLRenderingContext | null;
  59338. immersive?: boolean;
  59339. environmentIntegration?: boolean;
  59340. }
  59341. interface XRLayer {
  59342. getViewport: Function;
  59343. framebufferWidth: number;
  59344. framebufferHeight: number;
  59345. }
  59346. interface XRView {
  59347. projectionMatrix: Float32Array;
  59348. }
  59349. interface XRFrame {
  59350. getDevicePose: Function;
  59351. getInputPose: Function;
  59352. views: Array<XRView>;
  59353. baseLayer: XRLayer;
  59354. }
  59355. interface XRFrameOfReference {
  59356. }
  59357. interface XRWebGLLayer extends XRLayer {
  59358. framebuffer: WebGLFramebuffer;
  59359. }
  59360. declare var XRWebGLLayer: {
  59361. prototype: XRWebGLLayer;
  59362. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59363. };
  59364. declare module "babylonjs" {
  59365. export * from "babylonjs/Legacy/legacy";
  59366. }
  59367. declare module BABYLON {
  59368. /** Alias type for value that can be null */
  59369. export type Nullable<T> = T | null;
  59370. /**
  59371. * Alias type for number that are floats
  59372. * @ignorenaming
  59373. */
  59374. export type float = number;
  59375. /**
  59376. * Alias type for number that are doubles.
  59377. * @ignorenaming
  59378. */
  59379. export type double = number;
  59380. /**
  59381. * Alias type for number that are integer
  59382. * @ignorenaming
  59383. */
  59384. export type int = number;
  59385. /** Alias type for number array or Float32Array */
  59386. export type FloatArray = number[] | Float32Array;
  59387. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59388. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59389. /**
  59390. * Alias for types that can be used by a Buffer or VertexBuffer.
  59391. */
  59392. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59393. /**
  59394. * Alias type for primitive types
  59395. * @ignorenaming
  59396. */
  59397. type Primitive = undefined | null | boolean | string | number | Function;
  59398. /**
  59399. * Type modifier to make all the properties of an object Readonly
  59400. */
  59401. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59402. /**
  59403. * Type modifier to make all the properties of an object Readonly recursively
  59404. */
  59405. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59406. /** @hidden */
  59407. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59408. }
  59409. /** @hidden */
  59410. /** @hidden */
  59411. type DeepImmutableObject<T> = {
  59412. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59413. };
  59414. }
  59415. declare module BABYLON {
  59416. /**
  59417. * Class containing a set of static utilities functions for arrays.
  59418. */
  59419. export class ArrayTools {
  59420. /**
  59421. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59422. * @param size the number of element to construct and put in the array
  59423. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59424. * @returns a new array filled with new objects
  59425. */
  59426. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. /**
  59431. * Scalar computation library
  59432. */
  59433. export class Scalar {
  59434. /**
  59435. * Two pi constants convenient for computation.
  59436. */
  59437. static TwoPi: number;
  59438. /**
  59439. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59440. * @param a number
  59441. * @param b number
  59442. * @param epsilon (default = 1.401298E-45)
  59443. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59444. */
  59445. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59446. /**
  59447. * Returns a string : the upper case translation of the number i to hexadecimal.
  59448. * @param i number
  59449. * @returns the upper case translation of the number i to hexadecimal.
  59450. */
  59451. static ToHex(i: number): string;
  59452. /**
  59453. * Returns -1 if value is negative and +1 is value is positive.
  59454. * @param value the value
  59455. * @returns the value itself if it's equal to zero.
  59456. */
  59457. static Sign(value: number): number;
  59458. /**
  59459. * Returns the value itself if it's between min and max.
  59460. * Returns min if the value is lower than min.
  59461. * Returns max if the value is greater than max.
  59462. * @param value the value to clmap
  59463. * @param min the min value to clamp to (default: 0)
  59464. * @param max the max value to clamp to (default: 1)
  59465. * @returns the clamped value
  59466. */
  59467. static Clamp(value: number, min?: number, max?: number): number;
  59468. /**
  59469. * the log2 of value.
  59470. * @param value the value to compute log2 of
  59471. * @returns the log2 of value.
  59472. */
  59473. static Log2(value: number): number;
  59474. /**
  59475. * Loops the value, so that it is never larger than length and never smaller than 0.
  59476. *
  59477. * This is similar to the modulo operator but it works with floating point numbers.
  59478. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59479. * With t = 5 and length = 2.5, the result would be 0.0.
  59480. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59481. * @param value the value
  59482. * @param length the length
  59483. * @returns the looped value
  59484. */
  59485. static Repeat(value: number, length: number): number;
  59486. /**
  59487. * Normalize the value between 0.0 and 1.0 using min and max values
  59488. * @param value value to normalize
  59489. * @param min max to normalize between
  59490. * @param max min to normalize between
  59491. * @returns the normalized value
  59492. */
  59493. static Normalize(value: number, min: number, max: number): number;
  59494. /**
  59495. * Denormalize the value from 0.0 and 1.0 using min and max values
  59496. * @param normalized value to denormalize
  59497. * @param min max to denormalize between
  59498. * @param max min to denormalize between
  59499. * @returns the denormalized value
  59500. */
  59501. static Denormalize(normalized: number, min: number, max: number): number;
  59502. /**
  59503. * Calculates the shortest difference between two given angles given in degrees.
  59504. * @param current current angle in degrees
  59505. * @param target target angle in degrees
  59506. * @returns the delta
  59507. */
  59508. static DeltaAngle(current: number, target: number): number;
  59509. /**
  59510. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59511. * @param tx value
  59512. * @param length length
  59513. * @returns The returned value will move back and forth between 0 and length
  59514. */
  59515. static PingPong(tx: number, length: number): number;
  59516. /**
  59517. * Interpolates between min and max with smoothing at the limits.
  59518. *
  59519. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59520. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59521. * @param from from
  59522. * @param to to
  59523. * @param tx value
  59524. * @returns the smooth stepped value
  59525. */
  59526. static SmoothStep(from: number, to: number, tx: number): number;
  59527. /**
  59528. * Moves a value current towards target.
  59529. *
  59530. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59531. * Negative values of maxDelta pushes the value away from target.
  59532. * @param current current value
  59533. * @param target target value
  59534. * @param maxDelta max distance to move
  59535. * @returns resulting value
  59536. */
  59537. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59538. /**
  59539. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59540. *
  59541. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59542. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59543. * @param current current value
  59544. * @param target target value
  59545. * @param maxDelta max distance to move
  59546. * @returns resulting angle
  59547. */
  59548. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59549. /**
  59550. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59551. * @param start start value
  59552. * @param end target value
  59553. * @param amount amount to lerp between
  59554. * @returns the lerped value
  59555. */
  59556. static Lerp(start: number, end: number, amount: number): number;
  59557. /**
  59558. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59559. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59560. * @param start start value
  59561. * @param end target value
  59562. * @param amount amount to lerp between
  59563. * @returns the lerped value
  59564. */
  59565. static LerpAngle(start: number, end: number, amount: number): number;
  59566. /**
  59567. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59568. * @param a start value
  59569. * @param b target value
  59570. * @param value value between a and b
  59571. * @returns the inverseLerp value
  59572. */
  59573. static InverseLerp(a: number, b: number, value: number): number;
  59574. /**
  59575. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59576. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59577. * @param value1 spline value
  59578. * @param tangent1 spline value
  59579. * @param value2 spline value
  59580. * @param tangent2 spline value
  59581. * @param amount input value
  59582. * @returns hermite result
  59583. */
  59584. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59585. /**
  59586. * Returns a random float number between and min and max values
  59587. * @param min min value of random
  59588. * @param max max value of random
  59589. * @returns random value
  59590. */
  59591. static RandomRange(min: number, max: number): number;
  59592. /**
  59593. * This function returns percentage of a number in a given range.
  59594. *
  59595. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59596. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59597. * @param number to convert to percentage
  59598. * @param min min range
  59599. * @param max max range
  59600. * @returns the percentage
  59601. */
  59602. static RangeToPercent(number: number, min: number, max: number): number;
  59603. /**
  59604. * This function returns number that corresponds to the percentage in a given range.
  59605. *
  59606. * PercentToRange(0.34,0,100) will return 34.
  59607. * @param percent to convert to number
  59608. * @param min min range
  59609. * @param max max range
  59610. * @returns the number
  59611. */
  59612. static PercentToRange(percent: number, min: number, max: number): number;
  59613. /**
  59614. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59615. * @param angle The angle to normalize in radian.
  59616. * @return The converted angle.
  59617. */
  59618. static NormalizeRadians(angle: number): number;
  59619. }
  59620. }
  59621. declare module BABYLON {
  59622. /**
  59623. * Constant used to convert a value to gamma space
  59624. * @ignorenaming
  59625. */
  59626. export const ToGammaSpace: number;
  59627. /**
  59628. * Constant used to convert a value to linear space
  59629. * @ignorenaming
  59630. */
  59631. export const ToLinearSpace = 2.2;
  59632. /**
  59633. * Constant used to define the minimal number value in Babylon.js
  59634. * @ignorenaming
  59635. */
  59636. export const Epsilon = 0.001;
  59637. /**
  59638. * Class used to hold a RBG color
  59639. */
  59640. export class Color3 {
  59641. /**
  59642. * Defines the red component (between 0 and 1, default is 0)
  59643. */
  59644. r: number;
  59645. /**
  59646. * Defines the green component (between 0 and 1, default is 0)
  59647. */
  59648. g: number;
  59649. /**
  59650. * Defines the blue component (between 0 and 1, default is 0)
  59651. */
  59652. b: number;
  59653. /**
  59654. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59655. * @param r defines the red component (between 0 and 1, default is 0)
  59656. * @param g defines the green component (between 0 and 1, default is 0)
  59657. * @param b defines the blue component (between 0 and 1, default is 0)
  59658. */
  59659. constructor(
  59660. /**
  59661. * Defines the red component (between 0 and 1, default is 0)
  59662. */
  59663. r?: number,
  59664. /**
  59665. * Defines the green component (between 0 and 1, default is 0)
  59666. */
  59667. g?: number,
  59668. /**
  59669. * Defines the blue component (between 0 and 1, default is 0)
  59670. */
  59671. b?: number);
  59672. /**
  59673. * Creates a string with the Color3 current values
  59674. * @returns the string representation of the Color3 object
  59675. */
  59676. toString(): string;
  59677. /**
  59678. * Returns the string "Color3"
  59679. * @returns "Color3"
  59680. */
  59681. getClassName(): string;
  59682. /**
  59683. * Compute the Color3 hash code
  59684. * @returns an unique number that can be used to hash Color3 objects
  59685. */
  59686. getHashCode(): number;
  59687. /**
  59688. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59689. * @param array defines the array where to store the r,g,b components
  59690. * @param index defines an optional index in the target array to define where to start storing values
  59691. * @returns the current Color3 object
  59692. */
  59693. toArray(array: FloatArray, index?: number): Color3;
  59694. /**
  59695. * Returns a new Color4 object from the current Color3 and the given alpha
  59696. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59697. * @returns a new Color4 object
  59698. */
  59699. toColor4(alpha?: number): Color4;
  59700. /**
  59701. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59702. * @returns the new array
  59703. */
  59704. asArray(): number[];
  59705. /**
  59706. * Returns the luminance value
  59707. * @returns a float value
  59708. */
  59709. toLuminance(): number;
  59710. /**
  59711. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59712. * @param otherColor defines the second operand
  59713. * @returns the new Color3 object
  59714. */
  59715. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59716. /**
  59717. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59718. * @param otherColor defines the second operand
  59719. * @param result defines the Color3 object where to store the result
  59720. * @returns the current Color3
  59721. */
  59722. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59723. /**
  59724. * Determines equality between Color3 objects
  59725. * @param otherColor defines the second operand
  59726. * @returns true if the rgb values are equal to the given ones
  59727. */
  59728. equals(otherColor: DeepImmutable<Color3>): boolean;
  59729. /**
  59730. * Determines equality between the current Color3 object and a set of r,b,g values
  59731. * @param r defines the red component to check
  59732. * @param g defines the green component to check
  59733. * @param b defines the blue component to check
  59734. * @returns true if the rgb values are equal to the given ones
  59735. */
  59736. equalsFloats(r: number, g: number, b: number): boolean;
  59737. /**
  59738. * Multiplies in place each rgb value by scale
  59739. * @param scale defines the scaling factor
  59740. * @returns the updated Color3
  59741. */
  59742. scale(scale: number): Color3;
  59743. /**
  59744. * Multiplies the rgb values by scale and stores the result into "result"
  59745. * @param scale defines the scaling factor
  59746. * @param result defines the Color3 object where to store the result
  59747. * @returns the unmodified current Color3
  59748. */
  59749. scaleToRef(scale: number, result: Color3): Color3;
  59750. /**
  59751. * Scale the current Color3 values by a factor and add the result to a given Color3
  59752. * @param scale defines the scale factor
  59753. * @param result defines color to store the result into
  59754. * @returns the unmodified current Color3
  59755. */
  59756. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59757. /**
  59758. * Clamps the rgb values by the min and max values and stores the result into "result"
  59759. * @param min defines minimum clamping value (default is 0)
  59760. * @param max defines maximum clamping value (default is 1)
  59761. * @param result defines color to store the result into
  59762. * @returns the original Color3
  59763. */
  59764. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59765. /**
  59766. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59767. * @param otherColor defines the second operand
  59768. * @returns the new Color3
  59769. */
  59770. add(otherColor: DeepImmutable<Color3>): Color3;
  59771. /**
  59772. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59773. * @param otherColor defines the second operand
  59774. * @param result defines Color3 object to store the result into
  59775. * @returns the unmodified current Color3
  59776. */
  59777. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59778. /**
  59779. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59780. * @param otherColor defines the second operand
  59781. * @returns the new Color3
  59782. */
  59783. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59784. /**
  59785. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59786. * @param otherColor defines the second operand
  59787. * @param result defines Color3 object to store the result into
  59788. * @returns the unmodified current Color3
  59789. */
  59790. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59791. /**
  59792. * Copy the current object
  59793. * @returns a new Color3 copied the current one
  59794. */
  59795. clone(): Color3;
  59796. /**
  59797. * Copies the rgb values from the source in the current Color3
  59798. * @param source defines the source Color3 object
  59799. * @returns the updated Color3 object
  59800. */
  59801. copyFrom(source: DeepImmutable<Color3>): Color3;
  59802. /**
  59803. * Updates the Color3 rgb values from the given floats
  59804. * @param r defines the red component to read from
  59805. * @param g defines the green component to read from
  59806. * @param b defines the blue component to read from
  59807. * @returns the current Color3 object
  59808. */
  59809. copyFromFloats(r: number, g: number, b: number): Color3;
  59810. /**
  59811. * Updates the Color3 rgb values from the given floats
  59812. * @param r defines the red component to read from
  59813. * @param g defines the green component to read from
  59814. * @param b defines the blue component to read from
  59815. * @returns the current Color3 object
  59816. */
  59817. set(r: number, g: number, b: number): Color3;
  59818. /**
  59819. * Compute the Color3 hexadecimal code as a string
  59820. * @returns a string containing the hexadecimal representation of the Color3 object
  59821. */
  59822. toHexString(): string;
  59823. /**
  59824. * Computes a new Color3 converted from the current one to linear space
  59825. * @returns a new Color3 object
  59826. */
  59827. toLinearSpace(): Color3;
  59828. /**
  59829. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59830. * @param convertedColor defines the Color3 object where to store the linear space version
  59831. * @returns the unmodified Color3
  59832. */
  59833. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59834. /**
  59835. * Computes a new Color3 converted from the current one to gamma space
  59836. * @returns a new Color3 object
  59837. */
  59838. toGammaSpace(): Color3;
  59839. /**
  59840. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59841. * @param convertedColor defines the Color3 object where to store the gamma space version
  59842. * @returns the unmodified Color3
  59843. */
  59844. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59845. private static _BlackReadOnly;
  59846. /**
  59847. * Creates a new Color3 from the string containing valid hexadecimal values
  59848. * @param hex defines a string containing valid hexadecimal values
  59849. * @returns a new Color3 object
  59850. */
  59851. static FromHexString(hex: string): Color3;
  59852. /**
  59853. * Creates a new Vector3 from the starting index of the given array
  59854. * @param array defines the source array
  59855. * @param offset defines an offset in the source array
  59856. * @returns a new Color3 object
  59857. */
  59858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59859. /**
  59860. * Creates a new Color3 from integer values (< 256)
  59861. * @param r defines the red component to read from (value between 0 and 255)
  59862. * @param g defines the green component to read from (value between 0 and 255)
  59863. * @param b defines the blue component to read from (value between 0 and 255)
  59864. * @returns a new Color3 object
  59865. */
  59866. static FromInts(r: number, g: number, b: number): Color3;
  59867. /**
  59868. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59869. * @param start defines the start Color3 value
  59870. * @param end defines the end Color3 value
  59871. * @param amount defines the gradient value between start and end
  59872. * @returns a new Color3 object
  59873. */
  59874. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59875. /**
  59876. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59877. * @param left defines the start value
  59878. * @param right defines the end value
  59879. * @param amount defines the gradient factor
  59880. * @param result defines the Color3 object where to store the result
  59881. */
  59882. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59883. /**
  59884. * Returns a Color3 value containing a red color
  59885. * @returns a new Color3 object
  59886. */
  59887. static Red(): Color3;
  59888. /**
  59889. * Returns a Color3 value containing a green color
  59890. * @returns a new Color3 object
  59891. */
  59892. static Green(): Color3;
  59893. /**
  59894. * Returns a Color3 value containing a blue color
  59895. * @returns a new Color3 object
  59896. */
  59897. static Blue(): Color3;
  59898. /**
  59899. * Returns a Color3 value containing a black color
  59900. * @returns a new Color3 object
  59901. */
  59902. static Black(): Color3;
  59903. /**
  59904. * Gets a Color3 value containing a black color that must not be updated
  59905. */
  59906. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59907. /**
  59908. * Returns a Color3 value containing a white color
  59909. * @returns a new Color3 object
  59910. */
  59911. static White(): Color3;
  59912. /**
  59913. * Returns a Color3 value containing a purple color
  59914. * @returns a new Color3 object
  59915. */
  59916. static Purple(): Color3;
  59917. /**
  59918. * Returns a Color3 value containing a magenta color
  59919. * @returns a new Color3 object
  59920. */
  59921. static Magenta(): Color3;
  59922. /**
  59923. * Returns a Color3 value containing a yellow color
  59924. * @returns a new Color3 object
  59925. */
  59926. static Yellow(): Color3;
  59927. /**
  59928. * Returns a Color3 value containing a gray color
  59929. * @returns a new Color3 object
  59930. */
  59931. static Gray(): Color3;
  59932. /**
  59933. * Returns a Color3 value containing a teal color
  59934. * @returns a new Color3 object
  59935. */
  59936. static Teal(): Color3;
  59937. /**
  59938. * Returns a Color3 value containing a random color
  59939. * @returns a new Color3 object
  59940. */
  59941. static Random(): Color3;
  59942. }
  59943. /**
  59944. * Class used to hold a RBGA color
  59945. */
  59946. export class Color4 {
  59947. /**
  59948. * Defines the red component (between 0 and 1, default is 0)
  59949. */
  59950. r: number;
  59951. /**
  59952. * Defines the green component (between 0 and 1, default is 0)
  59953. */
  59954. g: number;
  59955. /**
  59956. * Defines the blue component (between 0 and 1, default is 0)
  59957. */
  59958. b: number;
  59959. /**
  59960. * Defines the alpha component (between 0 and 1, default is 1)
  59961. */
  59962. a: number;
  59963. /**
  59964. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59965. * @param r defines the red component (between 0 and 1, default is 0)
  59966. * @param g defines the green component (between 0 and 1, default is 0)
  59967. * @param b defines the blue component (between 0 and 1, default is 0)
  59968. * @param a defines the alpha component (between 0 and 1, default is 1)
  59969. */
  59970. constructor(
  59971. /**
  59972. * Defines the red component (between 0 and 1, default is 0)
  59973. */
  59974. r?: number,
  59975. /**
  59976. * Defines the green component (between 0 and 1, default is 0)
  59977. */
  59978. g?: number,
  59979. /**
  59980. * Defines the blue component (between 0 and 1, default is 0)
  59981. */
  59982. b?: number,
  59983. /**
  59984. * Defines the alpha component (between 0 and 1, default is 1)
  59985. */
  59986. a?: number);
  59987. /**
  59988. * Adds in place the given Color4 values to the current Color4 object
  59989. * @param right defines the second operand
  59990. * @returns the current updated Color4 object
  59991. */
  59992. addInPlace(right: DeepImmutable<Color4>): Color4;
  59993. /**
  59994. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59995. * @returns the new array
  59996. */
  59997. asArray(): number[];
  59998. /**
  59999. * Stores from the starting index in the given array the Color4 successive values
  60000. * @param array defines the array where to store the r,g,b components
  60001. * @param index defines an optional index in the target array to define where to start storing values
  60002. * @returns the current Color4 object
  60003. */
  60004. toArray(array: number[], index?: number): Color4;
  60005. /**
  60006. * Determines equality between Color4 objects
  60007. * @param otherColor defines the second operand
  60008. * @returns true if the rgba values are equal to the given ones
  60009. */
  60010. equals(otherColor: DeepImmutable<Color4>): boolean;
  60011. /**
  60012. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60013. * @param right defines the second operand
  60014. * @returns a new Color4 object
  60015. */
  60016. add(right: DeepImmutable<Color4>): Color4;
  60017. /**
  60018. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60019. * @param right defines the second operand
  60020. * @returns a new Color4 object
  60021. */
  60022. subtract(right: DeepImmutable<Color4>): Color4;
  60023. /**
  60024. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60025. * @param right defines the second operand
  60026. * @param result defines the Color4 object where to store the result
  60027. * @returns the current Color4 object
  60028. */
  60029. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60030. /**
  60031. * Creates a new Color4 with the current Color4 values multiplied by scale
  60032. * @param scale defines the scaling factor to apply
  60033. * @returns a new Color4 object
  60034. */
  60035. scale(scale: number): Color4;
  60036. /**
  60037. * Multiplies the current Color4 values by scale and stores the result in "result"
  60038. * @param scale defines the scaling factor to apply
  60039. * @param result defines the Color4 object where to store the result
  60040. * @returns the current unmodified Color4
  60041. */
  60042. scaleToRef(scale: number, result: Color4): Color4;
  60043. /**
  60044. * Scale the current Color4 values by a factor and add the result to a given Color4
  60045. * @param scale defines the scale factor
  60046. * @param result defines the Color4 object where to store the result
  60047. * @returns the unmodified current Color4
  60048. */
  60049. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60050. /**
  60051. * Clamps the rgb values by the min and max values and stores the result into "result"
  60052. * @param min defines minimum clamping value (default is 0)
  60053. * @param max defines maximum clamping value (default is 1)
  60054. * @param result defines color to store the result into.
  60055. * @returns the cuurent Color4
  60056. */
  60057. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60058. /**
  60059. * Multipy an Color4 value by another and return a new Color4 object
  60060. * @param color defines the Color4 value to multiply by
  60061. * @returns a new Color4 object
  60062. */
  60063. multiply(color: Color4): Color4;
  60064. /**
  60065. * Multipy a Color4 value by another and push the result in a reference value
  60066. * @param color defines the Color4 value to multiply by
  60067. * @param result defines the Color4 to fill the result in
  60068. * @returns the result Color4
  60069. */
  60070. multiplyToRef(color: Color4, result: Color4): Color4;
  60071. /**
  60072. * Creates a string with the Color4 current values
  60073. * @returns the string representation of the Color4 object
  60074. */
  60075. toString(): string;
  60076. /**
  60077. * Returns the string "Color4"
  60078. * @returns "Color4"
  60079. */
  60080. getClassName(): string;
  60081. /**
  60082. * Compute the Color4 hash code
  60083. * @returns an unique number that can be used to hash Color4 objects
  60084. */
  60085. getHashCode(): number;
  60086. /**
  60087. * Creates a new Color4 copied from the current one
  60088. * @returns a new Color4 object
  60089. */
  60090. clone(): Color4;
  60091. /**
  60092. * Copies the given Color4 values into the current one
  60093. * @param source defines the source Color4 object
  60094. * @returns the current updated Color4 object
  60095. */
  60096. copyFrom(source: Color4): Color4;
  60097. /**
  60098. * Copies the given float values into the current one
  60099. * @param r defines the red component to read from
  60100. * @param g defines the green component to read from
  60101. * @param b defines the blue component to read from
  60102. * @param a defines the alpha component to read from
  60103. * @returns the current updated Color4 object
  60104. */
  60105. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60106. /**
  60107. * Copies the given float values into the current one
  60108. * @param r defines the red component to read from
  60109. * @param g defines the green component to read from
  60110. * @param b defines the blue component to read from
  60111. * @param a defines the alpha component to read from
  60112. * @returns the current updated Color4 object
  60113. */
  60114. set(r: number, g: number, b: number, a: number): Color4;
  60115. /**
  60116. * Compute the Color4 hexadecimal code as a string
  60117. * @returns a string containing the hexadecimal representation of the Color4 object
  60118. */
  60119. toHexString(): string;
  60120. /**
  60121. * Computes a new Color4 converted from the current one to linear space
  60122. * @returns a new Color4 object
  60123. */
  60124. toLinearSpace(): Color4;
  60125. /**
  60126. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60127. * @param convertedColor defines the Color4 object where to store the linear space version
  60128. * @returns the unmodified Color4
  60129. */
  60130. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60131. /**
  60132. * Computes a new Color4 converted from the current one to gamma space
  60133. * @returns a new Color4 object
  60134. */
  60135. toGammaSpace(): Color4;
  60136. /**
  60137. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60138. * @param convertedColor defines the Color4 object where to store the gamma space version
  60139. * @returns the unmodified Color4
  60140. */
  60141. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60142. /**
  60143. * Creates a new Color4 from the string containing valid hexadecimal values
  60144. * @param hex defines a string containing valid hexadecimal values
  60145. * @returns a new Color4 object
  60146. */
  60147. static FromHexString(hex: string): Color4;
  60148. /**
  60149. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60150. * @param left defines the start value
  60151. * @param right defines the end value
  60152. * @param amount defines the gradient factor
  60153. * @returns a new Color4 object
  60154. */
  60155. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60156. /**
  60157. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60158. * @param left defines the start value
  60159. * @param right defines the end value
  60160. * @param amount defines the gradient factor
  60161. * @param result defines the Color4 object where to store data
  60162. */
  60163. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60164. /**
  60165. * Creates a new Color4 from a Color3 and an alpha value
  60166. * @param color3 defines the source Color3 to read from
  60167. * @param alpha defines the alpha component (1.0 by default)
  60168. * @returns a new Color4 object
  60169. */
  60170. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60171. /**
  60172. * Creates a new Color4 from the starting index element of the given array
  60173. * @param array defines the source array to read from
  60174. * @param offset defines the offset in the source array
  60175. * @returns a new Color4 object
  60176. */
  60177. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60178. /**
  60179. * Creates a new Color3 from integer values (< 256)
  60180. * @param r defines the red component to read from (value between 0 and 255)
  60181. * @param g defines the green component to read from (value between 0 and 255)
  60182. * @param b defines the blue component to read from (value between 0 and 255)
  60183. * @param a defines the alpha component to read from (value between 0 and 255)
  60184. * @returns a new Color3 object
  60185. */
  60186. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60187. /**
  60188. * Check the content of a given array and convert it to an array containing RGBA data
  60189. * If the original array was already containing count * 4 values then it is returned directly
  60190. * @param colors defines the array to check
  60191. * @param count defines the number of RGBA data to expect
  60192. * @returns an array containing count * 4 values (RGBA)
  60193. */
  60194. static CheckColors4(colors: number[], count: number): number[];
  60195. }
  60196. /**
  60197. * Class representing a vector containing 2 coordinates
  60198. */
  60199. export class Vector2 {
  60200. /** defines the first coordinate */
  60201. x: number;
  60202. /** defines the second coordinate */
  60203. y: number;
  60204. /**
  60205. * Creates a new Vector2 from the given x and y coordinates
  60206. * @param x defines the first coordinate
  60207. * @param y defines the second coordinate
  60208. */
  60209. constructor(
  60210. /** defines the first coordinate */
  60211. x?: number,
  60212. /** defines the second coordinate */
  60213. y?: number);
  60214. /**
  60215. * Gets a string with the Vector2 coordinates
  60216. * @returns a string with the Vector2 coordinates
  60217. */
  60218. toString(): string;
  60219. /**
  60220. * Gets class name
  60221. * @returns the string "Vector2"
  60222. */
  60223. getClassName(): string;
  60224. /**
  60225. * Gets current vector hash code
  60226. * @returns the Vector2 hash code as a number
  60227. */
  60228. getHashCode(): number;
  60229. /**
  60230. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60231. * @param array defines the source array
  60232. * @param index defines the offset in source array
  60233. * @returns the current Vector2
  60234. */
  60235. toArray(array: FloatArray, index?: number): Vector2;
  60236. /**
  60237. * Copy the current vector to an array
  60238. * @returns a new array with 2 elements: the Vector2 coordinates.
  60239. */
  60240. asArray(): number[];
  60241. /**
  60242. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60243. * @param source defines the source Vector2
  60244. * @returns the current updated Vector2
  60245. */
  60246. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60247. /**
  60248. * Sets the Vector2 coordinates with the given floats
  60249. * @param x defines the first coordinate
  60250. * @param y defines the second coordinate
  60251. * @returns the current updated Vector2
  60252. */
  60253. copyFromFloats(x: number, y: number): Vector2;
  60254. /**
  60255. * Sets the Vector2 coordinates with the given floats
  60256. * @param x defines the first coordinate
  60257. * @param y defines the second coordinate
  60258. * @returns the current updated Vector2
  60259. */
  60260. set(x: number, y: number): Vector2;
  60261. /**
  60262. * Add another vector with the current one
  60263. * @param otherVector defines the other vector
  60264. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60265. */
  60266. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60267. /**
  60268. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60269. * @param otherVector defines the other vector
  60270. * @param result defines the target vector
  60271. * @returns the unmodified current Vector2
  60272. */
  60273. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60274. /**
  60275. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60276. * @param otherVector defines the other vector
  60277. * @returns the current updated Vector2
  60278. */
  60279. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60280. /**
  60281. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60282. * @param otherVector defines the other vector
  60283. * @returns a new Vector2
  60284. */
  60285. addVector3(otherVector: Vector3): Vector2;
  60286. /**
  60287. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60288. * @param otherVector defines the other vector
  60289. * @returns a new Vector2
  60290. */
  60291. subtract(otherVector: Vector2): Vector2;
  60292. /**
  60293. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60294. * @param otherVector defines the other vector
  60295. * @param result defines the target vector
  60296. * @returns the unmodified current Vector2
  60297. */
  60298. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60299. /**
  60300. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60301. * @param otherVector defines the other vector
  60302. * @returns the current updated Vector2
  60303. */
  60304. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60305. /**
  60306. * Multiplies in place the current Vector2 coordinates by the given ones
  60307. * @param otherVector defines the other vector
  60308. * @returns the current updated Vector2
  60309. */
  60310. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60311. /**
  60312. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60313. * @param otherVector defines the other vector
  60314. * @returns a new Vector2
  60315. */
  60316. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60317. /**
  60318. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60319. * @param otherVector defines the other vector
  60320. * @param result defines the target vector
  60321. * @returns the unmodified current Vector2
  60322. */
  60323. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60324. /**
  60325. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60326. * @param x defines the first coordinate
  60327. * @param y defines the second coordinate
  60328. * @returns a new Vector2
  60329. */
  60330. multiplyByFloats(x: number, y: number): Vector2;
  60331. /**
  60332. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60333. * @param otherVector defines the other vector
  60334. * @returns a new Vector2
  60335. */
  60336. divide(otherVector: Vector2): Vector2;
  60337. /**
  60338. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60339. * @param otherVector defines the other vector
  60340. * @param result defines the target vector
  60341. * @returns the unmodified current Vector2
  60342. */
  60343. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60344. /**
  60345. * Divides the current Vector2 coordinates by the given ones
  60346. * @param otherVector defines the other vector
  60347. * @returns the current updated Vector2
  60348. */
  60349. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60350. /**
  60351. * Gets a new Vector2 with current Vector2 negated coordinates
  60352. * @returns a new Vector2
  60353. */
  60354. negate(): Vector2;
  60355. /**
  60356. * Multiply the Vector2 coordinates by scale
  60357. * @param scale defines the scaling factor
  60358. * @returns the current updated Vector2
  60359. */
  60360. scaleInPlace(scale: number): Vector2;
  60361. /**
  60362. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60363. * @param scale defines the scaling factor
  60364. * @returns a new Vector2
  60365. */
  60366. scale(scale: number): Vector2;
  60367. /**
  60368. * Scale the current Vector2 values by a factor to a given Vector2
  60369. * @param scale defines the scale factor
  60370. * @param result defines the Vector2 object where to store the result
  60371. * @returns the unmodified current Vector2
  60372. */
  60373. scaleToRef(scale: number, result: Vector2): Vector2;
  60374. /**
  60375. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60376. * @param scale defines the scale factor
  60377. * @param result defines the Vector2 object where to store the result
  60378. * @returns the unmodified current Vector2
  60379. */
  60380. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60381. /**
  60382. * Gets a boolean if two vectors are equals
  60383. * @param otherVector defines the other vector
  60384. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60385. */
  60386. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60387. /**
  60388. * Gets a boolean if two vectors are equals (using an epsilon value)
  60389. * @param otherVector defines the other vector
  60390. * @param epsilon defines the minimal distance to consider equality
  60391. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60392. */
  60393. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60394. /**
  60395. * Gets a new Vector2 from current Vector2 floored values
  60396. * @returns a new Vector2
  60397. */
  60398. floor(): Vector2;
  60399. /**
  60400. * Gets a new Vector2 from current Vector2 floored values
  60401. * @returns a new Vector2
  60402. */
  60403. fract(): Vector2;
  60404. /**
  60405. * Gets the length of the vector
  60406. * @returns the vector length (float)
  60407. */
  60408. length(): number;
  60409. /**
  60410. * Gets the vector squared length
  60411. * @returns the vector squared length (float)
  60412. */
  60413. lengthSquared(): number;
  60414. /**
  60415. * Normalize the vector
  60416. * @returns the current updated Vector2
  60417. */
  60418. normalize(): Vector2;
  60419. /**
  60420. * Gets a new Vector2 copied from the Vector2
  60421. * @returns a new Vector2
  60422. */
  60423. clone(): Vector2;
  60424. /**
  60425. * Gets a new Vector2(0, 0)
  60426. * @returns a new Vector2
  60427. */
  60428. static Zero(): Vector2;
  60429. /**
  60430. * Gets a new Vector2(1, 1)
  60431. * @returns a new Vector2
  60432. */
  60433. static One(): Vector2;
  60434. /**
  60435. * Gets a new Vector2 set from the given index element of the given array
  60436. * @param array defines the data source
  60437. * @param offset defines the offset in the data source
  60438. * @returns a new Vector2
  60439. */
  60440. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60441. /**
  60442. * Sets "result" from the given index element of the given array
  60443. * @param array defines the data source
  60444. * @param offset defines the offset in the data source
  60445. * @param result defines the target vector
  60446. */
  60447. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60448. /**
  60449. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60450. * @param value1 defines 1st point of control
  60451. * @param value2 defines 2nd point of control
  60452. * @param value3 defines 3rd point of control
  60453. * @param value4 defines 4th point of control
  60454. * @param amount defines the interpolation factor
  60455. * @returns a new Vector2
  60456. */
  60457. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60458. /**
  60459. * 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".
  60460. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60461. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60462. * @param value defines the value to clamp
  60463. * @param min defines the lower limit
  60464. * @param max defines the upper limit
  60465. * @returns a new Vector2
  60466. */
  60467. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60468. /**
  60469. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60470. * @param value1 defines the 1st control point
  60471. * @param tangent1 defines the outgoing tangent
  60472. * @param value2 defines the 2nd control point
  60473. * @param tangent2 defines the incoming tangent
  60474. * @param amount defines the interpolation factor
  60475. * @returns a new Vector2
  60476. */
  60477. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60478. /**
  60479. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60480. * @param start defines the start vector
  60481. * @param end defines the end vector
  60482. * @param amount defines the interpolation factor
  60483. * @returns a new Vector2
  60484. */
  60485. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60486. /**
  60487. * Gets the dot product of the vector "left" and the vector "right"
  60488. * @param left defines first vector
  60489. * @param right defines second vector
  60490. * @returns the dot product (float)
  60491. */
  60492. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60493. /**
  60494. * Returns a new Vector2 equal to the normalized given vector
  60495. * @param vector defines the vector to normalize
  60496. * @returns a new Vector2
  60497. */
  60498. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60499. /**
  60500. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60501. * @param left defines 1st vector
  60502. * @param right defines 2nd vector
  60503. * @returns a new Vector2
  60504. */
  60505. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60506. /**
  60507. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60508. * @param left defines 1st vector
  60509. * @param right defines 2nd vector
  60510. * @returns a new Vector2
  60511. */
  60512. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60513. /**
  60514. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60515. * @param vector defines the vector to transform
  60516. * @param transformation defines the matrix to apply
  60517. * @returns a new Vector2
  60518. */
  60519. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60520. /**
  60521. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60522. * @param vector defines the vector to transform
  60523. * @param transformation defines the matrix to apply
  60524. * @param result defines the target vector
  60525. */
  60526. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60527. /**
  60528. * Determines if a given vector is included in a triangle
  60529. * @param p defines the vector to test
  60530. * @param p0 defines 1st triangle point
  60531. * @param p1 defines 2nd triangle point
  60532. * @param p2 defines 3rd triangle point
  60533. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60534. */
  60535. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60536. /**
  60537. * Gets the distance between the vectors "value1" and "value2"
  60538. * @param value1 defines first vector
  60539. * @param value2 defines second vector
  60540. * @returns the distance between vectors
  60541. */
  60542. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60543. /**
  60544. * Returns the squared distance between the vectors "value1" and "value2"
  60545. * @param value1 defines first vector
  60546. * @param value2 defines second vector
  60547. * @returns the squared distance between vectors
  60548. */
  60549. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60550. /**
  60551. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60552. * @param value1 defines first vector
  60553. * @param value2 defines second vector
  60554. * @returns a new Vector2
  60555. */
  60556. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60557. /**
  60558. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60559. * @param p defines the middle point
  60560. * @param segA defines one point of the segment
  60561. * @param segB defines the other point of the segment
  60562. * @returns the shortest distance
  60563. */
  60564. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60565. }
  60566. /**
  60567. * Classed used to store (x,y,z) vector representation
  60568. * A Vector3 is the main object used in 3D geometry
  60569. * It can represent etiher the coordinates of a point the space, either a direction
  60570. * Reminder: js uses a left handed forward facing system
  60571. */
  60572. export class Vector3 {
  60573. /**
  60574. * Defines the first coordinates (on X axis)
  60575. */
  60576. x: number;
  60577. /**
  60578. * Defines the second coordinates (on Y axis)
  60579. */
  60580. y: number;
  60581. /**
  60582. * Defines the third coordinates (on Z axis)
  60583. */
  60584. z: number;
  60585. private static _UpReadOnly;
  60586. /**
  60587. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60588. * @param x defines the first coordinates (on X axis)
  60589. * @param y defines the second coordinates (on Y axis)
  60590. * @param z defines the third coordinates (on Z axis)
  60591. */
  60592. constructor(
  60593. /**
  60594. * Defines the first coordinates (on X axis)
  60595. */
  60596. x?: number,
  60597. /**
  60598. * Defines the second coordinates (on Y axis)
  60599. */
  60600. y?: number,
  60601. /**
  60602. * Defines the third coordinates (on Z axis)
  60603. */
  60604. z?: number);
  60605. /**
  60606. * Creates a string representation of the Vector3
  60607. * @returns a string with the Vector3 coordinates.
  60608. */
  60609. toString(): string;
  60610. /**
  60611. * Gets the class name
  60612. * @returns the string "Vector3"
  60613. */
  60614. getClassName(): string;
  60615. /**
  60616. * Creates the Vector3 hash code
  60617. * @returns a number which tends to be unique between Vector3 instances
  60618. */
  60619. getHashCode(): number;
  60620. /**
  60621. * Creates an array containing three elements : the coordinates of the Vector3
  60622. * @returns a new array of numbers
  60623. */
  60624. asArray(): number[];
  60625. /**
  60626. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60627. * @param array defines the destination array
  60628. * @param index defines the offset in the destination array
  60629. * @returns the current Vector3
  60630. */
  60631. toArray(array: FloatArray, index?: number): Vector3;
  60632. /**
  60633. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60634. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60635. */
  60636. toQuaternion(): Quaternion;
  60637. /**
  60638. * Adds the given vector to the current Vector3
  60639. * @param otherVector defines the second operand
  60640. * @returns the current updated Vector3
  60641. */
  60642. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60643. /**
  60644. * Adds the given coordinates to the current Vector3
  60645. * @param x defines the x coordinate of the operand
  60646. * @param y defines the y coordinate of the operand
  60647. * @param z defines the z coordinate of the operand
  60648. * @returns the current updated Vector3
  60649. */
  60650. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60651. /**
  60652. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60653. * @param otherVector defines the second operand
  60654. * @returns the resulting Vector3
  60655. */
  60656. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60657. /**
  60658. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60659. * @param otherVector defines the second operand
  60660. * @param result defines the Vector3 object where to store the result
  60661. * @returns the current Vector3
  60662. */
  60663. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60664. /**
  60665. * Subtract the given vector from the current Vector3
  60666. * @param otherVector defines the second operand
  60667. * @returns the current updated Vector3
  60668. */
  60669. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60670. /**
  60671. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60672. * @param otherVector defines the second operand
  60673. * @returns the resulting Vector3
  60674. */
  60675. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60676. /**
  60677. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60678. * @param otherVector defines the second operand
  60679. * @param result defines the Vector3 object where to store the result
  60680. * @returns the current Vector3
  60681. */
  60682. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60683. /**
  60684. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60685. * @param x defines the x coordinate of the operand
  60686. * @param y defines the y coordinate of the operand
  60687. * @param z defines the z coordinate of the operand
  60688. * @returns the resulting Vector3
  60689. */
  60690. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60691. /**
  60692. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  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. * @param result defines the Vector3 object where to store the result
  60697. * @returns the current Vector3
  60698. */
  60699. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60700. /**
  60701. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60702. * @returns a new Vector3
  60703. */
  60704. negate(): Vector3;
  60705. /**
  60706. * Multiplies the Vector3 coordinates by the float "scale"
  60707. * @param scale defines the multiplier factor
  60708. * @returns the current updated Vector3
  60709. */
  60710. scaleInPlace(scale: number): Vector3;
  60711. /**
  60712. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60713. * @param scale defines the multiplier factor
  60714. * @returns a new Vector3
  60715. */
  60716. scale(scale: number): Vector3;
  60717. /**
  60718. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60719. * @param scale defines the multiplier factor
  60720. * @param result defines the Vector3 object where to store the result
  60721. * @returns the current Vector3
  60722. */
  60723. scaleToRef(scale: number, result: Vector3): Vector3;
  60724. /**
  60725. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60726. * @param scale defines the scale factor
  60727. * @param result defines the Vector3 object where to store the result
  60728. * @returns the unmodified current Vector3
  60729. */
  60730. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60731. /**
  60732. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60733. * @param otherVector defines the second operand
  60734. * @returns true if both vectors are equals
  60735. */
  60736. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60737. /**
  60738. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60739. * @param otherVector defines the second operand
  60740. * @param epsilon defines the minimal distance to define values as equals
  60741. * @returns true if both vectors are distant less than epsilon
  60742. */
  60743. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60744. /**
  60745. * Returns true if the current Vector3 coordinates equals the given floats
  60746. * @param x defines the x coordinate of the operand
  60747. * @param y defines the y coordinate of the operand
  60748. * @param z defines the z coordinate of the operand
  60749. * @returns true if both vectors are equals
  60750. */
  60751. equalsToFloats(x: number, y: number, z: number): boolean;
  60752. /**
  60753. * Multiplies the current Vector3 coordinates by the given ones
  60754. * @param otherVector defines the second operand
  60755. * @returns the current updated Vector3
  60756. */
  60757. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60758. /**
  60759. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60760. * @param otherVector defines the second operand
  60761. * @returns the new Vector3
  60762. */
  60763. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60764. /**
  60765. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60766. * @param otherVector defines the second operand
  60767. * @param result defines the Vector3 object where to store the result
  60768. * @returns the current Vector3
  60769. */
  60770. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60771. /**
  60772. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60773. * @param x defines the x coordinate of the operand
  60774. * @param y defines the y coordinate of the operand
  60775. * @param z defines the z coordinate of the operand
  60776. * @returns the new Vector3
  60777. */
  60778. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60779. /**
  60780. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60781. * @param otherVector defines the second operand
  60782. * @returns the new Vector3
  60783. */
  60784. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60785. /**
  60786. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60787. * @param otherVector defines the second operand
  60788. * @param result defines the Vector3 object where to store the result
  60789. * @returns the current Vector3
  60790. */
  60791. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60792. /**
  60793. * Divides the current Vector3 coordinates by the given ones.
  60794. * @param otherVector defines the second operand
  60795. * @returns the current updated Vector3
  60796. */
  60797. divideInPlace(otherVector: Vector3): Vector3;
  60798. /**
  60799. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60800. * @param other defines the second operand
  60801. * @returns the current updated Vector3
  60802. */
  60803. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60804. /**
  60805. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60806. * @param other defines the second operand
  60807. * @returns the current updated Vector3
  60808. */
  60809. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60810. /**
  60811. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60812. * @param x defines the x coordinate of the operand
  60813. * @param y defines the y coordinate of the operand
  60814. * @param z defines the z coordinate of the operand
  60815. * @returns the current updated Vector3
  60816. */
  60817. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60818. /**
  60819. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60820. * @param x defines the x coordinate of the operand
  60821. * @param y defines the y coordinate of the operand
  60822. * @param z defines the z coordinate of the operand
  60823. * @returns the current updated Vector3
  60824. */
  60825. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60826. /**
  60827. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60828. * Check if is non uniform within a certain amount of decimal places to account for this
  60829. * @param epsilon the amount the values can differ
  60830. * @returns if the the vector is non uniform to a certain number of decimal places
  60831. */
  60832. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60833. /**
  60834. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60835. */
  60836. readonly isNonUniform: boolean;
  60837. /**
  60838. * Gets a new Vector3 from current Vector3 floored values
  60839. * @returns a new Vector3
  60840. */
  60841. floor(): Vector3;
  60842. /**
  60843. * Gets a new Vector3 from current Vector3 floored values
  60844. * @returns a new Vector3
  60845. */
  60846. fract(): Vector3;
  60847. /**
  60848. * Gets the length of the Vector3
  60849. * @returns the length of the Vecto3
  60850. */
  60851. length(): number;
  60852. /**
  60853. * Gets the squared length of the Vector3
  60854. * @returns squared length of the Vector3
  60855. */
  60856. lengthSquared(): number;
  60857. /**
  60858. * Normalize the current Vector3.
  60859. * Please note that this is an in place operation.
  60860. * @returns the current updated Vector3
  60861. */
  60862. normalize(): Vector3;
  60863. /**
  60864. * Reorders the x y z properties of the vector in place
  60865. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60866. * @returns the current updated vector
  60867. */
  60868. reorderInPlace(order: string): this;
  60869. /**
  60870. * Rotates the vector around 0,0,0 by a quaternion
  60871. * @param quaternion the rotation quaternion
  60872. * @param result vector to store the result
  60873. * @returns the resulting vector
  60874. */
  60875. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60876. /**
  60877. * Rotates a vector around a given point
  60878. * @param quaternion the rotation quaternion
  60879. * @param point the point to rotate around
  60880. * @param result vector to store the result
  60881. * @returns the resulting vector
  60882. */
  60883. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60884. /**
  60885. * Normalize the current Vector3 with the given input length.
  60886. * Please note that this is an in place operation.
  60887. * @param len the length of the vector
  60888. * @returns the current updated Vector3
  60889. */
  60890. normalizeFromLength(len: number): Vector3;
  60891. /**
  60892. * Normalize the current Vector3 to a new vector
  60893. * @returns the new Vector3
  60894. */
  60895. normalizeToNew(): Vector3;
  60896. /**
  60897. * Normalize the current Vector3 to the reference
  60898. * @param reference define the Vector3 to update
  60899. * @returns the updated Vector3
  60900. */
  60901. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60902. /**
  60903. * Creates a new Vector3 copied from the current Vector3
  60904. * @returns the new Vector3
  60905. */
  60906. clone(): Vector3;
  60907. /**
  60908. * Copies the given vector coordinates to the current Vector3 ones
  60909. * @param source defines the source Vector3
  60910. * @returns the current updated Vector3
  60911. */
  60912. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60913. /**
  60914. * Copies the given floats to the current Vector3 coordinates
  60915. * @param x defines the x coordinate of the operand
  60916. * @param y defines the y coordinate of the operand
  60917. * @param z defines the z coordinate of the operand
  60918. * @returns the current updated Vector3
  60919. */
  60920. copyFromFloats(x: number, y: number, z: number): Vector3;
  60921. /**
  60922. * Copies the given floats to the current Vector3 coordinates
  60923. * @param x defines the x coordinate of the operand
  60924. * @param y defines the y coordinate of the operand
  60925. * @param z defines the z coordinate of the operand
  60926. * @returns the current updated Vector3
  60927. */
  60928. set(x: number, y: number, z: number): Vector3;
  60929. /**
  60930. * Copies the given float to the current Vector3 coordinates
  60931. * @param v defines the x, y and z coordinates of the operand
  60932. * @returns the current updated Vector3
  60933. */
  60934. setAll(v: number): Vector3;
  60935. /**
  60936. * Get the clip factor between two vectors
  60937. * @param vector0 defines the first operand
  60938. * @param vector1 defines the second operand
  60939. * @param axis defines the axis to use
  60940. * @param size defines the size along the axis
  60941. * @returns the clip factor
  60942. */
  60943. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60944. /**
  60945. * Get angle between two vectors
  60946. * @param vector0 angle between vector0 and vector1
  60947. * @param vector1 angle between vector0 and vector1
  60948. * @param normal direction of the normal
  60949. * @return the angle between vector0 and vector1
  60950. */
  60951. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60952. /**
  60953. * Returns a new Vector3 set from the index "offset" of the given array
  60954. * @param array defines the source array
  60955. * @param offset defines the offset in the source array
  60956. * @returns the new Vector3
  60957. */
  60958. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60959. /**
  60960. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60961. * This function is deprecated. Use FromArray instead
  60962. * @param array defines the source array
  60963. * @param offset defines the offset in the source array
  60964. * @returns the new Vector3
  60965. */
  60966. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60967. /**
  60968. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60969. * @param array defines the source array
  60970. * @param offset defines the offset in the source array
  60971. * @param result defines the Vector3 where to store the result
  60972. */
  60973. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60974. /**
  60975. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60976. * This function is deprecated. Use FromArrayToRef instead.
  60977. * @param array defines the source array
  60978. * @param offset defines the offset in the source array
  60979. * @param result defines the Vector3 where to store the result
  60980. */
  60981. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60982. /**
  60983. * Sets the given vector "result" with the given floats.
  60984. * @param x defines the x coordinate of the source
  60985. * @param y defines the y coordinate of the source
  60986. * @param z defines the z coordinate of the source
  60987. * @param result defines the Vector3 where to store the result
  60988. */
  60989. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60990. /**
  60991. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60992. * @returns a new empty Vector3
  60993. */
  60994. static Zero(): Vector3;
  60995. /**
  60996. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60997. * @returns a new unit Vector3
  60998. */
  60999. static One(): Vector3;
  61000. /**
  61001. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61002. * @returns a new up Vector3
  61003. */
  61004. static Up(): Vector3;
  61005. /**
  61006. * Gets a up Vector3 that must not be updated
  61007. */
  61008. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61009. /**
  61010. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61011. * @returns a new down Vector3
  61012. */
  61013. static Down(): Vector3;
  61014. /**
  61015. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61016. * @returns a new forward Vector3
  61017. */
  61018. static Forward(): Vector3;
  61019. /**
  61020. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61021. * @returns a new forward Vector3
  61022. */
  61023. static Backward(): Vector3;
  61024. /**
  61025. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61026. * @returns a new right Vector3
  61027. */
  61028. static Right(): Vector3;
  61029. /**
  61030. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61031. * @returns a new left Vector3
  61032. */
  61033. static Left(): Vector3;
  61034. /**
  61035. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61036. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61037. * @param vector defines the Vector3 to transform
  61038. * @param transformation defines the transformation matrix
  61039. * @returns the transformed Vector3
  61040. */
  61041. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61042. /**
  61043. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61044. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61045. * @param vector defines the Vector3 to transform
  61046. * @param transformation defines the transformation matrix
  61047. * @param result defines the Vector3 where to store the result
  61048. */
  61049. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61050. /**
  61051. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61052. * This method computes tranformed coordinates only, not transformed direction vectors
  61053. * @param x define the x coordinate of the source vector
  61054. * @param y define the y coordinate of the source vector
  61055. * @param z define the z coordinate of the source vector
  61056. * @param transformation defines the transformation matrix
  61057. * @param result defines the Vector3 where to store the result
  61058. */
  61059. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61060. /**
  61061. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61062. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61063. * @param vector defines the Vector3 to transform
  61064. * @param transformation defines the transformation matrix
  61065. * @returns the new Vector3
  61066. */
  61067. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61068. /**
  61069. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61070. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61071. * @param vector defines the Vector3 to transform
  61072. * @param transformation defines the transformation matrix
  61073. * @param result defines the Vector3 where to store the result
  61074. */
  61075. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61076. /**
  61077. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61078. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61079. * @param x define the x coordinate of the source vector
  61080. * @param y define the y coordinate of the source vector
  61081. * @param z define the z coordinate of the source vector
  61082. * @param transformation defines the transformation matrix
  61083. * @param result defines the Vector3 where to store the result
  61084. */
  61085. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61086. /**
  61087. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61088. * @param value1 defines the first control point
  61089. * @param value2 defines the second control point
  61090. * @param value3 defines the third control point
  61091. * @param value4 defines the fourth control point
  61092. * @param amount defines the amount on the spline to use
  61093. * @returns the new Vector3
  61094. */
  61095. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61096. /**
  61097. * 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"
  61098. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61099. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61100. * @param value defines the current value
  61101. * @param min defines the lower range value
  61102. * @param max defines the upper range value
  61103. * @returns the new Vector3
  61104. */
  61105. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61106. /**
  61107. * 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"
  61108. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61109. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61110. * @param value defines the current value
  61111. * @param min defines the lower range value
  61112. * @param max defines the upper range value
  61113. * @param result defines the Vector3 where to store the result
  61114. */
  61115. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61116. /**
  61117. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61118. * @param value1 defines the first control point
  61119. * @param tangent1 defines the first tangent vector
  61120. * @param value2 defines the second control point
  61121. * @param tangent2 defines the second tangent vector
  61122. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61123. * @returns the new Vector3
  61124. */
  61125. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61126. /**
  61127. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61128. * @param start defines the start value
  61129. * @param end defines the end value
  61130. * @param amount max defines amount between both (between 0 and 1)
  61131. * @returns the new Vector3
  61132. */
  61133. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61134. /**
  61135. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61136. * @param start defines the start value
  61137. * @param end defines the end value
  61138. * @param amount max defines amount between both (between 0 and 1)
  61139. * @param result defines the Vector3 where to store the result
  61140. */
  61141. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61142. /**
  61143. * Returns the dot product (float) between the vectors "left" and "right"
  61144. * @param left defines the left operand
  61145. * @param right defines the right operand
  61146. * @returns the dot product
  61147. */
  61148. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61149. /**
  61150. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61151. * The cross product is then orthogonal to both "left" and "right"
  61152. * @param left defines the left operand
  61153. * @param right defines the right operand
  61154. * @returns the cross product
  61155. */
  61156. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61157. /**
  61158. * Sets the given vector "result" with the cross product of "left" and "right"
  61159. * The cross product is then orthogonal to both "left" and "right"
  61160. * @param left defines the left operand
  61161. * @param right defines the right operand
  61162. * @param result defines the Vector3 where to store the result
  61163. */
  61164. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61165. /**
  61166. * Returns a new Vector3 as the normalization of the given vector
  61167. * @param vector defines the Vector3 to normalize
  61168. * @returns the new Vector3
  61169. */
  61170. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61171. /**
  61172. * Sets the given vector "result" with the normalization of the given first vector
  61173. * @param vector defines the Vector3 to normalize
  61174. * @param result defines the Vector3 where to store the result
  61175. */
  61176. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61177. /**
  61178. * Project a Vector3 onto screen space
  61179. * @param vector defines the Vector3 to project
  61180. * @param world defines the world matrix to use
  61181. * @param transform defines the transform (view x projection) matrix to use
  61182. * @param viewport defines the screen viewport to use
  61183. * @returns the new Vector3
  61184. */
  61185. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61186. /** @hidden */
  61187. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61188. /**
  61189. * Unproject from screen space to object space
  61190. * @param source defines the screen space Vector3 to use
  61191. * @param viewportWidth defines the current width of the viewport
  61192. * @param viewportHeight defines the current height of the viewport
  61193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61194. * @param transform defines the transform (view x projection) matrix to use
  61195. * @returns the new Vector3
  61196. */
  61197. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61198. /**
  61199. * Unproject from screen space to object space
  61200. * @param source defines the screen space Vector3 to use
  61201. * @param viewportWidth defines the current width of the viewport
  61202. * @param viewportHeight defines the current height of the viewport
  61203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61204. * @param view defines the view matrix to use
  61205. * @param projection defines the projection matrix to use
  61206. * @returns the new Vector3
  61207. */
  61208. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61209. /**
  61210. * Unproject from screen space to object space
  61211. * @param source defines the screen space Vector3 to use
  61212. * @param viewportWidth defines the current width of the viewport
  61213. * @param viewportHeight defines the current height of the viewport
  61214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61215. * @param view defines the view matrix to use
  61216. * @param projection defines the projection matrix to use
  61217. * @param result defines the Vector3 where to store the result
  61218. */
  61219. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61220. /**
  61221. * Unproject from screen space to object space
  61222. * @param sourceX defines the screen space x coordinate to use
  61223. * @param sourceY defines the screen space y coordinate to use
  61224. * @param sourceZ defines the screen space z coordinate to use
  61225. * @param viewportWidth defines the current width of the viewport
  61226. * @param viewportHeight defines the current height of the viewport
  61227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61228. * @param view defines the view matrix to use
  61229. * @param projection defines the projection matrix to use
  61230. * @param result defines the Vector3 where to store the result
  61231. */
  61232. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61233. /**
  61234. * Gets the minimal coordinate values between two Vector3
  61235. * @param left defines the first operand
  61236. * @param right defines the second operand
  61237. * @returns the new Vector3
  61238. */
  61239. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61240. /**
  61241. * Gets the maximal coordinate values between two Vector3
  61242. * @param left defines the first operand
  61243. * @param right defines the second operand
  61244. * @returns the new Vector3
  61245. */
  61246. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61247. /**
  61248. * Returns the distance between the vectors "value1" and "value2"
  61249. * @param value1 defines the first operand
  61250. * @param value2 defines the second operand
  61251. * @returns the distance
  61252. */
  61253. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61254. /**
  61255. * Returns the squared distance between the vectors "value1" and "value2"
  61256. * @param value1 defines the first operand
  61257. * @param value2 defines the second operand
  61258. * @returns the squared distance
  61259. */
  61260. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61261. /**
  61262. * Returns a new Vector3 located at the center between "value1" and "value2"
  61263. * @param value1 defines the first operand
  61264. * @param value2 defines the second operand
  61265. * @returns the new Vector3
  61266. */
  61267. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61268. /**
  61269. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61270. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61271. * to something in order to rotate it from its local system to the given target system
  61272. * Note: axis1, axis2 and axis3 are normalized during this operation
  61273. * @param axis1 defines the first axis
  61274. * @param axis2 defines the second axis
  61275. * @param axis3 defines the third axis
  61276. * @returns a new Vector3
  61277. */
  61278. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61279. /**
  61280. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61281. * @param axis1 defines the first axis
  61282. * @param axis2 defines the second axis
  61283. * @param axis3 defines the third axis
  61284. * @param ref defines the Vector3 where to store the result
  61285. */
  61286. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61287. }
  61288. /**
  61289. * Vector4 class created for EulerAngle class conversion to Quaternion
  61290. */
  61291. export class Vector4 {
  61292. /** x value of the vector */
  61293. x: number;
  61294. /** y value of the vector */
  61295. y: number;
  61296. /** z value of the vector */
  61297. z: number;
  61298. /** w value of the vector */
  61299. w: number;
  61300. /**
  61301. * Creates a Vector4 object from the given floats.
  61302. * @param x x value of the vector
  61303. * @param y y value of the vector
  61304. * @param z z value of the vector
  61305. * @param w w value of the vector
  61306. */
  61307. constructor(
  61308. /** x value of the vector */
  61309. x: number,
  61310. /** y value of the vector */
  61311. y: number,
  61312. /** z value of the vector */
  61313. z: number,
  61314. /** w value of the vector */
  61315. w: number);
  61316. /**
  61317. * Returns the string with the Vector4 coordinates.
  61318. * @returns a string containing all the vector values
  61319. */
  61320. toString(): string;
  61321. /**
  61322. * Returns the string "Vector4".
  61323. * @returns "Vector4"
  61324. */
  61325. getClassName(): string;
  61326. /**
  61327. * Returns the Vector4 hash code.
  61328. * @returns a unique hash code
  61329. */
  61330. getHashCode(): number;
  61331. /**
  61332. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61333. * @returns the resulting array
  61334. */
  61335. asArray(): number[];
  61336. /**
  61337. * Populates the given array from the given index with the Vector4 coordinates.
  61338. * @param array array to populate
  61339. * @param index index of the array to start at (default: 0)
  61340. * @returns the Vector4.
  61341. */
  61342. toArray(array: FloatArray, index?: number): Vector4;
  61343. /**
  61344. * Adds the given vector to the current Vector4.
  61345. * @param otherVector the vector to add
  61346. * @returns the updated Vector4.
  61347. */
  61348. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61349. /**
  61350. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61351. * @param otherVector the vector to add
  61352. * @returns the resulting vector
  61353. */
  61354. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61355. /**
  61356. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61357. * @param otherVector the vector to add
  61358. * @param result the vector to store the result
  61359. * @returns the current Vector4.
  61360. */
  61361. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61362. /**
  61363. * Subtract in place the given vector from the current Vector4.
  61364. * @param otherVector the vector to subtract
  61365. * @returns the updated Vector4.
  61366. */
  61367. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61368. /**
  61369. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61370. * @param otherVector the vector to add
  61371. * @returns the new vector with the result
  61372. */
  61373. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61374. /**
  61375. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61376. * @param otherVector the vector to subtract
  61377. * @param result the vector to store the result
  61378. * @returns the current Vector4.
  61379. */
  61380. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61381. /**
  61382. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61383. */
  61384. /**
  61385. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61386. * @param x value to subtract
  61387. * @param y value to subtract
  61388. * @param z value to subtract
  61389. * @param w value to subtract
  61390. * @returns new vector containing the result
  61391. */
  61392. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61393. /**
  61394. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61395. * @param x value to subtract
  61396. * @param y value to subtract
  61397. * @param z value to subtract
  61398. * @param w value to subtract
  61399. * @param result the vector to store the result in
  61400. * @returns the current Vector4.
  61401. */
  61402. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61403. /**
  61404. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61405. * @returns a new vector with the negated values
  61406. */
  61407. negate(): Vector4;
  61408. /**
  61409. * Multiplies the current Vector4 coordinates by scale (float).
  61410. * @param scale the number to scale with
  61411. * @returns the updated Vector4.
  61412. */
  61413. scaleInPlace(scale: number): Vector4;
  61414. /**
  61415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61416. * @param scale the number to scale with
  61417. * @returns a new vector with the result
  61418. */
  61419. scale(scale: number): Vector4;
  61420. /**
  61421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61422. * @param scale the number to scale with
  61423. * @param result a vector to store the result in
  61424. * @returns the current Vector4.
  61425. */
  61426. scaleToRef(scale: number, result: Vector4): Vector4;
  61427. /**
  61428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61429. * @param scale defines the scale factor
  61430. * @param result defines the Vector4 object where to store the result
  61431. * @returns the unmodified current Vector4
  61432. */
  61433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61434. /**
  61435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61436. * @param otherVector the vector to compare against
  61437. * @returns true if they are equal
  61438. */
  61439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61440. /**
  61441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61442. * @param otherVector vector to compare against
  61443. * @param epsilon (Default: very small number)
  61444. * @returns true if they are equal
  61445. */
  61446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61447. /**
  61448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61449. * @param x x value to compare against
  61450. * @param y y value to compare against
  61451. * @param z z value to compare against
  61452. * @param w w value to compare against
  61453. * @returns true if equal
  61454. */
  61455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61456. /**
  61457. * Multiplies in place the current Vector4 by the given one.
  61458. * @param otherVector vector to multiple with
  61459. * @returns the updated Vector4.
  61460. */
  61461. multiplyInPlace(otherVector: Vector4): Vector4;
  61462. /**
  61463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61464. * @param otherVector vector to multiple with
  61465. * @returns resulting new vector
  61466. */
  61467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61468. /**
  61469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61470. * @param otherVector vector to multiple with
  61471. * @param result vector to store the result
  61472. * @returns the current Vector4.
  61473. */
  61474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61475. /**
  61476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61477. * @param x x value multiply with
  61478. * @param y y value multiply with
  61479. * @param z z value multiply with
  61480. * @param w w value multiply with
  61481. * @returns resulting new vector
  61482. */
  61483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61484. /**
  61485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61486. * @param otherVector vector to devide with
  61487. * @returns resulting new vector
  61488. */
  61489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61490. /**
  61491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61492. * @param otherVector vector to devide with
  61493. * @param result vector to store the result
  61494. * @returns the current Vector4.
  61495. */
  61496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61497. /**
  61498. * Divides the current Vector3 coordinates by the given ones.
  61499. * @param otherVector vector to devide with
  61500. * @returns the updated Vector3.
  61501. */
  61502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61503. /**
  61504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61505. * @param other defines the second operand
  61506. * @returns the current updated Vector4
  61507. */
  61508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61509. /**
  61510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61511. * @param other defines the second operand
  61512. * @returns the current updated Vector4
  61513. */
  61514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61515. /**
  61516. * Gets a new Vector4 from current Vector4 floored values
  61517. * @returns a new Vector4
  61518. */
  61519. floor(): Vector4;
  61520. /**
  61521. * Gets a new Vector4 from current Vector3 floored values
  61522. * @returns a new Vector4
  61523. */
  61524. fract(): Vector4;
  61525. /**
  61526. * Returns the Vector4 length (float).
  61527. * @returns the length
  61528. */
  61529. length(): number;
  61530. /**
  61531. * Returns the Vector4 squared length (float).
  61532. * @returns the length squared
  61533. */
  61534. lengthSquared(): number;
  61535. /**
  61536. * Normalizes in place the Vector4.
  61537. * @returns the updated Vector4.
  61538. */
  61539. normalize(): Vector4;
  61540. /**
  61541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61542. * @returns this converted to a new vector3
  61543. */
  61544. toVector3(): Vector3;
  61545. /**
  61546. * Returns a new Vector4 copied from the current one.
  61547. * @returns the new cloned vector
  61548. */
  61549. clone(): Vector4;
  61550. /**
  61551. * Updates the current Vector4 with the given one coordinates.
  61552. * @param source the source vector to copy from
  61553. * @returns the updated Vector4.
  61554. */
  61555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61556. /**
  61557. * Updates the current Vector4 coordinates with the given floats.
  61558. * @param x float to copy from
  61559. * @param y float to copy from
  61560. * @param z float to copy from
  61561. * @param w float to copy from
  61562. * @returns the updated Vector4.
  61563. */
  61564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61565. /**
  61566. * Updates the current Vector4 coordinates with the given floats.
  61567. * @param x float to set from
  61568. * @param y float to set from
  61569. * @param z float to set from
  61570. * @param w float to set from
  61571. * @returns the updated Vector4.
  61572. */
  61573. set(x: number, y: number, z: number, w: number): Vector4;
  61574. /**
  61575. * Copies the given float to the current Vector3 coordinates
  61576. * @param v defines the x, y, z and w coordinates of the operand
  61577. * @returns the current updated Vector3
  61578. */
  61579. setAll(v: number): Vector4;
  61580. /**
  61581. * Returns a new Vector4 set from the starting index of the given array.
  61582. * @param array the array to pull values from
  61583. * @param offset the offset into the array to start at
  61584. * @returns the new vector
  61585. */
  61586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61587. /**
  61588. * Updates the given vector "result" from the starting index of the given array.
  61589. * @param array the array to pull values from
  61590. * @param offset the offset into the array to start at
  61591. * @param result the vector to store the result in
  61592. */
  61593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61594. /**
  61595. * Updates the given vector "result" from the starting index of the given Float32Array.
  61596. * @param array the array to pull values from
  61597. * @param offset the offset into the array to start at
  61598. * @param result the vector to store the result in
  61599. */
  61600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61601. /**
  61602. * Updates the given vector "result" coordinates from the given floats.
  61603. * @param x float to set from
  61604. * @param y float to set from
  61605. * @param z float to set from
  61606. * @param w float to set from
  61607. * @param result the vector to the floats in
  61608. */
  61609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61610. /**
  61611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61612. * @returns the new vector
  61613. */
  61614. static Zero(): Vector4;
  61615. /**
  61616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61617. * @returns the new vector
  61618. */
  61619. static One(): Vector4;
  61620. /**
  61621. * Returns a new normalized Vector4 from the given one.
  61622. * @param vector the vector to normalize
  61623. * @returns the vector
  61624. */
  61625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61626. /**
  61627. * Updates the given vector "result" from the normalization of the given one.
  61628. * @param vector the vector to normalize
  61629. * @param result the vector to store the result in
  61630. */
  61631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61632. /**
  61633. * Returns a vector with the minimum values from the left and right vectors
  61634. * @param left left vector to minimize
  61635. * @param right right vector to minimize
  61636. * @returns a new vector with the minimum of the left and right vector values
  61637. */
  61638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61639. /**
  61640. * Returns a vector with the maximum values from the left and right vectors
  61641. * @param left left vector to maximize
  61642. * @param right right vector to maximize
  61643. * @returns a new vector with the maximum of the left and right vector values
  61644. */
  61645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61646. /**
  61647. * Returns the distance (float) between the vectors "value1" and "value2".
  61648. * @param value1 value to calulate the distance between
  61649. * @param value2 value to calulate the distance between
  61650. * @return the distance between the two vectors
  61651. */
  61652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61653. /**
  61654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61655. * @param value1 value to calulate the distance between
  61656. * @param value2 value to calulate the distance between
  61657. * @return the distance between the two vectors squared
  61658. */
  61659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61660. /**
  61661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61662. * @param value1 value to calulate the center between
  61663. * @param value2 value to calulate the center between
  61664. * @return the center between the two vectors
  61665. */
  61666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61667. /**
  61668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61669. * This methods computes transformed normalized direction vectors only.
  61670. * @param vector the vector to transform
  61671. * @param transformation the transformation matrix to apply
  61672. * @returns the new vector
  61673. */
  61674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61675. /**
  61676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61677. * This methods computes transformed normalized direction vectors only.
  61678. * @param vector the vector to transform
  61679. * @param transformation the transformation matrix to apply
  61680. * @param result the vector to store the result in
  61681. */
  61682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61683. /**
  61684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61685. * This methods computes transformed normalized direction vectors only.
  61686. * @param x value to transform
  61687. * @param y value to transform
  61688. * @param z value to transform
  61689. * @param w value to transform
  61690. * @param transformation the transformation matrix to apply
  61691. * @param result the vector to store the results in
  61692. */
  61693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61694. /**
  61695. * Creates a new Vector4 from a Vector3
  61696. * @param source defines the source data
  61697. * @param w defines the 4th component (default is 0)
  61698. * @returns a new Vector4
  61699. */
  61700. static FromVector3(source: Vector3, w?: number): Vector4;
  61701. }
  61702. /**
  61703. * Interface for the size containing width and height
  61704. */
  61705. export interface ISize {
  61706. /**
  61707. * Width
  61708. */
  61709. width: number;
  61710. /**
  61711. * Heighht
  61712. */
  61713. height: number;
  61714. }
  61715. /**
  61716. * Size containing widht and height
  61717. */
  61718. export class Size implements ISize {
  61719. /**
  61720. * Width
  61721. */
  61722. width: number;
  61723. /**
  61724. * Height
  61725. */
  61726. height: number;
  61727. /**
  61728. * Creates a Size object from the given width and height (floats).
  61729. * @param width width of the new size
  61730. * @param height height of the new size
  61731. */
  61732. constructor(width: number, height: number);
  61733. /**
  61734. * Returns a string with the Size width and height
  61735. * @returns a string with the Size width and height
  61736. */
  61737. toString(): string;
  61738. /**
  61739. * "Size"
  61740. * @returns the string "Size"
  61741. */
  61742. getClassName(): string;
  61743. /**
  61744. * Returns the Size hash code.
  61745. * @returns a hash code for a unique width and height
  61746. */
  61747. getHashCode(): number;
  61748. /**
  61749. * Updates the current size from the given one.
  61750. * @param src the given size
  61751. */
  61752. copyFrom(src: Size): void;
  61753. /**
  61754. * Updates in place the current Size from the given floats.
  61755. * @param width width of the new size
  61756. * @param height height of the new size
  61757. * @returns the updated Size.
  61758. */
  61759. copyFromFloats(width: number, height: number): Size;
  61760. /**
  61761. * Updates in place the current Size from the given floats.
  61762. * @param width width to set
  61763. * @param height height to set
  61764. * @returns the updated Size.
  61765. */
  61766. set(width: number, height: number): Size;
  61767. /**
  61768. * Multiplies the width and height by numbers
  61769. * @param w factor to multiple the width by
  61770. * @param h factor to multiple the height by
  61771. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61772. */
  61773. multiplyByFloats(w: number, h: number): Size;
  61774. /**
  61775. * Clones the size
  61776. * @returns a new Size copied from the given one.
  61777. */
  61778. clone(): Size;
  61779. /**
  61780. * True if the current Size and the given one width and height are strictly equal.
  61781. * @param other the other size to compare against
  61782. * @returns True if the current Size and the given one width and height are strictly equal.
  61783. */
  61784. equals(other: Size): boolean;
  61785. /**
  61786. * The surface of the Size : width * height (float).
  61787. */
  61788. readonly surface: number;
  61789. /**
  61790. * Create a new size of zero
  61791. * @returns a new Size set to (0.0, 0.0)
  61792. */
  61793. static Zero(): Size;
  61794. /**
  61795. * Sums the width and height of two sizes
  61796. * @param otherSize size to add to this size
  61797. * @returns a new Size set as the addition result of the current Size and the given one.
  61798. */
  61799. add(otherSize: Size): Size;
  61800. /**
  61801. * Subtracts the width and height of two
  61802. * @param otherSize size to subtract to this size
  61803. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61804. */
  61805. subtract(otherSize: Size): Size;
  61806. /**
  61807. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61808. * @param start starting size to lerp between
  61809. * @param end end size to lerp between
  61810. * @param amount amount to lerp between the start and end values
  61811. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61812. */
  61813. static Lerp(start: Size, end: Size, amount: number): Size;
  61814. }
  61815. /**
  61816. * Class used to store quaternion data
  61817. * @see https://en.wikipedia.org/wiki/Quaternion
  61818. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61819. */
  61820. export class Quaternion {
  61821. /** defines the first component (0 by default) */
  61822. x: number;
  61823. /** defines the second component (0 by default) */
  61824. y: number;
  61825. /** defines the third component (0 by default) */
  61826. z: number;
  61827. /** defines the fourth component (1.0 by default) */
  61828. w: number;
  61829. /**
  61830. * Creates a new Quaternion from the given floats
  61831. * @param x defines the first component (0 by default)
  61832. * @param y defines the second component (0 by default)
  61833. * @param z defines the third component (0 by default)
  61834. * @param w defines the fourth component (1.0 by default)
  61835. */
  61836. constructor(
  61837. /** defines the first component (0 by default) */
  61838. x?: number,
  61839. /** defines the second component (0 by default) */
  61840. y?: number,
  61841. /** defines the third component (0 by default) */
  61842. z?: number,
  61843. /** defines the fourth component (1.0 by default) */
  61844. w?: number);
  61845. /**
  61846. * Gets a string representation for the current quaternion
  61847. * @returns a string with the Quaternion coordinates
  61848. */
  61849. toString(): string;
  61850. /**
  61851. * Gets the class name of the quaternion
  61852. * @returns the string "Quaternion"
  61853. */
  61854. getClassName(): string;
  61855. /**
  61856. * Gets a hash code for this quaternion
  61857. * @returns the quaternion hash code
  61858. */
  61859. getHashCode(): number;
  61860. /**
  61861. * Copy the quaternion to an array
  61862. * @returns a new array populated with 4 elements from the quaternion coordinates
  61863. */
  61864. asArray(): number[];
  61865. /**
  61866. * Check if two quaternions are equals
  61867. * @param otherQuaternion defines the second operand
  61868. * @return true if the current quaternion and the given one coordinates are strictly equals
  61869. */
  61870. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61871. /**
  61872. * Clone the current quaternion
  61873. * @returns a new quaternion copied from the current one
  61874. */
  61875. clone(): Quaternion;
  61876. /**
  61877. * Copy a quaternion to the current one
  61878. * @param other defines the other quaternion
  61879. * @returns the updated current quaternion
  61880. */
  61881. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61882. /**
  61883. * Updates the current quaternion with the given float coordinates
  61884. * @param x defines the x coordinate
  61885. * @param y defines the y coordinate
  61886. * @param z defines the z coordinate
  61887. * @param w defines the w coordinate
  61888. * @returns the updated current quaternion
  61889. */
  61890. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61891. /**
  61892. * Updates the current quaternion from the given float coordinates
  61893. * @param x defines the x coordinate
  61894. * @param y defines the y coordinate
  61895. * @param z defines the z coordinate
  61896. * @param w defines the w coordinate
  61897. * @returns the updated current quaternion
  61898. */
  61899. set(x: number, y: number, z: number, w: number): Quaternion;
  61900. /**
  61901. * Adds two quaternions
  61902. * @param other defines the second operand
  61903. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61904. */
  61905. add(other: DeepImmutable<Quaternion>): Quaternion;
  61906. /**
  61907. * Add a quaternion to the current one
  61908. * @param other defines the quaternion to add
  61909. * @returns the current quaternion
  61910. */
  61911. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61912. /**
  61913. * Subtract two quaternions
  61914. * @param other defines the second operand
  61915. * @returns a new quaternion as the subtraction result of the given one from the current one
  61916. */
  61917. subtract(other: Quaternion): Quaternion;
  61918. /**
  61919. * Multiplies the current quaternion by a scale factor
  61920. * @param value defines the scale factor
  61921. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61922. */
  61923. scale(value: number): Quaternion;
  61924. /**
  61925. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61926. * @param scale defines the scale factor
  61927. * @param result defines the Quaternion object where to store the result
  61928. * @returns the unmodified current quaternion
  61929. */
  61930. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61931. /**
  61932. * Multiplies in place the current quaternion by a scale factor
  61933. * @param value defines the scale factor
  61934. * @returns the current modified quaternion
  61935. */
  61936. scaleInPlace(value: number): Quaternion;
  61937. /**
  61938. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61939. * @param scale defines the scale factor
  61940. * @param result defines the Quaternion object where to store the result
  61941. * @returns the unmodified current quaternion
  61942. */
  61943. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61944. /**
  61945. * Multiplies two quaternions
  61946. * @param q1 defines the second operand
  61947. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61948. */
  61949. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61950. /**
  61951. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61952. * @param q1 defines the second operand
  61953. * @param result defines the target quaternion
  61954. * @returns the current quaternion
  61955. */
  61956. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61957. /**
  61958. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61959. * @param q1 defines the second operand
  61960. * @returns the currentupdated quaternion
  61961. */
  61962. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61963. /**
  61964. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61965. * @param ref defines the target quaternion
  61966. * @returns the current quaternion
  61967. */
  61968. conjugateToRef(ref: Quaternion): Quaternion;
  61969. /**
  61970. * Conjugates in place (1-q) the current quaternion
  61971. * @returns the current updated quaternion
  61972. */
  61973. conjugateInPlace(): Quaternion;
  61974. /**
  61975. * Conjugates in place (1-q) the current quaternion
  61976. * @returns a new quaternion
  61977. */
  61978. conjugate(): Quaternion;
  61979. /**
  61980. * Gets length of current quaternion
  61981. * @returns the quaternion length (float)
  61982. */
  61983. length(): number;
  61984. /**
  61985. * Normalize in place the current quaternion
  61986. * @returns the current updated quaternion
  61987. */
  61988. normalize(): Quaternion;
  61989. /**
  61990. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61991. * @param order is a reserved parameter and is ignore for now
  61992. * @returns a new Vector3 containing the Euler angles
  61993. */
  61994. toEulerAngles(order?: string): Vector3;
  61995. /**
  61996. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61997. * @param result defines the vector which will be filled with the Euler angles
  61998. * @param order is a reserved parameter and is ignore for now
  61999. * @returns the current unchanged quaternion
  62000. */
  62001. toEulerAnglesToRef(result: Vector3): Quaternion;
  62002. /**
  62003. * Updates the given rotation matrix with the current quaternion values
  62004. * @param result defines the target matrix
  62005. * @returns the current unchanged quaternion
  62006. */
  62007. toRotationMatrix(result: Matrix): Quaternion;
  62008. /**
  62009. * Updates the current quaternion from the given rotation matrix values
  62010. * @param matrix defines the source matrix
  62011. * @returns the current updated quaternion
  62012. */
  62013. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62014. /**
  62015. * Creates a new quaternion from a rotation matrix
  62016. * @param matrix defines the source matrix
  62017. * @returns a new quaternion created from the given rotation matrix values
  62018. */
  62019. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62020. /**
  62021. * Updates the given quaternion with the given rotation matrix values
  62022. * @param matrix defines the source matrix
  62023. * @param result defines the target quaternion
  62024. */
  62025. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62026. /**
  62027. * Returns the dot product (float) between the quaternions "left" and "right"
  62028. * @param left defines the left operand
  62029. * @param right defines the right operand
  62030. * @returns the dot product
  62031. */
  62032. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62033. /**
  62034. * Checks if the two quaternions are close to each other
  62035. * @param quat0 defines the first quaternion to check
  62036. * @param quat1 defines the second quaternion to check
  62037. * @returns true if the two quaternions are close to each other
  62038. */
  62039. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62040. /**
  62041. * Creates an empty quaternion
  62042. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62043. */
  62044. static Zero(): Quaternion;
  62045. /**
  62046. * Inverse a given quaternion
  62047. * @param q defines the source quaternion
  62048. * @returns a new quaternion as the inverted current quaternion
  62049. */
  62050. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62051. /**
  62052. * Inverse a given quaternion
  62053. * @param q defines the source quaternion
  62054. * @param result the quaternion the result will be stored in
  62055. * @returns the result quaternion
  62056. */
  62057. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62058. /**
  62059. * Creates an identity quaternion
  62060. * @returns the identity quaternion
  62061. */
  62062. static Identity(): Quaternion;
  62063. /**
  62064. * Gets a boolean indicating if the given quaternion is identity
  62065. * @param quaternion defines the quaternion to check
  62066. * @returns true if the quaternion is identity
  62067. */
  62068. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62069. /**
  62070. * Creates a quaternion from a rotation around an axis
  62071. * @param axis defines the axis to use
  62072. * @param angle defines the angle to use
  62073. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62074. */
  62075. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62076. /**
  62077. * Creates a rotation around an axis and stores it into the given quaternion
  62078. * @param axis defines the axis to use
  62079. * @param angle defines the angle to use
  62080. * @param result defines the target quaternion
  62081. * @returns the target quaternion
  62082. */
  62083. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62084. /**
  62085. * Creates a new quaternion from data stored into an array
  62086. * @param array defines the data source
  62087. * @param offset defines the offset in the source array where the data starts
  62088. * @returns a new quaternion
  62089. */
  62090. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62091. /**
  62092. * Create a quaternion from Euler rotation angles
  62093. * @param x Pitch
  62094. * @param y Yaw
  62095. * @param z Roll
  62096. * @returns the new Quaternion
  62097. */
  62098. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62099. /**
  62100. * Updates a quaternion from Euler rotation angles
  62101. * @param x Pitch
  62102. * @param y Yaw
  62103. * @param z Roll
  62104. * @param result the quaternion to store the result
  62105. * @returns the updated quaternion
  62106. */
  62107. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62108. /**
  62109. * Create a quaternion from Euler rotation vector
  62110. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62111. * @returns the new Quaternion
  62112. */
  62113. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62114. /**
  62115. * Updates a quaternion from Euler rotation vector
  62116. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62117. * @param result the quaternion to store the result
  62118. * @returns the updated quaternion
  62119. */
  62120. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62121. /**
  62122. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62123. * @param yaw defines the rotation around Y axis
  62124. * @param pitch defines the rotation around X axis
  62125. * @param roll defines the rotation around Z axis
  62126. * @returns the new quaternion
  62127. */
  62128. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62129. /**
  62130. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62131. * @param yaw defines the rotation around Y axis
  62132. * @param pitch defines the rotation around X axis
  62133. * @param roll defines the rotation around Z axis
  62134. * @param result defines the target quaternion
  62135. */
  62136. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62137. /**
  62138. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62139. * @param alpha defines the rotation around first axis
  62140. * @param beta defines the rotation around second axis
  62141. * @param gamma defines the rotation around third axis
  62142. * @returns the new quaternion
  62143. */
  62144. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62145. /**
  62146. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62147. * @param alpha defines the rotation around first axis
  62148. * @param beta defines the rotation around second axis
  62149. * @param gamma defines the rotation around third axis
  62150. * @param result defines the target quaternion
  62151. */
  62152. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62153. /**
  62154. * 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)
  62155. * @param axis1 defines the first axis
  62156. * @param axis2 defines the second axis
  62157. * @param axis3 defines the third axis
  62158. * @returns the new quaternion
  62159. */
  62160. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62161. /**
  62162. * 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
  62163. * @param axis1 defines the first axis
  62164. * @param axis2 defines the second axis
  62165. * @param axis3 defines the third axis
  62166. * @param ref defines the target quaternion
  62167. */
  62168. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62169. /**
  62170. * Interpolates between two quaternions
  62171. * @param left defines first quaternion
  62172. * @param right defines second quaternion
  62173. * @param amount defines the gradient to use
  62174. * @returns the new interpolated quaternion
  62175. */
  62176. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62177. /**
  62178. * Interpolates between two quaternions and stores it into a target quaternion
  62179. * @param left defines first quaternion
  62180. * @param right defines second quaternion
  62181. * @param amount defines the gradient to use
  62182. * @param result defines the target quaternion
  62183. */
  62184. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62185. /**
  62186. * Interpolate between two quaternions using Hermite interpolation
  62187. * @param value1 defines first quaternion
  62188. * @param tangent1 defines the incoming tangent
  62189. * @param value2 defines second quaternion
  62190. * @param tangent2 defines the outgoing tangent
  62191. * @param amount defines the target quaternion
  62192. * @returns the new interpolated quaternion
  62193. */
  62194. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62195. }
  62196. /**
  62197. * Class used to store matrix data (4x4)
  62198. */
  62199. export class Matrix {
  62200. private static _updateFlagSeed;
  62201. private static _identityReadOnly;
  62202. private _isIdentity;
  62203. private _isIdentityDirty;
  62204. private _isIdentity3x2;
  62205. private _isIdentity3x2Dirty;
  62206. /**
  62207. * Gets the update flag of the matrix which is an unique number for the matrix.
  62208. * It will be incremented every time the matrix data change.
  62209. * You can use it to speed the comparison between two versions of the same matrix.
  62210. */
  62211. updateFlag: number;
  62212. private readonly _m;
  62213. /**
  62214. * Gets the internal data of the matrix
  62215. */
  62216. readonly m: DeepImmutable<Float32Array>;
  62217. /** @hidden */
  62218. _markAsUpdated(): void;
  62219. /** @hidden */
  62220. private _updateIdentityStatus;
  62221. /**
  62222. * Creates an empty matrix (filled with zeros)
  62223. */
  62224. constructor();
  62225. /**
  62226. * Check if the current matrix is identity
  62227. * @returns true is the matrix is the identity matrix
  62228. */
  62229. isIdentity(): boolean;
  62230. /**
  62231. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62232. * @returns true is the matrix is the identity matrix
  62233. */
  62234. isIdentityAs3x2(): boolean;
  62235. /**
  62236. * Gets the determinant of the matrix
  62237. * @returns the matrix determinant
  62238. */
  62239. determinant(): number;
  62240. /**
  62241. * Returns the matrix as a Float32Array
  62242. * @returns the matrix underlying array
  62243. */
  62244. toArray(): DeepImmutable<Float32Array>;
  62245. /**
  62246. * Returns the matrix as a Float32Array
  62247. * @returns the matrix underlying array.
  62248. */
  62249. asArray(): DeepImmutable<Float32Array>;
  62250. /**
  62251. * Inverts the current matrix in place
  62252. * @returns the current inverted matrix
  62253. */
  62254. invert(): Matrix;
  62255. /**
  62256. * Sets all the matrix elements to zero
  62257. * @returns the current matrix
  62258. */
  62259. reset(): Matrix;
  62260. /**
  62261. * Adds the current matrix with a second one
  62262. * @param other defines the matrix to add
  62263. * @returns a new matrix as the addition of the current matrix and the given one
  62264. */
  62265. add(other: DeepImmutable<Matrix>): Matrix;
  62266. /**
  62267. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62268. * @param other defines the matrix to add
  62269. * @param result defines the target matrix
  62270. * @returns the current matrix
  62271. */
  62272. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62273. /**
  62274. * Adds in place the given matrix to the current matrix
  62275. * @param other defines the second operand
  62276. * @returns the current updated matrix
  62277. */
  62278. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62279. /**
  62280. * Sets the given matrix to the current inverted Matrix
  62281. * @param other defines the target matrix
  62282. * @returns the unmodified current matrix
  62283. */
  62284. invertToRef(other: Matrix): Matrix;
  62285. /**
  62286. * add a value at the specified position in the current Matrix
  62287. * @param index the index of the value within the matrix. between 0 and 15.
  62288. * @param value the value to be added
  62289. * @returns the current updated matrix
  62290. */
  62291. addAtIndex(index: number, value: number): Matrix;
  62292. /**
  62293. * mutiply the specified position in the current Matrix by a value
  62294. * @param index the index of the value within the matrix. between 0 and 15.
  62295. * @param value the value to be added
  62296. * @returns the current updated matrix
  62297. */
  62298. multiplyAtIndex(index: number, value: number): Matrix;
  62299. /**
  62300. * Inserts the translation vector (using 3 floats) in the current matrix
  62301. * @param x defines the 1st component of the translation
  62302. * @param y defines the 2nd component of the translation
  62303. * @param z defines the 3rd component of the translation
  62304. * @returns the current updated matrix
  62305. */
  62306. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62307. /**
  62308. * Inserts the translation vector in the current matrix
  62309. * @param vector3 defines the translation to insert
  62310. * @returns the current updated matrix
  62311. */
  62312. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62313. /**
  62314. * Gets the translation value of the current matrix
  62315. * @returns a new Vector3 as the extracted translation from the matrix
  62316. */
  62317. getTranslation(): Vector3;
  62318. /**
  62319. * Fill a Vector3 with the extracted translation from the matrix
  62320. * @param result defines the Vector3 where to store the translation
  62321. * @returns the current matrix
  62322. */
  62323. getTranslationToRef(result: Vector3): Matrix;
  62324. /**
  62325. * Remove rotation and scaling part from the matrix
  62326. * @returns the updated matrix
  62327. */
  62328. removeRotationAndScaling(): Matrix;
  62329. /**
  62330. * Multiply two matrices
  62331. * @param other defines the second operand
  62332. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62333. */
  62334. multiply(other: DeepImmutable<Matrix>): Matrix;
  62335. /**
  62336. * Copy the current matrix from the given one
  62337. * @param other defines the source matrix
  62338. * @returns the current updated matrix
  62339. */
  62340. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62341. /**
  62342. * Populates the given array from the starting index with the current matrix values
  62343. * @param array defines the target array
  62344. * @param offset defines the offset in the target array where to start storing values
  62345. * @returns the current matrix
  62346. */
  62347. copyToArray(array: Float32Array, offset?: number): Matrix;
  62348. /**
  62349. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62350. * @param other defines the second operand
  62351. * @param result defines the matrix where to store the multiplication
  62352. * @returns the current matrix
  62353. */
  62354. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62355. /**
  62356. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62357. * @param other defines the second operand
  62358. * @param result defines the array where to store the multiplication
  62359. * @param offset defines the offset in the target array where to start storing values
  62360. * @returns the current matrix
  62361. */
  62362. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62363. /**
  62364. * Check equality between this matrix and a second one
  62365. * @param value defines the second matrix to compare
  62366. * @returns true is the current matrix and the given one values are strictly equal
  62367. */
  62368. equals(value: DeepImmutable<Matrix>): boolean;
  62369. /**
  62370. * Clone the current matrix
  62371. * @returns a new matrix from the current matrix
  62372. */
  62373. clone(): Matrix;
  62374. /**
  62375. * Returns the name of the current matrix class
  62376. * @returns the string "Matrix"
  62377. */
  62378. getClassName(): string;
  62379. /**
  62380. * Gets the hash code of the current matrix
  62381. * @returns the hash code
  62382. */
  62383. getHashCode(): number;
  62384. /**
  62385. * Decomposes the current Matrix into a translation, rotation and scaling components
  62386. * @param scale defines the scale vector3 given as a reference to update
  62387. * @param rotation defines the rotation quaternion given as a reference to update
  62388. * @param translation defines the translation vector3 given as a reference to update
  62389. * @returns true if operation was successful
  62390. */
  62391. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62392. /**
  62393. * Gets specific row of the matrix
  62394. * @param index defines the number of the row to get
  62395. * @returns the index-th row of the current matrix as a new Vector4
  62396. */
  62397. getRow(index: number): Nullable<Vector4>;
  62398. /**
  62399. * Sets the index-th row of the current matrix to the vector4 values
  62400. * @param index defines the number of the row to set
  62401. * @param row defines the target vector4
  62402. * @returns the updated current matrix
  62403. */
  62404. setRow(index: number, row: Vector4): Matrix;
  62405. /**
  62406. * Compute the transpose of the matrix
  62407. * @returns the new transposed matrix
  62408. */
  62409. transpose(): Matrix;
  62410. /**
  62411. * Compute the transpose of the matrix and store it in a given matrix
  62412. * @param result defines the target matrix
  62413. * @returns the current matrix
  62414. */
  62415. transposeToRef(result: Matrix): Matrix;
  62416. /**
  62417. * Sets the index-th row of the current matrix with the given 4 x float values
  62418. * @param index defines the row index
  62419. * @param x defines the x component to set
  62420. * @param y defines the y component to set
  62421. * @param z defines the z component to set
  62422. * @param w defines the w component to set
  62423. * @returns the updated current matrix
  62424. */
  62425. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62426. /**
  62427. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62428. * @param scale defines the scale factor
  62429. * @returns a new matrix
  62430. */
  62431. scale(scale: number): Matrix;
  62432. /**
  62433. * Scale the current matrix values by a factor to a given result matrix
  62434. * @param scale defines the scale factor
  62435. * @param result defines the matrix to store the result
  62436. * @returns the current matrix
  62437. */
  62438. scaleToRef(scale: number, result: Matrix): Matrix;
  62439. /**
  62440. * Scale the current matrix values by a factor and add the result to a given matrix
  62441. * @param scale defines the scale factor
  62442. * @param result defines the Matrix to store the result
  62443. * @returns the current matrix
  62444. */
  62445. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62446. /**
  62447. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62448. * @param ref matrix to store the result
  62449. */
  62450. toNormalMatrix(ref: Matrix): void;
  62451. /**
  62452. * Gets only rotation part of the current matrix
  62453. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62454. */
  62455. getRotationMatrix(): Matrix;
  62456. /**
  62457. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62458. * @param result defines the target matrix to store data to
  62459. * @returns the current matrix
  62460. */
  62461. getRotationMatrixToRef(result: Matrix): Matrix;
  62462. /**
  62463. * Toggles model matrix from being right handed to left handed in place and vice versa
  62464. */
  62465. toggleModelMatrixHandInPlace(): void;
  62466. /**
  62467. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62468. */
  62469. toggleProjectionMatrixHandInPlace(): void;
  62470. /**
  62471. * Creates a matrix from an array
  62472. * @param array defines the source array
  62473. * @param offset defines an offset in the source array
  62474. * @returns a new Matrix set from the starting index of the given array
  62475. */
  62476. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62477. /**
  62478. * Copy the content of an array into a given matrix
  62479. * @param array defines the source array
  62480. * @param offset defines an offset in the source array
  62481. * @param result defines the target matrix
  62482. */
  62483. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62484. /**
  62485. * Stores an array into a matrix after having multiplied each component by a given factor
  62486. * @param array defines the source array
  62487. * @param offset defines the offset in the source array
  62488. * @param scale defines the scaling factor
  62489. * @param result defines the target matrix
  62490. */
  62491. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62492. /**
  62493. * Gets an identity matrix that must not be updated
  62494. */
  62495. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62496. /**
  62497. * Stores a list of values (16) inside a given matrix
  62498. * @param initialM11 defines 1st value of 1st row
  62499. * @param initialM12 defines 2nd value of 1st row
  62500. * @param initialM13 defines 3rd value of 1st row
  62501. * @param initialM14 defines 4th value of 1st row
  62502. * @param initialM21 defines 1st value of 2nd row
  62503. * @param initialM22 defines 2nd value of 2nd row
  62504. * @param initialM23 defines 3rd value of 2nd row
  62505. * @param initialM24 defines 4th value of 2nd row
  62506. * @param initialM31 defines 1st value of 3rd row
  62507. * @param initialM32 defines 2nd value of 3rd row
  62508. * @param initialM33 defines 3rd value of 3rd row
  62509. * @param initialM34 defines 4th value of 3rd row
  62510. * @param initialM41 defines 1st value of 4th row
  62511. * @param initialM42 defines 2nd value of 4th row
  62512. * @param initialM43 defines 3rd value of 4th row
  62513. * @param initialM44 defines 4th value of 4th row
  62514. * @param result defines the target matrix
  62515. */
  62516. 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;
  62517. /**
  62518. * Creates new matrix from a list of values (16)
  62519. * @param initialM11 defines 1st value of 1st row
  62520. * @param initialM12 defines 2nd value of 1st row
  62521. * @param initialM13 defines 3rd value of 1st row
  62522. * @param initialM14 defines 4th value of 1st row
  62523. * @param initialM21 defines 1st value of 2nd row
  62524. * @param initialM22 defines 2nd value of 2nd row
  62525. * @param initialM23 defines 3rd value of 2nd row
  62526. * @param initialM24 defines 4th value of 2nd row
  62527. * @param initialM31 defines 1st value of 3rd row
  62528. * @param initialM32 defines 2nd value of 3rd row
  62529. * @param initialM33 defines 3rd value of 3rd row
  62530. * @param initialM34 defines 4th value of 3rd row
  62531. * @param initialM41 defines 1st value of 4th row
  62532. * @param initialM42 defines 2nd value of 4th row
  62533. * @param initialM43 defines 3rd value of 4th row
  62534. * @param initialM44 defines 4th value of 4th row
  62535. * @returns the new matrix
  62536. */
  62537. 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;
  62538. /**
  62539. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62540. * @param scale defines the scale vector3
  62541. * @param rotation defines the rotation quaternion
  62542. * @param translation defines the translation vector3
  62543. * @returns a new matrix
  62544. */
  62545. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62546. /**
  62547. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62548. * @param scale defines the scale vector3
  62549. * @param rotation defines the rotation quaternion
  62550. * @param translation defines the translation vector3
  62551. * @param result defines the target matrix
  62552. */
  62553. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62554. /**
  62555. * Creates a new identity matrix
  62556. * @returns a new identity matrix
  62557. */
  62558. static Identity(): Matrix;
  62559. /**
  62560. * Creates a new identity matrix and stores the result in a given matrix
  62561. * @param result defines the target matrix
  62562. */
  62563. static IdentityToRef(result: Matrix): void;
  62564. /**
  62565. * Creates a new zero matrix
  62566. * @returns a new zero matrix
  62567. */
  62568. static Zero(): Matrix;
  62569. /**
  62570. * Creates a new rotation matrix for "angle" radians around the X axis
  62571. * @param angle defines the angle (in radians) to use
  62572. * @return the new matrix
  62573. */
  62574. static RotationX(angle: number): Matrix;
  62575. /**
  62576. * Creates a new matrix as the invert of a given matrix
  62577. * @param source defines the source matrix
  62578. * @returns the new matrix
  62579. */
  62580. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62581. /**
  62582. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62583. * @param angle defines the angle (in radians) to use
  62584. * @param result defines the target matrix
  62585. */
  62586. static RotationXToRef(angle: number, result: Matrix): void;
  62587. /**
  62588. * Creates a new rotation matrix for "angle" radians around the Y axis
  62589. * @param angle defines the angle (in radians) to use
  62590. * @return the new matrix
  62591. */
  62592. static RotationY(angle: number): Matrix;
  62593. /**
  62594. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62595. * @param angle defines the angle (in radians) to use
  62596. * @param result defines the target matrix
  62597. */
  62598. static RotationYToRef(angle: number, result: Matrix): void;
  62599. /**
  62600. * Creates a new rotation matrix for "angle" radians around the Z axis
  62601. * @param angle defines the angle (in radians) to use
  62602. * @return the new matrix
  62603. */
  62604. static RotationZ(angle: number): Matrix;
  62605. /**
  62606. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62607. * @param angle defines the angle (in radians) to use
  62608. * @param result defines the target matrix
  62609. */
  62610. static RotationZToRef(angle: number, result: Matrix): void;
  62611. /**
  62612. * Creates a new rotation matrix for "angle" radians around the given axis
  62613. * @param axis defines the axis to use
  62614. * @param angle defines the angle (in radians) to use
  62615. * @return the new matrix
  62616. */
  62617. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62618. /**
  62619. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62620. * @param axis defines the axis to use
  62621. * @param angle defines the angle (in radians) to use
  62622. * @param result defines the target matrix
  62623. */
  62624. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62625. /**
  62626. * Creates a rotation matrix
  62627. * @param yaw defines the yaw angle in radians (Y axis)
  62628. * @param pitch defines the pitch angle in radians (X axis)
  62629. * @param roll defines the roll angle in radians (X axis)
  62630. * @returns the new rotation matrix
  62631. */
  62632. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62633. /**
  62634. * Creates a rotation matrix and stores it in a given matrix
  62635. * @param yaw defines the yaw angle in radians (Y axis)
  62636. * @param pitch defines the pitch angle in radians (X axis)
  62637. * @param roll defines the roll angle in radians (X axis)
  62638. * @param result defines the target matrix
  62639. */
  62640. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62641. /**
  62642. * Creates a scaling matrix
  62643. * @param x defines the scale factor on X axis
  62644. * @param y defines the scale factor on Y axis
  62645. * @param z defines the scale factor on Z axis
  62646. * @returns the new matrix
  62647. */
  62648. static Scaling(x: number, y: number, z: number): Matrix;
  62649. /**
  62650. * Creates a scaling matrix and stores it in a given matrix
  62651. * @param x defines the scale factor on X axis
  62652. * @param y defines the scale factor on Y axis
  62653. * @param z defines the scale factor on Z axis
  62654. * @param result defines the target matrix
  62655. */
  62656. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62657. /**
  62658. * Creates a translation matrix
  62659. * @param x defines the translation on X axis
  62660. * @param y defines the translation on Y axis
  62661. * @param z defines the translationon Z axis
  62662. * @returns the new matrix
  62663. */
  62664. static Translation(x: number, y: number, z: number): Matrix;
  62665. /**
  62666. * Creates a translation matrix and stores it in a given matrix
  62667. * @param x defines the translation on X axis
  62668. * @param y defines the translation on Y axis
  62669. * @param z defines the translationon Z axis
  62670. * @param result defines the target matrix
  62671. */
  62672. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62673. /**
  62674. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62675. * @param startValue defines the start value
  62676. * @param endValue defines the end value
  62677. * @param gradient defines the gradient factor
  62678. * @returns the new matrix
  62679. */
  62680. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62681. /**
  62682. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62683. * @param startValue defines the start value
  62684. * @param endValue defines the end value
  62685. * @param gradient defines the gradient factor
  62686. * @param result defines the Matrix object where to store data
  62687. */
  62688. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62689. /**
  62690. * Builds a new matrix whose values are computed by:
  62691. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62692. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62693. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62694. * @param startValue defines the first matrix
  62695. * @param endValue defines the second matrix
  62696. * @param gradient defines the gradient between the two matrices
  62697. * @returns the new matrix
  62698. */
  62699. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62700. /**
  62701. * Update a matrix to values which are computed by:
  62702. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62703. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62704. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62705. * @param startValue defines the first matrix
  62706. * @param endValue defines the second matrix
  62707. * @param gradient defines the gradient between the two matrices
  62708. * @param result defines the target matrix
  62709. */
  62710. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62711. /**
  62712. * 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"
  62713. * This function works in left handed mode
  62714. * @param eye defines the final position of the entity
  62715. * @param target defines where the entity should look at
  62716. * @param up defines the up vector for the entity
  62717. * @returns the new matrix
  62718. */
  62719. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62720. /**
  62721. * 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".
  62722. * This function works in left handed mode
  62723. * @param eye defines the final position of the entity
  62724. * @param target defines where the entity should look at
  62725. * @param up defines the up vector for the entity
  62726. * @param result defines the target matrix
  62727. */
  62728. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62729. /**
  62730. * 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"
  62731. * This function works in right handed mode
  62732. * @param eye defines the final position of the entity
  62733. * @param target defines where the entity should look at
  62734. * @param up defines the up vector for the entity
  62735. * @returns the new matrix
  62736. */
  62737. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62738. /**
  62739. * 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".
  62740. * This function works in right handed mode
  62741. * @param eye defines the final position of the entity
  62742. * @param target defines where the entity should look at
  62743. * @param up defines the up vector for the entity
  62744. * @param result defines the target matrix
  62745. */
  62746. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62747. /**
  62748. * Create a left-handed orthographic projection matrix
  62749. * @param width defines the viewport width
  62750. * @param height defines the viewport height
  62751. * @param znear defines the near clip plane
  62752. * @param zfar defines the far clip plane
  62753. * @returns a new matrix as a left-handed orthographic projection matrix
  62754. */
  62755. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62756. /**
  62757. * Store a left-handed orthographic projection to a given matrix
  62758. * @param width defines the viewport width
  62759. * @param height defines the viewport height
  62760. * @param znear defines the near clip plane
  62761. * @param zfar defines the far clip plane
  62762. * @param result defines the target matrix
  62763. */
  62764. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62765. /**
  62766. * Create a left-handed orthographic projection matrix
  62767. * @param left defines the viewport left coordinate
  62768. * @param right defines the viewport right coordinate
  62769. * @param bottom defines the viewport bottom coordinate
  62770. * @param top defines the viewport top coordinate
  62771. * @param znear defines the near clip plane
  62772. * @param zfar defines the far clip plane
  62773. * @returns a new matrix as a left-handed orthographic projection matrix
  62774. */
  62775. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62776. /**
  62777. * Stores a left-handed orthographic projection into a given matrix
  62778. * @param left defines the viewport left coordinate
  62779. * @param right defines the viewport right coordinate
  62780. * @param bottom defines the viewport bottom coordinate
  62781. * @param top defines the viewport top coordinate
  62782. * @param znear defines the near clip plane
  62783. * @param zfar defines the far clip plane
  62784. * @param result defines the target matrix
  62785. */
  62786. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62787. /**
  62788. * Creates a right-handed orthographic projection matrix
  62789. * @param left defines the viewport left coordinate
  62790. * @param right defines the viewport right coordinate
  62791. * @param bottom defines the viewport bottom coordinate
  62792. * @param top defines the viewport top coordinate
  62793. * @param znear defines the near clip plane
  62794. * @param zfar defines the far clip plane
  62795. * @returns a new matrix as a right-handed orthographic projection matrix
  62796. */
  62797. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62798. /**
  62799. * Stores a right-handed orthographic projection into a given matrix
  62800. * @param left defines the viewport left coordinate
  62801. * @param right defines the viewport right coordinate
  62802. * @param bottom defines the viewport bottom coordinate
  62803. * @param top defines the viewport top coordinate
  62804. * @param znear defines the near clip plane
  62805. * @param zfar defines the far clip plane
  62806. * @param result defines the target matrix
  62807. */
  62808. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62809. /**
  62810. * Creates a left-handed perspective projection matrix
  62811. * @param width defines the viewport width
  62812. * @param height defines the viewport height
  62813. * @param znear defines the near clip plane
  62814. * @param zfar defines the far clip plane
  62815. * @returns a new matrix as a left-handed perspective projection matrix
  62816. */
  62817. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62818. /**
  62819. * Creates a left-handed perspective projection matrix
  62820. * @param fov defines the horizontal field of view
  62821. * @param aspect defines the aspect ratio
  62822. * @param znear defines the near clip plane
  62823. * @param zfar defines the far clip plane
  62824. * @returns a new matrix as a left-handed perspective projection matrix
  62825. */
  62826. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62827. /**
  62828. * Stores a left-handed perspective projection into a given matrix
  62829. * @param fov defines the horizontal field of view
  62830. * @param aspect defines the aspect ratio
  62831. * @param znear defines the near clip plane
  62832. * @param zfar defines the far clip plane
  62833. * @param result defines the target matrix
  62834. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62835. */
  62836. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62837. /**
  62838. * Creates a right-handed perspective projection matrix
  62839. * @param fov defines the horizontal field of view
  62840. * @param aspect defines the aspect ratio
  62841. * @param znear defines the near clip plane
  62842. * @param zfar defines the far clip plane
  62843. * @returns a new matrix as a right-handed perspective projection matrix
  62844. */
  62845. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62846. /**
  62847. * Stores a right-handed perspective projection into a given matrix
  62848. * @param fov defines the horizontal field of view
  62849. * @param aspect defines the aspect ratio
  62850. * @param znear defines the near clip plane
  62851. * @param zfar defines the far clip plane
  62852. * @param result defines the target matrix
  62853. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62854. */
  62855. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62856. /**
  62857. * Stores a perspective projection for WebVR info a given matrix
  62858. * @param fov defines the field of view
  62859. * @param znear defines the near clip plane
  62860. * @param zfar defines the far clip plane
  62861. * @param result defines the target matrix
  62862. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62863. */
  62864. static PerspectiveFovWebVRToRef(fov: {
  62865. upDegrees: number;
  62866. downDegrees: number;
  62867. leftDegrees: number;
  62868. rightDegrees: number;
  62869. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62870. /**
  62871. * Computes a complete transformation matrix
  62872. * @param viewport defines the viewport to use
  62873. * @param world defines the world matrix
  62874. * @param view defines the view matrix
  62875. * @param projection defines the projection matrix
  62876. * @param zmin defines the near clip plane
  62877. * @param zmax defines the far clip plane
  62878. * @returns the transformation matrix
  62879. */
  62880. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62881. /**
  62882. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62883. * @param matrix defines the matrix to use
  62884. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62885. */
  62886. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62887. /**
  62888. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62889. * @param matrix defines the matrix to use
  62890. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62891. */
  62892. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62893. /**
  62894. * Compute the transpose of a given matrix
  62895. * @param matrix defines the matrix to transpose
  62896. * @returns the new matrix
  62897. */
  62898. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62899. /**
  62900. * Compute the transpose of a matrix and store it in a target matrix
  62901. * @param matrix defines the matrix to transpose
  62902. * @param result defines the target matrix
  62903. */
  62904. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62905. /**
  62906. * Computes a reflection matrix from a plane
  62907. * @param plane defines the reflection plane
  62908. * @returns a new matrix
  62909. */
  62910. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62911. /**
  62912. * Computes a reflection matrix from a plane
  62913. * @param plane defines the reflection plane
  62914. * @param result defines the target matrix
  62915. */
  62916. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62917. /**
  62918. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62919. * @param xaxis defines the value of the 1st axis
  62920. * @param yaxis defines the value of the 2nd axis
  62921. * @param zaxis defines the value of the 3rd axis
  62922. * @param result defines the target matrix
  62923. */
  62924. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62925. /**
  62926. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62927. * @param quat defines the quaternion to use
  62928. * @param result defines the target matrix
  62929. */
  62930. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62931. }
  62932. /**
  62933. * Represens a plane by the equation ax + by + cz + d = 0
  62934. */
  62935. export class Plane {
  62936. /**
  62937. * Normal of the plane (a,b,c)
  62938. */
  62939. normal: Vector3;
  62940. /**
  62941. * d component of the plane
  62942. */
  62943. d: number;
  62944. /**
  62945. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62946. * @param a a component of the plane
  62947. * @param b b component of the plane
  62948. * @param c c component of the plane
  62949. * @param d d component of the plane
  62950. */
  62951. constructor(a: number, b: number, c: number, d: number);
  62952. /**
  62953. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62954. */
  62955. asArray(): number[];
  62956. /**
  62957. * @returns a new plane copied from the current Plane.
  62958. */
  62959. clone(): Plane;
  62960. /**
  62961. * @returns the string "Plane".
  62962. */
  62963. getClassName(): string;
  62964. /**
  62965. * @returns the Plane hash code.
  62966. */
  62967. getHashCode(): number;
  62968. /**
  62969. * Normalize the current Plane in place.
  62970. * @returns the updated Plane.
  62971. */
  62972. normalize(): Plane;
  62973. /**
  62974. * Applies a transformation the plane and returns the result
  62975. * @param transformation the transformation matrix to be applied to the plane
  62976. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62977. */
  62978. transform(transformation: DeepImmutable<Matrix>): Plane;
  62979. /**
  62980. * Calcualtte the dot product between the point and the plane normal
  62981. * @param point point to calculate the dot product with
  62982. * @returns the dot product (float) of the point coordinates and the plane normal.
  62983. */
  62984. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62985. /**
  62986. * Updates the current Plane from the plane defined by the three given points.
  62987. * @param point1 one of the points used to contruct the plane
  62988. * @param point2 one of the points used to contruct the plane
  62989. * @param point3 one of the points used to contruct the plane
  62990. * @returns the updated Plane.
  62991. */
  62992. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62993. /**
  62994. * Checks if the plane is facing a given direction
  62995. * @param direction the direction to check if the plane is facing
  62996. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62997. * @returns True is the vector "direction" is the same side than the plane normal.
  62998. */
  62999. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63000. /**
  63001. * Calculates the distance to a point
  63002. * @param point point to calculate distance to
  63003. * @returns the signed distance (float) from the given point to the Plane.
  63004. */
  63005. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63006. /**
  63007. * Creates a plane from an array
  63008. * @param array the array to create a plane from
  63009. * @returns a new Plane from the given array.
  63010. */
  63011. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63012. /**
  63013. * Creates a plane from three points
  63014. * @param point1 point used to create the plane
  63015. * @param point2 point used to create the plane
  63016. * @param point3 point used to create the plane
  63017. * @returns a new Plane defined by the three given points.
  63018. */
  63019. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63020. /**
  63021. * Creates a plane from an origin point and a normal
  63022. * @param origin origin of the plane to be constructed
  63023. * @param normal normal of the plane to be constructed
  63024. * @returns a new Plane the normal vector to this plane at the given origin point.
  63025. * Note : the vector "normal" is updated because normalized.
  63026. */
  63027. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63028. /**
  63029. * Calculates the distance from a plane and a point
  63030. * @param origin origin of the plane to be constructed
  63031. * @param normal normal of the plane to be constructed
  63032. * @param point point to calculate distance to
  63033. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63034. */
  63035. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63036. }
  63037. /**
  63038. * Class used to represent a viewport on screen
  63039. */
  63040. export class Viewport {
  63041. /** viewport left coordinate */
  63042. x: number;
  63043. /** viewport top coordinate */
  63044. y: number;
  63045. /**viewport width */
  63046. width: number;
  63047. /** viewport height */
  63048. height: number;
  63049. /**
  63050. * Creates a Viewport object located at (x, y) and sized (width, height)
  63051. * @param x defines viewport left coordinate
  63052. * @param y defines viewport top coordinate
  63053. * @param width defines the viewport width
  63054. * @param height defines the viewport height
  63055. */
  63056. constructor(
  63057. /** viewport left coordinate */
  63058. x: number,
  63059. /** viewport top coordinate */
  63060. y: number,
  63061. /**viewport width */
  63062. width: number,
  63063. /** viewport height */
  63064. height: number);
  63065. /**
  63066. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63067. * @param renderWidth defines the rendering width
  63068. * @param renderHeight defines the rendering height
  63069. * @returns a new Viewport
  63070. */
  63071. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63072. /**
  63073. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63074. * @param renderWidth defines the rendering width
  63075. * @param renderHeight defines the rendering height
  63076. * @param ref defines the target viewport
  63077. * @returns the current viewport
  63078. */
  63079. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63080. /**
  63081. * Returns a new Viewport copied from the current one
  63082. * @returns a new Viewport
  63083. */
  63084. clone(): Viewport;
  63085. }
  63086. /**
  63087. * Reprasents a camera frustum
  63088. */
  63089. export class Frustum {
  63090. /**
  63091. * Gets the planes representing the frustum
  63092. * @param transform matrix to be applied to the returned planes
  63093. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63094. */
  63095. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63096. /**
  63097. * Gets the near frustum plane transformed by the transform matrix
  63098. * @param transform transformation matrix to be applied to the resulting frustum plane
  63099. * @param frustumPlane the resuling frustum plane
  63100. */
  63101. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63102. /**
  63103. * Gets the far frustum plane transformed by the transform matrix
  63104. * @param transform transformation matrix to be applied to the resulting frustum plane
  63105. * @param frustumPlane the resuling frustum plane
  63106. */
  63107. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63108. /**
  63109. * Gets the left frustum plane transformed by the transform matrix
  63110. * @param transform transformation matrix to be applied to the resulting frustum plane
  63111. * @param frustumPlane the resuling frustum plane
  63112. */
  63113. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63114. /**
  63115. * Gets the right frustum plane transformed by the transform matrix
  63116. * @param transform transformation matrix to be applied to the resulting frustum plane
  63117. * @param frustumPlane the resuling frustum plane
  63118. */
  63119. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63120. /**
  63121. * Gets the top frustum plane transformed by the transform matrix
  63122. * @param transform transformation matrix to be applied to the resulting frustum plane
  63123. * @param frustumPlane the resuling frustum plane
  63124. */
  63125. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63126. /**
  63127. * Gets the bottom frustum plane transformed by the transform matrix
  63128. * @param transform transformation matrix to be applied to the resulting frustum plane
  63129. * @param frustumPlane the resuling frustum plane
  63130. */
  63131. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63132. /**
  63133. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63134. * @param transform transformation matrix to be applied to the resulting frustum planes
  63135. * @param frustumPlanes the resuling frustum planes
  63136. */
  63137. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63138. }
  63139. /** Defines supported spaces */
  63140. export enum Space {
  63141. /** Local (object) space */
  63142. LOCAL = 0,
  63143. /** World space */
  63144. WORLD = 1,
  63145. /** Bone space */
  63146. BONE = 2
  63147. }
  63148. /** Defines the 3 main axes */
  63149. export class Axis {
  63150. /** X axis */
  63151. static X: Vector3;
  63152. /** Y axis */
  63153. static Y: Vector3;
  63154. /** Z axis */
  63155. static Z: Vector3;
  63156. }
  63157. /** Class used to represent a Bezier curve */
  63158. export class BezierCurve {
  63159. /**
  63160. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63161. * @param t defines the time
  63162. * @param x1 defines the left coordinate on X axis
  63163. * @param y1 defines the left coordinate on Y axis
  63164. * @param x2 defines the right coordinate on X axis
  63165. * @param y2 defines the right coordinate on Y axis
  63166. * @returns the interpolated value
  63167. */
  63168. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63169. }
  63170. /**
  63171. * Defines potential orientation for back face culling
  63172. */
  63173. export enum Orientation {
  63174. /**
  63175. * Clockwise
  63176. */
  63177. CW = 0,
  63178. /** Counter clockwise */
  63179. CCW = 1
  63180. }
  63181. /**
  63182. * Defines angle representation
  63183. */
  63184. export class Angle {
  63185. private _radians;
  63186. /**
  63187. * Creates an Angle object of "radians" radians (float).
  63188. * @param radians the angle in radians
  63189. */
  63190. constructor(radians: number);
  63191. /**
  63192. * Get value in degrees
  63193. * @returns the Angle value in degrees (float)
  63194. */
  63195. degrees(): number;
  63196. /**
  63197. * Get value in radians
  63198. * @returns the Angle value in radians (float)
  63199. */
  63200. radians(): number;
  63201. /**
  63202. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63203. * @param a defines first vector
  63204. * @param b defines second vector
  63205. * @returns a new Angle
  63206. */
  63207. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63208. /**
  63209. * Gets a new Angle object from the given float in radians
  63210. * @param radians defines the angle value in radians
  63211. * @returns a new Angle
  63212. */
  63213. static FromRadians(radians: number): Angle;
  63214. /**
  63215. * Gets a new Angle object from the given float in degrees
  63216. * @param degrees defines the angle value in degrees
  63217. * @returns a new Angle
  63218. */
  63219. static FromDegrees(degrees: number): Angle;
  63220. }
  63221. /**
  63222. * This represents an arc in a 2d space.
  63223. */
  63224. export class Arc2 {
  63225. /** Defines the start point of the arc */
  63226. startPoint: Vector2;
  63227. /** Defines the mid point of the arc */
  63228. midPoint: Vector2;
  63229. /** Defines the end point of the arc */
  63230. endPoint: Vector2;
  63231. /**
  63232. * Defines the center point of the arc.
  63233. */
  63234. centerPoint: Vector2;
  63235. /**
  63236. * Defines the radius of the arc.
  63237. */
  63238. radius: number;
  63239. /**
  63240. * Defines the angle of the arc (from mid point to end point).
  63241. */
  63242. angle: Angle;
  63243. /**
  63244. * Defines the start angle of the arc (from start point to middle point).
  63245. */
  63246. startAngle: Angle;
  63247. /**
  63248. * Defines the orientation of the arc (clock wise/counter clock wise).
  63249. */
  63250. orientation: Orientation;
  63251. /**
  63252. * Creates an Arc object from the three given points : start, middle and end.
  63253. * @param startPoint Defines the start point of the arc
  63254. * @param midPoint Defines the midlle point of the arc
  63255. * @param endPoint Defines the end point of the arc
  63256. */
  63257. constructor(
  63258. /** Defines the start point of the arc */
  63259. startPoint: Vector2,
  63260. /** Defines the mid point of the arc */
  63261. midPoint: Vector2,
  63262. /** Defines the end point of the arc */
  63263. endPoint: Vector2);
  63264. }
  63265. /**
  63266. * Represents a 2D path made up of multiple 2D points
  63267. */
  63268. export class Path2 {
  63269. private _points;
  63270. private _length;
  63271. /**
  63272. * If the path start and end point are the same
  63273. */
  63274. closed: boolean;
  63275. /**
  63276. * Creates a Path2 object from the starting 2D coordinates x and y.
  63277. * @param x the starting points x value
  63278. * @param y the starting points y value
  63279. */
  63280. constructor(x: number, y: number);
  63281. /**
  63282. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63283. * @param x the added points x value
  63284. * @param y the added points y value
  63285. * @returns the updated Path2.
  63286. */
  63287. addLineTo(x: number, y: number): Path2;
  63288. /**
  63289. * 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.
  63290. * @param midX middle point x value
  63291. * @param midY middle point y value
  63292. * @param endX end point x value
  63293. * @param endY end point y value
  63294. * @param numberOfSegments (default: 36)
  63295. * @returns the updated Path2.
  63296. */
  63297. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63298. /**
  63299. * Closes the Path2.
  63300. * @returns the Path2.
  63301. */
  63302. close(): Path2;
  63303. /**
  63304. * Gets the sum of the distance between each sequential point in the path
  63305. * @returns the Path2 total length (float).
  63306. */
  63307. length(): number;
  63308. /**
  63309. * Gets the points which construct the path
  63310. * @returns the Path2 internal array of points.
  63311. */
  63312. getPoints(): Vector2[];
  63313. /**
  63314. * Retreives the point at the distance aways from the starting point
  63315. * @param normalizedLengthPosition the length along the path to retreive the point from
  63316. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63317. */
  63318. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63319. /**
  63320. * Creates a new path starting from an x and y position
  63321. * @param x starting x value
  63322. * @param y starting y value
  63323. * @returns a new Path2 starting at the coordinates (x, y).
  63324. */
  63325. static StartingAt(x: number, y: number): Path2;
  63326. }
  63327. /**
  63328. * Represents a 3D path made up of multiple 3D points
  63329. */
  63330. export class Path3D {
  63331. /**
  63332. * an array of Vector3, the curve axis of the Path3D
  63333. */
  63334. path: Vector3[];
  63335. private _curve;
  63336. private _distances;
  63337. private _tangents;
  63338. private _normals;
  63339. private _binormals;
  63340. private _raw;
  63341. /**
  63342. * new Path3D(path, normal, raw)
  63343. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63344. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63345. * @param path an array of Vector3, the curve axis of the Path3D
  63346. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63347. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63348. */
  63349. constructor(
  63350. /**
  63351. * an array of Vector3, the curve axis of the Path3D
  63352. */
  63353. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63354. /**
  63355. * Returns the Path3D array of successive Vector3 designing its curve.
  63356. * @returns the Path3D array of successive Vector3 designing its curve.
  63357. */
  63358. getCurve(): Vector3[];
  63359. /**
  63360. * Returns an array populated with tangent vectors on each Path3D curve point.
  63361. * @returns an array populated with tangent vectors on each Path3D curve point.
  63362. */
  63363. getTangents(): Vector3[];
  63364. /**
  63365. * Returns an array populated with normal vectors on each Path3D curve point.
  63366. * @returns an array populated with normal vectors on each Path3D curve point.
  63367. */
  63368. getNormals(): Vector3[];
  63369. /**
  63370. * Returns an array populated with binormal vectors on each Path3D curve point.
  63371. * @returns an array populated with binormal vectors on each Path3D curve point.
  63372. */
  63373. getBinormals(): Vector3[];
  63374. /**
  63375. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63376. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63377. */
  63378. getDistances(): number[];
  63379. /**
  63380. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63381. * @param path path which all values are copied into the curves points
  63382. * @param firstNormal which should be projected onto the curve
  63383. * @returns the same object updated.
  63384. */
  63385. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63386. private _compute;
  63387. private _getFirstNonNullVector;
  63388. private _getLastNonNullVector;
  63389. private _normalVector;
  63390. }
  63391. /**
  63392. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63393. * A Curve3 is designed from a series of successive Vector3.
  63394. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63395. */
  63396. export class Curve3 {
  63397. private _points;
  63398. private _length;
  63399. /**
  63400. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63401. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63402. * @param v1 (Vector3) the control point
  63403. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63404. * @param nbPoints (integer) the wanted number of points in the curve
  63405. * @returns the created Curve3
  63406. */
  63407. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63408. /**
  63409. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63410. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63411. * @param v1 (Vector3) the first control point
  63412. * @param v2 (Vector3) the second control point
  63413. * @param v3 (Vector3) the end point of the Cubic Bezier
  63414. * @param nbPoints (integer) the wanted number of points in the curve
  63415. * @returns the created Curve3
  63416. */
  63417. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63418. /**
  63419. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63420. * @param p1 (Vector3) the origin point of the Hermite Spline
  63421. * @param t1 (Vector3) the tangent vector at the origin point
  63422. * @param p2 (Vector3) the end point of the Hermite Spline
  63423. * @param t2 (Vector3) the tangent vector at the end point
  63424. * @param nbPoints (integer) the wanted number of points in the curve
  63425. * @returns the created Curve3
  63426. */
  63427. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63428. /**
  63429. * Returns a Curve3 object along a CatmullRom Spline curve :
  63430. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63431. * @param nbPoints (integer) the wanted number of points between each curve control points
  63432. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63433. * @returns the created Curve3
  63434. */
  63435. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63436. /**
  63437. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63438. * A Curve3 is designed from a series of successive Vector3.
  63439. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63440. * @param points points which make up the curve
  63441. */
  63442. constructor(points: Vector3[]);
  63443. /**
  63444. * @returns the Curve3 stored array of successive Vector3
  63445. */
  63446. getPoints(): Vector3[];
  63447. /**
  63448. * @returns the computed length (float) of the curve.
  63449. */
  63450. length(): number;
  63451. /**
  63452. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63453. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63454. * curveA and curveB keep unchanged.
  63455. * @param curve the curve to continue from this curve
  63456. * @returns the newly constructed curve
  63457. */
  63458. continue(curve: DeepImmutable<Curve3>): Curve3;
  63459. private _computeLength;
  63460. }
  63461. /**
  63462. * Contains position and normal vectors for a vertex
  63463. */
  63464. export class PositionNormalVertex {
  63465. /** the position of the vertex (defaut: 0,0,0) */
  63466. position: Vector3;
  63467. /** the normal of the vertex (defaut: 0,1,0) */
  63468. normal: Vector3;
  63469. /**
  63470. * Creates a PositionNormalVertex
  63471. * @param position the position of the vertex (defaut: 0,0,0)
  63472. * @param normal the normal of the vertex (defaut: 0,1,0)
  63473. */
  63474. constructor(
  63475. /** the position of the vertex (defaut: 0,0,0) */
  63476. position?: Vector3,
  63477. /** the normal of the vertex (defaut: 0,1,0) */
  63478. normal?: Vector3);
  63479. /**
  63480. * Clones the PositionNormalVertex
  63481. * @returns the cloned PositionNormalVertex
  63482. */
  63483. clone(): PositionNormalVertex;
  63484. }
  63485. /**
  63486. * Contains position, normal and uv vectors for a vertex
  63487. */
  63488. export class PositionNormalTextureVertex {
  63489. /** the position of the vertex (defaut: 0,0,0) */
  63490. position: Vector3;
  63491. /** the normal of the vertex (defaut: 0,1,0) */
  63492. normal: Vector3;
  63493. /** the uv of the vertex (default: 0,0) */
  63494. uv: Vector2;
  63495. /**
  63496. * Creates a PositionNormalTextureVertex
  63497. * @param position the position of the vertex (defaut: 0,0,0)
  63498. * @param normal the normal of the vertex (defaut: 0,1,0)
  63499. * @param uv the uv of the vertex (default: 0,0)
  63500. */
  63501. constructor(
  63502. /** the position of the vertex (defaut: 0,0,0) */
  63503. position?: Vector3,
  63504. /** the normal of the vertex (defaut: 0,1,0) */
  63505. normal?: Vector3,
  63506. /** the uv of the vertex (default: 0,0) */
  63507. uv?: Vector2);
  63508. /**
  63509. * Clones the PositionNormalTextureVertex
  63510. * @returns the cloned PositionNormalTextureVertex
  63511. */
  63512. clone(): PositionNormalTextureVertex;
  63513. }
  63514. /**
  63515. * @hidden
  63516. */
  63517. export class Tmp {
  63518. static Color3: Color3[];
  63519. static Color4: Color4[];
  63520. static Vector2: Vector2[];
  63521. static Vector3: Vector3[];
  63522. static Vector4: Vector4[];
  63523. static Quaternion: Quaternion[];
  63524. static Matrix: Matrix[];
  63525. }
  63526. }
  63527. declare module BABYLON {
  63528. /**
  63529. * Class used to enable access to offline support
  63530. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63531. */
  63532. export interface IOfflineProvider {
  63533. /**
  63534. * Gets a boolean indicating if scene must be saved in the database
  63535. */
  63536. enableSceneOffline: boolean;
  63537. /**
  63538. * Gets a boolean indicating if textures must be saved in the database
  63539. */
  63540. enableTexturesOffline: boolean;
  63541. /**
  63542. * Open the offline support and make it available
  63543. * @param successCallback defines the callback to call on success
  63544. * @param errorCallback defines the callback to call on error
  63545. */
  63546. open(successCallback: () => void, errorCallback: () => void): void;
  63547. /**
  63548. * Loads an image from the offline support
  63549. * @param url defines the url to load from
  63550. * @param image defines the target DOM image
  63551. */
  63552. loadImage(url: string, image: HTMLImageElement): void;
  63553. /**
  63554. * Loads a file from offline support
  63555. * @param url defines the URL to load from
  63556. * @param sceneLoaded defines a callback to call on success
  63557. * @param progressCallBack defines a callback to call when progress changed
  63558. * @param errorCallback defines a callback to call on error
  63559. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63560. */
  63561. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63562. }
  63563. }
  63564. declare module BABYLON {
  63565. /**
  63566. * A class serves as a medium between the observable and its observers
  63567. */
  63568. export class EventState {
  63569. /**
  63570. * Create a new EventState
  63571. * @param mask defines the mask associated with this state
  63572. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63573. * @param target defines the original target of the state
  63574. * @param currentTarget defines the current target of the state
  63575. */
  63576. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63577. /**
  63578. * Initialize the current event state
  63579. * @param mask defines the mask associated with this state
  63580. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63581. * @param target defines the original target of the state
  63582. * @param currentTarget defines the current target of the state
  63583. * @returns the current event state
  63584. */
  63585. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63586. /**
  63587. * An Observer can set this property to true to prevent subsequent observers of being notified
  63588. */
  63589. skipNextObservers: boolean;
  63590. /**
  63591. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63592. */
  63593. mask: number;
  63594. /**
  63595. * The object that originally notified the event
  63596. */
  63597. target?: any;
  63598. /**
  63599. * The current object in the bubbling phase
  63600. */
  63601. currentTarget?: any;
  63602. /**
  63603. * This will be populated with the return value of the last function that was executed.
  63604. * If it is the first function in the callback chain it will be the event data.
  63605. */
  63606. lastReturnValue?: any;
  63607. }
  63608. /**
  63609. * Represent an Observer registered to a given Observable object.
  63610. */
  63611. export class Observer<T> {
  63612. /**
  63613. * Defines the callback to call when the observer is notified
  63614. */
  63615. callback: (eventData: T, eventState: EventState) => void;
  63616. /**
  63617. * Defines the mask of the observer (used to filter notifications)
  63618. */
  63619. mask: number;
  63620. /**
  63621. * Defines the current scope used to restore the JS context
  63622. */
  63623. scope: any;
  63624. /** @hidden */
  63625. _willBeUnregistered: boolean;
  63626. /**
  63627. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63628. */
  63629. unregisterOnNextCall: boolean;
  63630. /**
  63631. * Creates a new observer
  63632. * @param callback defines the callback to call when the observer is notified
  63633. * @param mask defines the mask of the observer (used to filter notifications)
  63634. * @param scope defines the current scope used to restore the JS context
  63635. */
  63636. constructor(
  63637. /**
  63638. * Defines the callback to call when the observer is notified
  63639. */
  63640. callback: (eventData: T, eventState: EventState) => void,
  63641. /**
  63642. * Defines the mask of the observer (used to filter notifications)
  63643. */
  63644. mask: number,
  63645. /**
  63646. * Defines the current scope used to restore the JS context
  63647. */
  63648. scope?: any);
  63649. }
  63650. /**
  63651. * Represent a list of observers registered to multiple Observables object.
  63652. */
  63653. export class MultiObserver<T> {
  63654. private _observers;
  63655. private _observables;
  63656. /**
  63657. * Release associated resources
  63658. */
  63659. dispose(): void;
  63660. /**
  63661. * Raise a callback when one of the observable will notify
  63662. * @param observables defines a list of observables to watch
  63663. * @param callback defines the callback to call on notification
  63664. * @param mask defines the mask used to filter notifications
  63665. * @param scope defines the current scope used to restore the JS context
  63666. * @returns the new MultiObserver
  63667. */
  63668. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63669. }
  63670. /**
  63671. * The Observable class is a simple implementation of the Observable pattern.
  63672. *
  63673. * 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.
  63674. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63675. * 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).
  63676. * 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.
  63677. */
  63678. export class Observable<T> {
  63679. private _observers;
  63680. private _eventState;
  63681. private _onObserverAdded;
  63682. /**
  63683. * Creates a new observable
  63684. * @param onObserverAdded defines a callback to call when a new observer is added
  63685. */
  63686. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63687. /**
  63688. * Create a new Observer with the specified callback
  63689. * @param callback the callback that will be executed for that Observer
  63690. * @param mask the mask used to filter observers
  63691. * @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.
  63692. * @param scope optional scope for the callback to be called from
  63693. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63694. * @returns the new observer created for the callback
  63695. */
  63696. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63697. /**
  63698. * Create a new Observer with the specified callback and unregisters after the next notification
  63699. * @param callback the callback that will be executed for that Observer
  63700. * @returns the new observer created for the callback
  63701. */
  63702. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63703. /**
  63704. * Remove an Observer from the Observable object
  63705. * @param observer the instance of the Observer to remove
  63706. * @returns false if it doesn't belong to this Observable
  63707. */
  63708. remove(observer: Nullable<Observer<T>>): boolean;
  63709. /**
  63710. * Remove a callback from the Observable object
  63711. * @param callback the callback to remove
  63712. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63713. * @returns false if it doesn't belong to this Observable
  63714. */
  63715. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63716. private _deferUnregister;
  63717. private _remove;
  63718. /**
  63719. * Moves the observable to the top of the observer list making it get called first when notified
  63720. * @param observer the observer to move
  63721. */
  63722. makeObserverTopPriority(observer: Observer<T>): void;
  63723. /**
  63724. * Moves the observable to the bottom of the observer list making it get called last when notified
  63725. * @param observer the observer to move
  63726. */
  63727. makeObserverBottomPriority(observer: Observer<T>): void;
  63728. /**
  63729. * Notify all Observers by calling their respective callback with the given data
  63730. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63731. * @param eventData defines the data to send to all observers
  63732. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63733. * @param target defines the original target of the state
  63734. * @param currentTarget defines the current target of the state
  63735. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63736. */
  63737. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63738. /**
  63739. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63740. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63741. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63742. * and it is crucial that all callbacks will be executed.
  63743. * The order of the callbacks is kept, callbacks are not executed parallel.
  63744. *
  63745. * @param eventData The data to be sent to each callback
  63746. * @param mask is used to filter observers defaults to -1
  63747. * @param target defines the callback target (see EventState)
  63748. * @param currentTarget defines he current object in the bubbling phase
  63749. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63750. */
  63751. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63752. /**
  63753. * Notify a specific observer
  63754. * @param observer defines the observer to notify
  63755. * @param eventData defines the data to be sent to each callback
  63756. * @param mask is used to filter observers defaults to -1
  63757. */
  63758. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63759. /**
  63760. * Gets a boolean indicating if the observable has at least one observer
  63761. * @returns true is the Observable has at least one Observer registered
  63762. */
  63763. hasObservers(): boolean;
  63764. /**
  63765. * Clear the list of observers
  63766. */
  63767. clear(): void;
  63768. /**
  63769. * Clone the current observable
  63770. * @returns a new observable
  63771. */
  63772. clone(): Observable<T>;
  63773. /**
  63774. * Does this observable handles observer registered with a given mask
  63775. * @param mask defines the mask to be tested
  63776. * @return whether or not one observer registered with the given mask is handeled
  63777. **/
  63778. hasSpecificMask(mask?: number): boolean;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Class used to help managing file picking and drag'n'drop
  63784. * File Storage
  63785. */
  63786. export class FilesInputStore {
  63787. /**
  63788. * List of files ready to be loaded
  63789. */
  63790. static FilesToLoad: {
  63791. [key: string]: File;
  63792. };
  63793. }
  63794. }
  63795. declare module BABYLON {
  63796. /** Defines the cross module used constants to avoid circular dependncies */
  63797. export class Constants {
  63798. /** Defines that alpha blending is disabled */
  63799. static readonly ALPHA_DISABLE: number;
  63800. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63801. static readonly ALPHA_ADD: number;
  63802. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63803. static readonly ALPHA_COMBINE: number;
  63804. /** Defines that alpha blending to DEST - SRC * DEST */
  63805. static readonly ALPHA_SUBTRACT: number;
  63806. /** Defines that alpha blending to SRC * DEST */
  63807. static readonly ALPHA_MULTIPLY: number;
  63808. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63809. static readonly ALPHA_MAXIMIZED: number;
  63810. /** Defines that alpha blending to SRC + DEST */
  63811. static readonly ALPHA_ONEONE: number;
  63812. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63813. static readonly ALPHA_PREMULTIPLIED: number;
  63814. /**
  63815. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63816. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63817. */
  63818. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63819. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63820. static readonly ALPHA_INTERPOLATE: number;
  63821. /**
  63822. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63823. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63824. */
  63825. static readonly ALPHA_SCREENMODE: number;
  63826. /** Defines that the ressource is not delayed*/
  63827. static readonly DELAYLOADSTATE_NONE: number;
  63828. /** Defines that the ressource was successfully delay loaded */
  63829. static readonly DELAYLOADSTATE_LOADED: number;
  63830. /** Defines that the ressource is currently delay loading */
  63831. static readonly DELAYLOADSTATE_LOADING: number;
  63832. /** Defines that the ressource is delayed and has not started loading */
  63833. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63835. static readonly NEVER: number;
  63836. /** 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 */
  63837. static readonly ALWAYS: number;
  63838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63839. static readonly LESS: number;
  63840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63841. static readonly EQUAL: number;
  63842. /** 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 */
  63843. static readonly LEQUAL: number;
  63844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63845. static readonly GREATER: number;
  63846. /** 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 */
  63847. static readonly GEQUAL: number;
  63848. /** 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 */
  63849. static readonly NOTEQUAL: number;
  63850. /** Passed to stencilOperation to specify that stencil value must be kept */
  63851. static readonly KEEP: number;
  63852. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63853. static readonly REPLACE: number;
  63854. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63855. static readonly INCR: number;
  63856. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63857. static readonly DECR: number;
  63858. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63859. static readonly INVERT: number;
  63860. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63861. static readonly INCR_WRAP: number;
  63862. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63863. static readonly DECR_WRAP: number;
  63864. /** Texture is not repeating outside of 0..1 UVs */
  63865. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63866. /** Texture is repeating outside of 0..1 UVs */
  63867. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63868. /** Texture is repeating and mirrored */
  63869. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63870. /** ALPHA */
  63871. static readonly TEXTUREFORMAT_ALPHA: number;
  63872. /** LUMINANCE */
  63873. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63874. /** LUMINANCE_ALPHA */
  63875. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63876. /** RGB */
  63877. static readonly TEXTUREFORMAT_RGB: number;
  63878. /** RGBA */
  63879. static readonly TEXTUREFORMAT_RGBA: number;
  63880. /** RED */
  63881. static readonly TEXTUREFORMAT_RED: number;
  63882. /** RED (2nd reference) */
  63883. static readonly TEXTUREFORMAT_R: number;
  63884. /** RG */
  63885. static readonly TEXTUREFORMAT_RG: number;
  63886. /** RED_INTEGER */
  63887. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63888. /** RED_INTEGER (2nd reference) */
  63889. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63890. /** RG_INTEGER */
  63891. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63892. /** RGB_INTEGER */
  63893. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63894. /** RGBA_INTEGER */
  63895. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63896. /** UNSIGNED_BYTE */
  63897. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63898. /** UNSIGNED_BYTE (2nd reference) */
  63899. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63900. /** FLOAT */
  63901. static readonly TEXTURETYPE_FLOAT: number;
  63902. /** HALF_FLOAT */
  63903. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63904. /** BYTE */
  63905. static readonly TEXTURETYPE_BYTE: number;
  63906. /** SHORT */
  63907. static readonly TEXTURETYPE_SHORT: number;
  63908. /** UNSIGNED_SHORT */
  63909. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63910. /** INT */
  63911. static readonly TEXTURETYPE_INT: number;
  63912. /** UNSIGNED_INT */
  63913. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63914. /** UNSIGNED_SHORT_4_4_4_4 */
  63915. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63916. /** UNSIGNED_SHORT_5_5_5_1 */
  63917. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63918. /** UNSIGNED_SHORT_5_6_5 */
  63919. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63920. /** UNSIGNED_INT_2_10_10_10_REV */
  63921. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63922. /** UNSIGNED_INT_24_8 */
  63923. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63924. /** UNSIGNED_INT_10F_11F_11F_REV */
  63925. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63926. /** UNSIGNED_INT_5_9_9_9_REV */
  63927. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63928. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63929. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63930. /** nearest is mag = nearest and min = nearest and mip = linear */
  63931. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63933. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63934. /** Trilinear is mag = linear and min = linear and mip = linear */
  63935. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63936. /** nearest is mag = nearest and min = nearest and mip = linear */
  63937. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63938. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63939. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63940. /** Trilinear is mag = linear and min = linear and mip = linear */
  63941. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63942. /** mag = nearest and min = nearest and mip = nearest */
  63943. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63944. /** mag = nearest and min = linear and mip = nearest */
  63945. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63946. /** mag = nearest and min = linear and mip = linear */
  63947. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63948. /** mag = nearest and min = linear and mip = none */
  63949. static readonly TEXTURE_NEAREST_LINEAR: number;
  63950. /** mag = nearest and min = nearest and mip = none */
  63951. static readonly TEXTURE_NEAREST_NEAREST: number;
  63952. /** mag = linear and min = nearest and mip = nearest */
  63953. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63954. /** mag = linear and min = nearest and mip = linear */
  63955. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63956. /** mag = linear and min = linear and mip = none */
  63957. static readonly TEXTURE_LINEAR_LINEAR: number;
  63958. /** mag = linear and min = nearest and mip = none */
  63959. static readonly TEXTURE_LINEAR_NEAREST: number;
  63960. /** Explicit coordinates mode */
  63961. static readonly TEXTURE_EXPLICIT_MODE: number;
  63962. /** Spherical coordinates mode */
  63963. static readonly TEXTURE_SPHERICAL_MODE: number;
  63964. /** Planar coordinates mode */
  63965. static readonly TEXTURE_PLANAR_MODE: number;
  63966. /** Cubic coordinates mode */
  63967. static readonly TEXTURE_CUBIC_MODE: number;
  63968. /** Projection coordinates mode */
  63969. static readonly TEXTURE_PROJECTION_MODE: number;
  63970. /** Skybox coordinates mode */
  63971. static readonly TEXTURE_SKYBOX_MODE: number;
  63972. /** Inverse Cubic coordinates mode */
  63973. static readonly TEXTURE_INVCUBIC_MODE: number;
  63974. /** Equirectangular coordinates mode */
  63975. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63976. /** Equirectangular Fixed coordinates mode */
  63977. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63978. /** Equirectangular Fixed Mirrored coordinates mode */
  63979. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63980. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63981. static readonly SCALEMODE_FLOOR: number;
  63982. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63983. static readonly SCALEMODE_NEAREST: number;
  63984. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63985. static readonly SCALEMODE_CEILING: number;
  63986. /**
  63987. * The dirty texture flag value
  63988. */
  63989. static readonly MATERIAL_TextureDirtyFlag: number;
  63990. /**
  63991. * The dirty light flag value
  63992. */
  63993. static readonly MATERIAL_LightDirtyFlag: number;
  63994. /**
  63995. * The dirty fresnel flag value
  63996. */
  63997. static readonly MATERIAL_FresnelDirtyFlag: number;
  63998. /**
  63999. * The dirty attribute flag value
  64000. */
  64001. static readonly MATERIAL_AttributesDirtyFlag: number;
  64002. /**
  64003. * The dirty misc flag value
  64004. */
  64005. static readonly MATERIAL_MiscDirtyFlag: number;
  64006. /**
  64007. * The all dirty flag value
  64008. */
  64009. static readonly MATERIAL_AllDirtyFlag: number;
  64010. /**
  64011. * Returns the triangle fill mode
  64012. */
  64013. static readonly MATERIAL_TriangleFillMode: number;
  64014. /**
  64015. * Returns the wireframe mode
  64016. */
  64017. static readonly MATERIAL_WireFrameFillMode: number;
  64018. /**
  64019. * Returns the point fill mode
  64020. */
  64021. static readonly MATERIAL_PointFillMode: number;
  64022. /**
  64023. * Returns the point list draw mode
  64024. */
  64025. static readonly MATERIAL_PointListDrawMode: number;
  64026. /**
  64027. * Returns the line list draw mode
  64028. */
  64029. static readonly MATERIAL_LineListDrawMode: number;
  64030. /**
  64031. * Returns the line loop draw mode
  64032. */
  64033. static readonly MATERIAL_LineLoopDrawMode: number;
  64034. /**
  64035. * Returns the line strip draw mode
  64036. */
  64037. static readonly MATERIAL_LineStripDrawMode: number;
  64038. /**
  64039. * Returns the triangle strip draw mode
  64040. */
  64041. static readonly MATERIAL_TriangleStripDrawMode: number;
  64042. /**
  64043. * Returns the triangle fan draw mode
  64044. */
  64045. static readonly MATERIAL_TriangleFanDrawMode: number;
  64046. /**
  64047. * Stores the clock-wise side orientation
  64048. */
  64049. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64050. /**
  64051. * Stores the counter clock-wise side orientation
  64052. */
  64053. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64054. /**
  64055. * Nothing
  64056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64057. */
  64058. static readonly ACTION_NothingTrigger: number;
  64059. /**
  64060. * On pick
  64061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64062. */
  64063. static readonly ACTION_OnPickTrigger: number;
  64064. /**
  64065. * On left pick
  64066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64067. */
  64068. static readonly ACTION_OnLeftPickTrigger: number;
  64069. /**
  64070. * On right pick
  64071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64072. */
  64073. static readonly ACTION_OnRightPickTrigger: number;
  64074. /**
  64075. * On center pick
  64076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64077. */
  64078. static readonly ACTION_OnCenterPickTrigger: number;
  64079. /**
  64080. * On pick down
  64081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64082. */
  64083. static readonly ACTION_OnPickDownTrigger: number;
  64084. /**
  64085. * On double pick
  64086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64087. */
  64088. static readonly ACTION_OnDoublePickTrigger: number;
  64089. /**
  64090. * On pick up
  64091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64092. */
  64093. static readonly ACTION_OnPickUpTrigger: number;
  64094. /**
  64095. * On pick out.
  64096. * This trigger will only be raised if you also declared a OnPickDown
  64097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64098. */
  64099. static readonly ACTION_OnPickOutTrigger: number;
  64100. /**
  64101. * On long press
  64102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64103. */
  64104. static readonly ACTION_OnLongPressTrigger: number;
  64105. /**
  64106. * On pointer over
  64107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64108. */
  64109. static readonly ACTION_OnPointerOverTrigger: number;
  64110. /**
  64111. * On pointer out
  64112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64113. */
  64114. static readonly ACTION_OnPointerOutTrigger: number;
  64115. /**
  64116. * On every frame
  64117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64118. */
  64119. static readonly ACTION_OnEveryFrameTrigger: number;
  64120. /**
  64121. * On intersection enter
  64122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64123. */
  64124. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64125. /**
  64126. * On intersection exit
  64127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64128. */
  64129. static readonly ACTION_OnIntersectionExitTrigger: number;
  64130. /**
  64131. * On key down
  64132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64133. */
  64134. static readonly ACTION_OnKeyDownTrigger: number;
  64135. /**
  64136. * On key up
  64137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64138. */
  64139. static readonly ACTION_OnKeyUpTrigger: number;
  64140. /**
  64141. * Billboard mode will only apply to Y axis
  64142. */
  64143. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64144. /**
  64145. * Billboard mode will apply to all axes
  64146. */
  64147. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64148. /**
  64149. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64150. */
  64151. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64152. /**
  64153. * Gets or sets base Assets URL
  64154. */
  64155. static readonly PARTICLES_BaseAssetsUrl: string;
  64156. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64157. * Test order :
  64158. * Is the bounding sphere outside the frustum ?
  64159. * If not, are the bounding box vertices outside the frustum ?
  64160. * It not, then the cullable object is in the frustum.
  64161. */
  64162. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64163. /** Culling strategy : Bounding Sphere Only.
  64164. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64165. * It's also less accurate than the standard because some not visible objects can still be selected.
  64166. * Test : is the bounding sphere outside the frustum ?
  64167. * If not, then the cullable object is in the frustum.
  64168. */
  64169. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64170. /** Culling strategy : Optimistic Inclusion.
  64171. * This in an inclusion test first, then the standard exclusion test.
  64172. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64173. * 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.
  64174. * Anyway, it's as accurate as the standard strategy.
  64175. * Test :
  64176. * Is the cullable object bounding sphere center in the frustum ?
  64177. * If not, apply the default culling strategy.
  64178. */
  64179. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64180. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64181. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64182. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64183. * 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.
  64184. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64185. * Test :
  64186. * Is the cullable object bounding sphere center in the frustum ?
  64187. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64188. */
  64189. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64190. /**
  64191. * No logging while loading
  64192. */
  64193. static readonly SCENELOADER_NO_LOGGING: number;
  64194. /**
  64195. * Minimal logging while loading
  64196. */
  64197. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64198. /**
  64199. * Summary logging while loading
  64200. */
  64201. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64202. /**
  64203. * Detailled logging while loading
  64204. */
  64205. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64206. }
  64207. }
  64208. declare module BABYLON {
  64209. /**
  64210. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64211. * Babylon.js
  64212. */
  64213. export class DomManagement {
  64214. /**
  64215. * Checks if the window object exists
  64216. * @returns true if the window object exists
  64217. */
  64218. static IsWindowObjectExist(): boolean;
  64219. /**
  64220. * Extracts text content from a DOM element hierarchy
  64221. * @param element defines the root element
  64222. * @returns a string
  64223. */
  64224. static GetDOMTextContent(element: HTMLElement): string;
  64225. }
  64226. }
  64227. declare module BABYLON {
  64228. /**
  64229. * Logger used througouht the application to allow configuration of
  64230. * the log level required for the messages.
  64231. */
  64232. export class Logger {
  64233. /**
  64234. * No log
  64235. */
  64236. static readonly NoneLogLevel: number;
  64237. /**
  64238. * Only message logs
  64239. */
  64240. static readonly MessageLogLevel: number;
  64241. /**
  64242. * Only warning logs
  64243. */
  64244. static readonly WarningLogLevel: number;
  64245. /**
  64246. * Only error logs
  64247. */
  64248. static readonly ErrorLogLevel: number;
  64249. /**
  64250. * All logs
  64251. */
  64252. static readonly AllLogLevel: number;
  64253. private static _LogCache;
  64254. /**
  64255. * Gets a value indicating the number of loading errors
  64256. * @ignorenaming
  64257. */
  64258. static errorsCount: number;
  64259. /**
  64260. * Callback called when a new log is added
  64261. */
  64262. static OnNewCacheEntry: (entry: string) => void;
  64263. private static _AddLogEntry;
  64264. private static _FormatMessage;
  64265. private static _LogDisabled;
  64266. private static _LogEnabled;
  64267. private static _WarnDisabled;
  64268. private static _WarnEnabled;
  64269. private static _ErrorDisabled;
  64270. private static _ErrorEnabled;
  64271. /**
  64272. * Log a message to the console
  64273. */
  64274. static Log: (message: string) => void;
  64275. /**
  64276. * Write a warning message to the console
  64277. */
  64278. static Warn: (message: string) => void;
  64279. /**
  64280. * Write an error message to the console
  64281. */
  64282. static Error: (message: string) => void;
  64283. /**
  64284. * Gets current log cache (list of logs)
  64285. */
  64286. static readonly LogCache: string;
  64287. /**
  64288. * Clears the log cache
  64289. */
  64290. static ClearLogCache(): void;
  64291. /**
  64292. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64293. */
  64294. static LogLevels: number;
  64295. }
  64296. }
  64297. declare module BABYLON {
  64298. /** @hidden */
  64299. export class _TypeStore {
  64300. /** @hidden */
  64301. static RegisteredTypes: {
  64302. [key: string]: Object;
  64303. };
  64304. /** @hidden */
  64305. static GetClass(fqdn: string): any;
  64306. }
  64307. }
  64308. declare module BABYLON {
  64309. /**
  64310. * Class containing a set of static utilities functions for deep copy.
  64311. */
  64312. export class DeepCopier {
  64313. /**
  64314. * Tries to copy an object by duplicating every property
  64315. * @param source defines the source object
  64316. * @param destination defines the target object
  64317. * @param doNotCopyList defines a list of properties to avoid
  64318. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64319. */
  64320. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Class containing a set of static utilities functions for precision date
  64326. */
  64327. export class PrecisionDate {
  64328. /**
  64329. * Gets either window.performance.now() if supported or Date.now() else
  64330. */
  64331. static readonly Now: number;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /** @hidden */
  64336. export class _DevTools {
  64337. static WarnImport(name: string): string;
  64338. }
  64339. }
  64340. declare module BABYLON {
  64341. /**
  64342. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64343. */
  64344. export class WebRequest {
  64345. private _xhr;
  64346. /**
  64347. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64348. * i.e. when loading files, where the server/service expects an Authorization header
  64349. */
  64350. static CustomRequestHeaders: {
  64351. [key: string]: string;
  64352. };
  64353. /**
  64354. * Add callback functions in this array to update all the requests before they get sent to the network
  64355. */
  64356. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64357. private _injectCustomRequestHeaders;
  64358. /**
  64359. * Gets or sets a function to be called when loading progress changes
  64360. */
  64361. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64362. /**
  64363. * Returns client's state
  64364. */
  64365. readonly readyState: number;
  64366. /**
  64367. * Returns client's status
  64368. */
  64369. readonly status: number;
  64370. /**
  64371. * Returns client's status as a text
  64372. */
  64373. readonly statusText: string;
  64374. /**
  64375. * Returns client's response
  64376. */
  64377. readonly response: any;
  64378. /**
  64379. * Returns client's response url
  64380. */
  64381. readonly responseURL: string;
  64382. /**
  64383. * Returns client's response as text
  64384. */
  64385. readonly responseText: string;
  64386. /**
  64387. * Gets or sets the expected response type
  64388. */
  64389. responseType: XMLHttpRequestResponseType;
  64390. /** @hidden */
  64391. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64392. /** @hidden */
  64393. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64394. /**
  64395. * Cancels any network activity
  64396. */
  64397. abort(): void;
  64398. /**
  64399. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64400. * @param body defines an optional request body
  64401. */
  64402. send(body?: Document | BodyInit | null): void;
  64403. /**
  64404. * Sets the request method, request URL
  64405. * @param method defines the method to use (GET, POST, etc..)
  64406. * @param url defines the url to connect with
  64407. */
  64408. open(method: string, url: string): void;
  64409. }
  64410. }
  64411. declare module BABYLON {
  64412. /**
  64413. * Class used to evalaute queries containing `and` and `or` operators
  64414. */
  64415. export class AndOrNotEvaluator {
  64416. /**
  64417. * Evaluate a query
  64418. * @param query defines the query to evaluate
  64419. * @param evaluateCallback defines the callback used to filter result
  64420. * @returns true if the query matches
  64421. */
  64422. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64423. private static _HandleParenthesisContent;
  64424. private static _SimplifyNegation;
  64425. }
  64426. }
  64427. declare module BABYLON {
  64428. /**
  64429. * Class used to store custom tags
  64430. */
  64431. export class Tags {
  64432. /**
  64433. * Adds support for tags on the given object
  64434. * @param obj defines the object to use
  64435. */
  64436. static EnableFor(obj: any): void;
  64437. /**
  64438. * Removes tags support
  64439. * @param obj defines the object to use
  64440. */
  64441. static DisableFor(obj: any): void;
  64442. /**
  64443. * Gets a boolean indicating if the given object has tags
  64444. * @param obj defines the object to use
  64445. * @returns a boolean
  64446. */
  64447. static HasTags(obj: any): boolean;
  64448. /**
  64449. * Gets the tags available on a given object
  64450. * @param obj defines the object to use
  64451. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64452. * @returns the tags
  64453. */
  64454. static GetTags(obj: any, asString?: boolean): any;
  64455. /**
  64456. * Adds tags to an object
  64457. * @param obj defines the object to use
  64458. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64459. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64460. */
  64461. static AddTagsTo(obj: any, tagsString: string): void;
  64462. /**
  64463. * @hidden
  64464. */
  64465. static _AddTagTo(obj: any, tag: string): void;
  64466. /**
  64467. * Removes specific tags from a specific object
  64468. * @param obj defines the object to use
  64469. * @param tagsString defines the tags to remove
  64470. */
  64471. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64472. /**
  64473. * @hidden
  64474. */
  64475. static _RemoveTagFrom(obj: any, tag: string): void;
  64476. /**
  64477. * Defines if tags hosted on an object match a given query
  64478. * @param obj defines the object to use
  64479. * @param tagsQuery defines the tag query
  64480. * @returns a boolean
  64481. */
  64482. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64483. }
  64484. }
  64485. declare module BABYLON {
  64486. /**
  64487. * Manages the defines for the Material
  64488. */
  64489. export class MaterialDefines {
  64490. private _keys;
  64491. private _isDirty;
  64492. /** @hidden */
  64493. _renderId: number;
  64494. /** @hidden */
  64495. _areLightsDirty: boolean;
  64496. /** @hidden */
  64497. _areAttributesDirty: boolean;
  64498. /** @hidden */
  64499. _areTexturesDirty: boolean;
  64500. /** @hidden */
  64501. _areFresnelDirty: boolean;
  64502. /** @hidden */
  64503. _areMiscDirty: boolean;
  64504. /** @hidden */
  64505. _areImageProcessingDirty: boolean;
  64506. /** @hidden */
  64507. _normals: boolean;
  64508. /** @hidden */
  64509. _uvs: boolean;
  64510. /** @hidden */
  64511. _needNormals: boolean;
  64512. /** @hidden */
  64513. _needUVs: boolean;
  64514. /**
  64515. * Specifies if the material needs to be re-calculated
  64516. */
  64517. readonly isDirty: boolean;
  64518. /**
  64519. * Marks the material to indicate that it has been re-calculated
  64520. */
  64521. markAsProcessed(): void;
  64522. /**
  64523. * Marks the material to indicate that it needs to be re-calculated
  64524. */
  64525. markAsUnprocessed(): void;
  64526. /**
  64527. * Marks the material to indicate all of its defines need to be re-calculated
  64528. */
  64529. markAllAsDirty(): void;
  64530. /**
  64531. * Marks the material to indicate that image processing needs to be re-calculated
  64532. */
  64533. markAsImageProcessingDirty(): void;
  64534. /**
  64535. * Marks the material to indicate the lights need to be re-calculated
  64536. */
  64537. markAsLightDirty(): void;
  64538. /**
  64539. * Marks the attribute state as changed
  64540. */
  64541. markAsAttributesDirty(): void;
  64542. /**
  64543. * Marks the texture state as changed
  64544. */
  64545. markAsTexturesDirty(): void;
  64546. /**
  64547. * Marks the fresnel state as changed
  64548. */
  64549. markAsFresnelDirty(): void;
  64550. /**
  64551. * Marks the misc state as changed
  64552. */
  64553. markAsMiscDirty(): void;
  64554. /**
  64555. * Rebuilds the material defines
  64556. */
  64557. rebuild(): void;
  64558. /**
  64559. * Specifies if two material defines are equal
  64560. * @param other - A material define instance to compare to
  64561. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64562. */
  64563. isEqual(other: MaterialDefines): boolean;
  64564. /**
  64565. * Clones this instance's defines to another instance
  64566. * @param other - material defines to clone values to
  64567. */
  64568. cloneTo(other: MaterialDefines): void;
  64569. /**
  64570. * Resets the material define values
  64571. */
  64572. reset(): void;
  64573. /**
  64574. * Converts the material define values to a string
  64575. * @returns - String of material define information
  64576. */
  64577. toString(): string;
  64578. }
  64579. }
  64580. declare module BABYLON {
  64581. /**
  64582. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64583. */
  64584. export class PerformanceMonitor {
  64585. private _enabled;
  64586. private _rollingFrameTime;
  64587. private _lastFrameTimeMs;
  64588. /**
  64589. * constructor
  64590. * @param frameSampleSize The number of samples required to saturate the sliding window
  64591. */
  64592. constructor(frameSampleSize?: number);
  64593. /**
  64594. * Samples current frame
  64595. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64596. */
  64597. sampleFrame(timeMs?: number): void;
  64598. /**
  64599. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64600. */
  64601. readonly averageFrameTime: number;
  64602. /**
  64603. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64604. */
  64605. readonly averageFrameTimeVariance: number;
  64606. /**
  64607. * Returns the frame time of the most recent frame
  64608. */
  64609. readonly instantaneousFrameTime: number;
  64610. /**
  64611. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64612. */
  64613. readonly averageFPS: number;
  64614. /**
  64615. * Returns the average framerate in frames per second using the most recent frame time
  64616. */
  64617. readonly instantaneousFPS: number;
  64618. /**
  64619. * Returns true if enough samples have been taken to completely fill the sliding window
  64620. */
  64621. readonly isSaturated: boolean;
  64622. /**
  64623. * Enables contributions to the sliding window sample set
  64624. */
  64625. enable(): void;
  64626. /**
  64627. * Disables contributions to the sliding window sample set
  64628. * Samples will not be interpolated over the disabled period
  64629. */
  64630. disable(): void;
  64631. /**
  64632. * Returns true if sampling is enabled
  64633. */
  64634. readonly isEnabled: boolean;
  64635. /**
  64636. * Resets performance monitor
  64637. */
  64638. reset(): void;
  64639. }
  64640. /**
  64641. * RollingAverage
  64642. *
  64643. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64644. */
  64645. export class RollingAverage {
  64646. /**
  64647. * Current average
  64648. */
  64649. average: number;
  64650. /**
  64651. * Current variance
  64652. */
  64653. variance: number;
  64654. protected _samples: Array<number>;
  64655. protected _sampleCount: number;
  64656. protected _pos: number;
  64657. protected _m2: number;
  64658. /**
  64659. * constructor
  64660. * @param length The number of samples required to saturate the sliding window
  64661. */
  64662. constructor(length: number);
  64663. /**
  64664. * Adds a sample to the sample set
  64665. * @param v The sample value
  64666. */
  64667. add(v: number): void;
  64668. /**
  64669. * Returns previously added values or null if outside of history or outside the sliding window domain
  64670. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64671. * @return Value previously recorded with add() or null if outside of range
  64672. */
  64673. history(i: number): number;
  64674. /**
  64675. * Returns true if enough samples have been taken to completely fill the sliding window
  64676. * @return true if sample-set saturated
  64677. */
  64678. isSaturated(): boolean;
  64679. /**
  64680. * Resets the rolling average (equivalent to 0 samples taken so far)
  64681. */
  64682. reset(): void;
  64683. /**
  64684. * Wraps a value around the sample range boundaries
  64685. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64686. * @return Wrapped position in sample range
  64687. */
  64688. protected _wrapPosition(i: number): number;
  64689. }
  64690. }
  64691. declare module BABYLON {
  64692. /**
  64693. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64694. * The underlying implementation relies on an associative array to ensure the best performances.
  64695. * The value can be anything including 'null' but except 'undefined'
  64696. */
  64697. export class StringDictionary<T> {
  64698. /**
  64699. * This will clear this dictionary and copy the content from the 'source' one.
  64700. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64701. * @param source the dictionary to take the content from and copy to this dictionary
  64702. */
  64703. copyFrom(source: StringDictionary<T>): void;
  64704. /**
  64705. * Get a value based from its key
  64706. * @param key the given key to get the matching value from
  64707. * @return the value if found, otherwise undefined is returned
  64708. */
  64709. get(key: string): T | undefined;
  64710. /**
  64711. * Get a value from its key or add it if it doesn't exist.
  64712. * This method will ensure you that a given key/data will be present in the dictionary.
  64713. * @param key the given key to get the matching value from
  64714. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64715. * The factory will only be invoked if there's no data for the given key.
  64716. * @return the value corresponding to the key.
  64717. */
  64718. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64719. /**
  64720. * Get a value from its key if present in the dictionary otherwise add it
  64721. * @param key the key to get the value from
  64722. * @param val if there's no such key/value pair in the dictionary add it with this value
  64723. * @return the value corresponding to the key
  64724. */
  64725. getOrAdd(key: string, val: T): T;
  64726. /**
  64727. * Check if there's a given key in the dictionary
  64728. * @param key the key to check for
  64729. * @return true if the key is present, false otherwise
  64730. */
  64731. contains(key: string): boolean;
  64732. /**
  64733. * Add a new key and its corresponding value
  64734. * @param key the key to add
  64735. * @param value the value corresponding to the key
  64736. * @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
  64737. */
  64738. add(key: string, value: T): boolean;
  64739. /**
  64740. * Update a specific value associated to a key
  64741. * @param key defines the key to use
  64742. * @param value defines the value to store
  64743. * @returns true if the value was updated (or false if the key was not found)
  64744. */
  64745. set(key: string, value: T): boolean;
  64746. /**
  64747. * Get the element of the given key and remove it from the dictionary
  64748. * @param key defines the key to search
  64749. * @returns the value associated with the key or null if not found
  64750. */
  64751. getAndRemove(key: string): Nullable<T>;
  64752. /**
  64753. * Remove a key/value from the dictionary.
  64754. * @param key the key to remove
  64755. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64756. */
  64757. remove(key: string): boolean;
  64758. /**
  64759. * Clear the whole content of the dictionary
  64760. */
  64761. clear(): void;
  64762. /**
  64763. * Gets the current count
  64764. */
  64765. readonly count: number;
  64766. /**
  64767. * Execute a callback on each key/val of the dictionary.
  64768. * Note that you can remove any element in this dictionary in the callback implementation
  64769. * @param callback the callback to execute on a given key/value pair
  64770. */
  64771. forEach(callback: (key: string, val: T) => void): void;
  64772. /**
  64773. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64774. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64775. * Note that you can remove any element in this dictionary in the callback implementation
  64776. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64777. * @returns the first item
  64778. */
  64779. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64780. private _count;
  64781. private _data;
  64782. }
  64783. }
  64784. declare module BABYLON {
  64785. /**
  64786. * Helper class that provides a small promise polyfill
  64787. */
  64788. export class PromisePolyfill {
  64789. /**
  64790. * Static function used to check if the polyfill is required
  64791. * If this is the case then the function will inject the polyfill to window.Promise
  64792. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64793. */
  64794. static Apply(force?: boolean): void;
  64795. }
  64796. }
  64797. declare module BABYLON {
  64798. /**
  64799. * Class used to store data that will be store in GPU memory
  64800. */
  64801. export class Buffer {
  64802. private _engine;
  64803. private _buffer;
  64804. /** @hidden */
  64805. _data: Nullable<DataArray>;
  64806. private _updatable;
  64807. private _instanced;
  64808. /**
  64809. * Gets the byte stride.
  64810. */
  64811. readonly byteStride: number;
  64812. /**
  64813. * Constructor
  64814. * @param engine the engine
  64815. * @param data the data to use for this buffer
  64816. * @param updatable whether the data is updatable
  64817. * @param stride the stride (optional)
  64818. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64819. * @param instanced whether the buffer is instanced (optional)
  64820. * @param useBytes set to true if the stride in in bytes (optional)
  64821. */
  64822. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64823. /**
  64824. * Create a new VertexBuffer based on the current buffer
  64825. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64826. * @param offset defines offset in the buffer (0 by default)
  64827. * @param size defines the size in floats of attributes (position is 3 for instance)
  64828. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64829. * @param instanced defines if the vertex buffer contains indexed data
  64830. * @param useBytes defines if the offset and stride are in bytes
  64831. * @returns the new vertex buffer
  64832. */
  64833. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64834. /**
  64835. * Gets a boolean indicating if the Buffer is updatable?
  64836. * @returns true if the buffer is updatable
  64837. */
  64838. isUpdatable(): boolean;
  64839. /**
  64840. * Gets current buffer's data
  64841. * @returns a DataArray or null
  64842. */
  64843. getData(): Nullable<DataArray>;
  64844. /**
  64845. * Gets underlying native buffer
  64846. * @returns underlying native buffer
  64847. */
  64848. getBuffer(): Nullable<WebGLBuffer>;
  64849. /**
  64850. * Gets the stride in float32 units (i.e. byte stride / 4).
  64851. * May not be an integer if the byte stride is not divisible by 4.
  64852. * DEPRECATED. Use byteStride instead.
  64853. * @returns the stride in float32 units
  64854. */
  64855. getStrideSize(): number;
  64856. /**
  64857. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64858. * @param data defines the data to store
  64859. */
  64860. create(data?: Nullable<DataArray>): void;
  64861. /** @hidden */
  64862. _rebuild(): void;
  64863. /**
  64864. * Update current buffer data
  64865. * @param data defines the data to store
  64866. */
  64867. update(data: DataArray): void;
  64868. /**
  64869. * Updates the data directly.
  64870. * @param data the new data
  64871. * @param offset the new offset
  64872. * @param vertexCount the vertex count (optional)
  64873. * @param useBytes set to true if the offset is in bytes
  64874. */
  64875. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64876. /**
  64877. * Release all resources
  64878. */
  64879. dispose(): void;
  64880. }
  64881. /**
  64882. * Specialized buffer used to store vertex data
  64883. */
  64884. export class VertexBuffer {
  64885. /** @hidden */
  64886. _buffer: Buffer;
  64887. private _kind;
  64888. private _size;
  64889. private _ownsBuffer;
  64890. private _instanced;
  64891. private _instanceDivisor;
  64892. /**
  64893. * The byte type.
  64894. */
  64895. static readonly BYTE: number;
  64896. /**
  64897. * The unsigned byte type.
  64898. */
  64899. static readonly UNSIGNED_BYTE: number;
  64900. /**
  64901. * The short type.
  64902. */
  64903. static readonly SHORT: number;
  64904. /**
  64905. * The unsigned short type.
  64906. */
  64907. static readonly UNSIGNED_SHORT: number;
  64908. /**
  64909. * The integer type.
  64910. */
  64911. static readonly INT: number;
  64912. /**
  64913. * The unsigned integer type.
  64914. */
  64915. static readonly UNSIGNED_INT: number;
  64916. /**
  64917. * The float type.
  64918. */
  64919. static readonly FLOAT: number;
  64920. /**
  64921. * Gets or sets the instance divisor when in instanced mode
  64922. */
  64923. instanceDivisor: number;
  64924. /**
  64925. * Gets the byte stride.
  64926. */
  64927. readonly byteStride: number;
  64928. /**
  64929. * Gets the byte offset.
  64930. */
  64931. readonly byteOffset: number;
  64932. /**
  64933. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64934. */
  64935. readonly normalized: boolean;
  64936. /**
  64937. * Gets the data type of each component in the array.
  64938. */
  64939. readonly type: number;
  64940. /**
  64941. * Constructor
  64942. * @param engine the engine
  64943. * @param data the data to use for this vertex buffer
  64944. * @param kind the vertex buffer kind
  64945. * @param updatable whether the data is updatable
  64946. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64947. * @param stride the stride (optional)
  64948. * @param instanced whether the buffer is instanced (optional)
  64949. * @param offset the offset of the data (optional)
  64950. * @param size the number of components (optional)
  64951. * @param type the type of the component (optional)
  64952. * @param normalized whether the data contains normalized data (optional)
  64953. * @param useBytes set to true if stride and offset are in bytes (optional)
  64954. */
  64955. 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);
  64956. /** @hidden */
  64957. _rebuild(): void;
  64958. /**
  64959. * Returns the kind of the VertexBuffer (string)
  64960. * @returns a string
  64961. */
  64962. getKind(): string;
  64963. /**
  64964. * Gets a boolean indicating if the VertexBuffer is updatable?
  64965. * @returns true if the buffer is updatable
  64966. */
  64967. isUpdatable(): boolean;
  64968. /**
  64969. * Gets current buffer's data
  64970. * @returns a DataArray or null
  64971. */
  64972. getData(): Nullable<DataArray>;
  64973. /**
  64974. * Gets underlying native buffer
  64975. * @returns underlying native buffer
  64976. */
  64977. getBuffer(): Nullable<WebGLBuffer>;
  64978. /**
  64979. * Gets the stride in float32 units (i.e. byte stride / 4).
  64980. * May not be an integer if the byte stride is not divisible by 4.
  64981. * DEPRECATED. Use byteStride instead.
  64982. * @returns the stride in float32 units
  64983. */
  64984. getStrideSize(): number;
  64985. /**
  64986. * Returns the offset as a multiple of the type byte length.
  64987. * DEPRECATED. Use byteOffset instead.
  64988. * @returns the offset in bytes
  64989. */
  64990. getOffset(): number;
  64991. /**
  64992. * Returns the number of components per vertex attribute (integer)
  64993. * @returns the size in float
  64994. */
  64995. getSize(): number;
  64996. /**
  64997. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64998. * @returns true if this buffer is instanced
  64999. */
  65000. getIsInstanced(): boolean;
  65001. /**
  65002. * Returns the instancing divisor, zero for non-instanced (integer).
  65003. * @returns a number
  65004. */
  65005. getInstanceDivisor(): number;
  65006. /**
  65007. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65008. * @param data defines the data to store
  65009. */
  65010. create(data?: DataArray): void;
  65011. /**
  65012. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65013. * This function will create a new buffer if the current one is not updatable
  65014. * @param data defines the data to store
  65015. */
  65016. update(data: DataArray): void;
  65017. /**
  65018. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65019. * Returns the directly updated WebGLBuffer.
  65020. * @param data the new data
  65021. * @param offset the new offset
  65022. * @param useBytes set to true if the offset is in bytes
  65023. */
  65024. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65025. /**
  65026. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65027. */
  65028. dispose(): void;
  65029. /**
  65030. * Enumerates each value of this vertex buffer as numbers.
  65031. * @param count the number of values to enumerate
  65032. * @param callback the callback function called for each value
  65033. */
  65034. forEach(count: number, callback: (value: number, index: number) => void): void;
  65035. /**
  65036. * Positions
  65037. */
  65038. static readonly PositionKind: string;
  65039. /**
  65040. * Normals
  65041. */
  65042. static readonly NormalKind: string;
  65043. /**
  65044. * Tangents
  65045. */
  65046. static readonly TangentKind: string;
  65047. /**
  65048. * Texture coordinates
  65049. */
  65050. static readonly UVKind: string;
  65051. /**
  65052. * Texture coordinates 2
  65053. */
  65054. static readonly UV2Kind: string;
  65055. /**
  65056. * Texture coordinates 3
  65057. */
  65058. static readonly UV3Kind: string;
  65059. /**
  65060. * Texture coordinates 4
  65061. */
  65062. static readonly UV4Kind: string;
  65063. /**
  65064. * Texture coordinates 5
  65065. */
  65066. static readonly UV5Kind: string;
  65067. /**
  65068. * Texture coordinates 6
  65069. */
  65070. static readonly UV6Kind: string;
  65071. /**
  65072. * Colors
  65073. */
  65074. static readonly ColorKind: string;
  65075. /**
  65076. * Matrix indices (for bones)
  65077. */
  65078. static readonly MatricesIndicesKind: string;
  65079. /**
  65080. * Matrix weights (for bones)
  65081. */
  65082. static readonly MatricesWeightsKind: string;
  65083. /**
  65084. * Additional matrix indices (for bones)
  65085. */
  65086. static readonly MatricesIndicesExtraKind: string;
  65087. /**
  65088. * Additional matrix weights (for bones)
  65089. */
  65090. static readonly MatricesWeightsExtraKind: string;
  65091. /**
  65092. * Deduces the stride given a kind.
  65093. * @param kind The kind string to deduce
  65094. * @returns The deduced stride
  65095. */
  65096. static DeduceStride(kind: string): number;
  65097. /**
  65098. * Gets the byte length of the given type.
  65099. * @param type the type
  65100. * @returns the number of bytes
  65101. */
  65102. static GetTypeByteLength(type: number): number;
  65103. /**
  65104. * Enumerates each value of the given parameters as numbers.
  65105. * @param data the data to enumerate
  65106. * @param byteOffset the byte offset of the data
  65107. * @param byteStride the byte stride of the data
  65108. * @param componentCount the number of components per element
  65109. * @param componentType the type of the component
  65110. * @param count the total number of components
  65111. * @param normalized whether the data is normalized
  65112. * @param callback the callback function called for each value
  65113. */
  65114. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65115. private static _GetFloatValue;
  65116. }
  65117. }
  65118. declare module BABYLON {
  65119. /**
  65120. * Class representing spherical polynomial coefficients to the 3rd degree
  65121. */
  65122. export class SphericalPolynomial {
  65123. /**
  65124. * The x coefficients of the spherical polynomial
  65125. */
  65126. x: Vector3;
  65127. /**
  65128. * The y coefficients of the spherical polynomial
  65129. */
  65130. y: Vector3;
  65131. /**
  65132. * The z coefficients of the spherical polynomial
  65133. */
  65134. z: Vector3;
  65135. /**
  65136. * The xx coefficients of the spherical polynomial
  65137. */
  65138. xx: Vector3;
  65139. /**
  65140. * The yy coefficients of the spherical polynomial
  65141. */
  65142. yy: Vector3;
  65143. /**
  65144. * The zz coefficients of the spherical polynomial
  65145. */
  65146. zz: Vector3;
  65147. /**
  65148. * The xy coefficients of the spherical polynomial
  65149. */
  65150. xy: Vector3;
  65151. /**
  65152. * The yz coefficients of the spherical polynomial
  65153. */
  65154. yz: Vector3;
  65155. /**
  65156. * The zx coefficients of the spherical polynomial
  65157. */
  65158. zx: Vector3;
  65159. /**
  65160. * Adds an ambient color to the spherical polynomial
  65161. * @param color the color to add
  65162. */
  65163. addAmbient(color: Color3): void;
  65164. /**
  65165. * Scales the spherical polynomial by the given amount
  65166. * @param scale the amount to scale
  65167. */
  65168. scale(scale: number): void;
  65169. /**
  65170. * Gets the spherical polynomial from harmonics
  65171. * @param harmonics the spherical harmonics
  65172. * @returns the spherical polynomial
  65173. */
  65174. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65175. /**
  65176. * Constructs a spherical polynomial from an array.
  65177. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65178. * @returns the spherical polynomial
  65179. */
  65180. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65181. }
  65182. /**
  65183. * Class representing spherical harmonics coefficients to the 3rd degree
  65184. */
  65185. export class SphericalHarmonics {
  65186. /**
  65187. * The l0,0 coefficients of the spherical harmonics
  65188. */
  65189. l00: Vector3;
  65190. /**
  65191. * The l1,-1 coefficients of the spherical harmonics
  65192. */
  65193. l1_1: Vector3;
  65194. /**
  65195. * The l1,0 coefficients of the spherical harmonics
  65196. */
  65197. l10: Vector3;
  65198. /**
  65199. * The l1,1 coefficients of the spherical harmonics
  65200. */
  65201. l11: Vector3;
  65202. /**
  65203. * The l2,-2 coefficients of the spherical harmonics
  65204. */
  65205. l2_2: Vector3;
  65206. /**
  65207. * The l2,-1 coefficients of the spherical harmonics
  65208. */
  65209. l2_1: Vector3;
  65210. /**
  65211. * The l2,0 coefficients of the spherical harmonics
  65212. */
  65213. l20: Vector3;
  65214. /**
  65215. * The l2,1 coefficients of the spherical harmonics
  65216. */
  65217. l21: Vector3;
  65218. /**
  65219. * The l2,2 coefficients of the spherical harmonics
  65220. */
  65221. lL22: Vector3;
  65222. /**
  65223. * Adds a light to the spherical harmonics
  65224. * @param direction the direction of the light
  65225. * @param color the color of the light
  65226. * @param deltaSolidAngle the delta solid angle of the light
  65227. */
  65228. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65229. /**
  65230. * Scales the spherical harmonics by the given amount
  65231. * @param scale the amount to scale
  65232. */
  65233. scale(scale: number): void;
  65234. /**
  65235. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65236. *
  65237. * ```
  65238. * E_lm = A_l * L_lm
  65239. * ```
  65240. *
  65241. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65242. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65243. * the scaling factors are given in equation 9.
  65244. */
  65245. convertIncidentRadianceToIrradiance(): void;
  65246. /**
  65247. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65248. *
  65249. * ```
  65250. * L = (1/pi) * E * rho
  65251. * ```
  65252. *
  65253. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65254. */
  65255. convertIrradianceToLambertianRadiance(): void;
  65256. /**
  65257. * Gets the spherical harmonics from polynomial
  65258. * @param polynomial the spherical polynomial
  65259. * @returns the spherical harmonics
  65260. */
  65261. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65262. /**
  65263. * Constructs a spherical harmonics from an array.
  65264. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65265. * @returns the spherical harmonics
  65266. */
  65267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65268. }
  65269. }
  65270. declare module BABYLON {
  65271. /**
  65272. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65273. */
  65274. export interface CubeMapInfo {
  65275. /**
  65276. * The pixel array for the front face.
  65277. * This is stored in format, left to right, up to down format.
  65278. */
  65279. front: Nullable<ArrayBufferView>;
  65280. /**
  65281. * The pixel array for the back face.
  65282. * This is stored in format, left to right, up to down format.
  65283. */
  65284. back: Nullable<ArrayBufferView>;
  65285. /**
  65286. * The pixel array for the left face.
  65287. * This is stored in format, left to right, up to down format.
  65288. */
  65289. left: Nullable<ArrayBufferView>;
  65290. /**
  65291. * The pixel array for the right face.
  65292. * This is stored in format, left to right, up to down format.
  65293. */
  65294. right: Nullable<ArrayBufferView>;
  65295. /**
  65296. * The pixel array for the up face.
  65297. * This is stored in format, left to right, up to down format.
  65298. */
  65299. up: Nullable<ArrayBufferView>;
  65300. /**
  65301. * The pixel array for the down face.
  65302. * This is stored in format, left to right, up to down format.
  65303. */
  65304. down: Nullable<ArrayBufferView>;
  65305. /**
  65306. * The size of the cubemap stored.
  65307. *
  65308. * Each faces will be size * size pixels.
  65309. */
  65310. size: number;
  65311. /**
  65312. * The format of the texture.
  65313. *
  65314. * RGBA, RGB.
  65315. */
  65316. format: number;
  65317. /**
  65318. * The type of the texture data.
  65319. *
  65320. * UNSIGNED_INT, FLOAT.
  65321. */
  65322. type: number;
  65323. /**
  65324. * Specifies whether the texture is in gamma space.
  65325. */
  65326. gammaSpace: boolean;
  65327. }
  65328. /**
  65329. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65330. */
  65331. export class PanoramaToCubeMapTools {
  65332. private static FACE_FRONT;
  65333. private static FACE_BACK;
  65334. private static FACE_RIGHT;
  65335. private static FACE_LEFT;
  65336. private static FACE_DOWN;
  65337. private static FACE_UP;
  65338. /**
  65339. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65340. *
  65341. * @param float32Array The source data.
  65342. * @param inputWidth The width of the input panorama.
  65343. * @param inputHeight The height of the input panorama.
  65344. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65345. * @return The cubemap data
  65346. */
  65347. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65348. private static CreateCubemapTexture;
  65349. private static CalcProjectionSpherical;
  65350. }
  65351. }
  65352. declare module BABYLON {
  65353. /**
  65354. * Helper class dealing with the extraction of spherical polynomial dataArray
  65355. * from a cube map.
  65356. */
  65357. export class CubeMapToSphericalPolynomialTools {
  65358. private static FileFaces;
  65359. /**
  65360. * Converts a texture to the according Spherical Polynomial data.
  65361. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65362. *
  65363. * @param texture The texture to extract the information from.
  65364. * @return The Spherical Polynomial data.
  65365. */
  65366. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65367. /**
  65368. * Converts a cubemap to the according Spherical Polynomial data.
  65369. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65370. *
  65371. * @param cubeInfo The Cube map to extract the information from.
  65372. * @return The Spherical Polynomial data.
  65373. */
  65374. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65375. }
  65376. }
  65377. declare module BABYLON {
  65378. /**
  65379. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65380. * during the life time of the application.
  65381. */
  65382. export class EngineStore {
  65383. /** Gets the list of created engines */
  65384. static Instances: Engine[];
  65385. /**
  65386. * Gets the latest created engine
  65387. */
  65388. static readonly LastCreatedEngine: Nullable<Engine>;
  65389. /**
  65390. * Gets the latest created scene
  65391. */
  65392. static readonly LastCreatedScene: Nullable<Scene>;
  65393. }
  65394. }
  65395. declare module BABYLON {
  65396. /**
  65397. * Define options used to create a render target texture
  65398. */
  65399. export class RenderTargetCreationOptions {
  65400. /**
  65401. * Specifies is mipmaps must be generated
  65402. */
  65403. generateMipMaps?: boolean;
  65404. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65405. generateDepthBuffer?: boolean;
  65406. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65407. generateStencilBuffer?: boolean;
  65408. /** Defines texture type (int by default) */
  65409. type?: number;
  65410. /** Defines sampling mode (trilinear by default) */
  65411. samplingMode?: number;
  65412. /** Defines format (RGBA by default) */
  65413. format?: number;
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * @hidden
  65419. **/
  65420. export class _AlphaState {
  65421. private _isAlphaBlendDirty;
  65422. private _isBlendFunctionParametersDirty;
  65423. private _isBlendEquationParametersDirty;
  65424. private _isBlendConstantsDirty;
  65425. private _alphaBlend;
  65426. private _blendFunctionParameters;
  65427. private _blendEquationParameters;
  65428. private _blendConstants;
  65429. /**
  65430. * Initializes the state.
  65431. */
  65432. constructor();
  65433. readonly isDirty: boolean;
  65434. alphaBlend: boolean;
  65435. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65436. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65437. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65438. reset(): void;
  65439. apply(gl: WebGLRenderingContext): void;
  65440. }
  65441. }
  65442. declare module BABYLON {
  65443. /**
  65444. * @hidden
  65445. **/
  65446. export class _DepthCullingState {
  65447. private _isDepthTestDirty;
  65448. private _isDepthMaskDirty;
  65449. private _isDepthFuncDirty;
  65450. private _isCullFaceDirty;
  65451. private _isCullDirty;
  65452. private _isZOffsetDirty;
  65453. private _isFrontFaceDirty;
  65454. private _depthTest;
  65455. private _depthMask;
  65456. private _depthFunc;
  65457. private _cull;
  65458. private _cullFace;
  65459. private _zOffset;
  65460. private _frontFace;
  65461. /**
  65462. * Initializes the state.
  65463. */
  65464. constructor();
  65465. readonly isDirty: boolean;
  65466. zOffset: number;
  65467. cullFace: Nullable<number>;
  65468. cull: Nullable<boolean>;
  65469. depthFunc: Nullable<number>;
  65470. depthMask: boolean;
  65471. depthTest: boolean;
  65472. frontFace: Nullable<number>;
  65473. reset(): void;
  65474. apply(gl: WebGLRenderingContext): void;
  65475. }
  65476. }
  65477. declare module BABYLON {
  65478. /**
  65479. * @hidden
  65480. **/
  65481. export class _StencilState {
  65482. /** 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 */
  65483. static readonly ALWAYS: number;
  65484. /** Passed to stencilOperation to specify that stencil value must be kept */
  65485. static readonly KEEP: number;
  65486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65487. static readonly REPLACE: number;
  65488. private _isStencilTestDirty;
  65489. private _isStencilMaskDirty;
  65490. private _isStencilFuncDirty;
  65491. private _isStencilOpDirty;
  65492. private _stencilTest;
  65493. private _stencilMask;
  65494. private _stencilFunc;
  65495. private _stencilFuncRef;
  65496. private _stencilFuncMask;
  65497. private _stencilOpStencilFail;
  65498. private _stencilOpDepthFail;
  65499. private _stencilOpStencilDepthPass;
  65500. readonly isDirty: boolean;
  65501. stencilFunc: number;
  65502. stencilFuncRef: number;
  65503. stencilFuncMask: number;
  65504. stencilOpStencilFail: number;
  65505. stencilOpDepthFail: number;
  65506. stencilOpStencilDepthPass: number;
  65507. stencilMask: number;
  65508. stencilTest: boolean;
  65509. constructor();
  65510. reset(): void;
  65511. apply(gl: WebGLRenderingContext): void;
  65512. }
  65513. }
  65514. declare module BABYLON {
  65515. /**
  65516. * @hidden
  65517. **/
  65518. export class _TimeToken {
  65519. _startTimeQuery: Nullable<WebGLQuery>;
  65520. _endTimeQuery: Nullable<WebGLQuery>;
  65521. _timeElapsedQuery: Nullable<WebGLQuery>;
  65522. _timeElapsedQueryEnded: boolean;
  65523. }
  65524. }
  65525. declare module BABYLON {
  65526. /**
  65527. * Internal interface used to track InternalTexture already bound to the GL context
  65528. */
  65529. export interface IInternalTextureTracker {
  65530. /**
  65531. * Gets or set the previous tracker in the list
  65532. */
  65533. previous: Nullable<IInternalTextureTracker>;
  65534. /**
  65535. * Gets or set the next tracker in the list
  65536. */
  65537. next: Nullable<IInternalTextureTracker>;
  65538. }
  65539. /**
  65540. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  65541. */
  65542. export class DummyInternalTextureTracker {
  65543. /**
  65544. * Gets or set the previous tracker in the list
  65545. */
  65546. previous: Nullable<IInternalTextureTracker>;
  65547. /**
  65548. * Gets or set the next tracker in the list
  65549. */
  65550. next: Nullable<IInternalTextureTracker>;
  65551. }
  65552. }
  65553. declare module BABYLON {
  65554. /**
  65555. * Class used to store data associated with WebGL texture data for the engine
  65556. * This class should not be used directly
  65557. */
  65558. export class InternalTexture implements IInternalTextureTracker {
  65559. /** hidden */
  65560. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65561. /**
  65562. * The source of the texture data is unknown
  65563. */
  65564. static DATASOURCE_UNKNOWN: number;
  65565. /**
  65566. * Texture data comes from an URL
  65567. */
  65568. static DATASOURCE_URL: number;
  65569. /**
  65570. * Texture data is only used for temporary storage
  65571. */
  65572. static DATASOURCE_TEMP: number;
  65573. /**
  65574. * Texture data comes from raw data (ArrayBuffer)
  65575. */
  65576. static DATASOURCE_RAW: number;
  65577. /**
  65578. * Texture content is dynamic (video or dynamic texture)
  65579. */
  65580. static DATASOURCE_DYNAMIC: number;
  65581. /**
  65582. * Texture content is generated by rendering to it
  65583. */
  65584. static DATASOURCE_RENDERTARGET: number;
  65585. /**
  65586. * Texture content is part of a multi render target process
  65587. */
  65588. static DATASOURCE_MULTIRENDERTARGET: number;
  65589. /**
  65590. * Texture data comes from a cube data file
  65591. */
  65592. static DATASOURCE_CUBE: number;
  65593. /**
  65594. * Texture data comes from a raw cube data
  65595. */
  65596. static DATASOURCE_CUBERAW: number;
  65597. /**
  65598. * Texture data come from a prefiltered cube data file
  65599. */
  65600. static DATASOURCE_CUBEPREFILTERED: number;
  65601. /**
  65602. * Texture content is raw 3D data
  65603. */
  65604. static DATASOURCE_RAW3D: number;
  65605. /**
  65606. * Texture content is a depth texture
  65607. */
  65608. static DATASOURCE_DEPTHTEXTURE: number;
  65609. /**
  65610. * Texture data comes from a raw cube data encoded with RGBD
  65611. */
  65612. static DATASOURCE_CUBERAW_RGBD: number;
  65613. /**
  65614. * Defines if the texture is ready
  65615. */
  65616. isReady: boolean;
  65617. /**
  65618. * Defines if the texture is a cube texture
  65619. */
  65620. isCube: boolean;
  65621. /**
  65622. * Defines if the texture contains 3D data
  65623. */
  65624. is3D: boolean;
  65625. /**
  65626. * Defines if the texture contains multiview data
  65627. */
  65628. isMultiview: boolean;
  65629. /**
  65630. * Gets the URL used to load this texture
  65631. */
  65632. url: string;
  65633. /**
  65634. * Gets the sampling mode of the texture
  65635. */
  65636. samplingMode: number;
  65637. /**
  65638. * Gets a boolean indicating if the texture needs mipmaps generation
  65639. */
  65640. generateMipMaps: boolean;
  65641. /**
  65642. * Gets the number of samples used by the texture (WebGL2+ only)
  65643. */
  65644. samples: number;
  65645. /**
  65646. * Gets the type of the texture (int, float...)
  65647. */
  65648. type: number;
  65649. /**
  65650. * Gets the format of the texture (RGB, RGBA...)
  65651. */
  65652. format: number;
  65653. /**
  65654. * Observable called when the texture is loaded
  65655. */
  65656. onLoadedObservable: Observable<InternalTexture>;
  65657. /**
  65658. * Gets the width of the texture
  65659. */
  65660. width: number;
  65661. /**
  65662. * Gets the height of the texture
  65663. */
  65664. height: number;
  65665. /**
  65666. * Gets the depth of the texture
  65667. */
  65668. depth: number;
  65669. /**
  65670. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65671. */
  65672. baseWidth: number;
  65673. /**
  65674. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65675. */
  65676. baseHeight: number;
  65677. /**
  65678. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65679. */
  65680. baseDepth: number;
  65681. /**
  65682. * Gets a boolean indicating if the texture is inverted on Y axis
  65683. */
  65684. invertY: boolean;
  65685. /**
  65686. * Gets or set the previous tracker in the list
  65687. */
  65688. previous: Nullable<IInternalTextureTracker>;
  65689. /**
  65690. * Gets or set the next tracker in the list
  65691. */
  65692. next: Nullable<IInternalTextureTracker>;
  65693. /** @hidden */
  65694. _invertVScale: boolean;
  65695. /** @hidden */
  65696. _initialSlot: number;
  65697. /** @hidden */
  65698. _designatedSlot: number;
  65699. /** @hidden */
  65700. _dataSource: number;
  65701. /** @hidden */
  65702. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65703. /** @hidden */
  65704. _bufferView: Nullable<ArrayBufferView>;
  65705. /** @hidden */
  65706. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65707. /** @hidden */
  65708. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65709. /** @hidden */
  65710. _size: number;
  65711. /** @hidden */
  65712. _extension: string;
  65713. /** @hidden */
  65714. _files: Nullable<string[]>;
  65715. /** @hidden */
  65716. _workingCanvas: HTMLCanvasElement;
  65717. /** @hidden */
  65718. _workingContext: CanvasRenderingContext2D;
  65719. /** @hidden */
  65720. _framebuffer: Nullable<WebGLFramebuffer>;
  65721. /** @hidden */
  65722. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65723. /** @hidden */
  65724. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65725. /** @hidden */
  65726. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65727. /** @hidden */
  65728. _attachments: Nullable<number[]>;
  65729. /** @hidden */
  65730. _cachedCoordinatesMode: Nullable<number>;
  65731. /** @hidden */
  65732. _cachedWrapU: Nullable<number>;
  65733. /** @hidden */
  65734. _cachedWrapV: Nullable<number>;
  65735. /** @hidden */
  65736. _cachedWrapR: Nullable<number>;
  65737. /** @hidden */
  65738. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65739. /** @hidden */
  65740. _isDisabled: boolean;
  65741. /** @hidden */
  65742. _compression: Nullable<string>;
  65743. /** @hidden */
  65744. _generateStencilBuffer: boolean;
  65745. /** @hidden */
  65746. _generateDepthBuffer: boolean;
  65747. /** @hidden */
  65748. _comparisonFunction: number;
  65749. /** @hidden */
  65750. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65751. /** @hidden */
  65752. _lodGenerationScale: number;
  65753. /** @hidden */
  65754. _lodGenerationOffset: number;
  65755. /** @hidden */
  65756. _colorTextureArray: Nullable<WebGLTexture>;
  65757. /** @hidden */
  65758. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65759. /** @hidden */
  65760. _lodTextureHigh: BaseTexture;
  65761. /** @hidden */
  65762. _lodTextureMid: BaseTexture;
  65763. /** @hidden */
  65764. _lodTextureLow: BaseTexture;
  65765. /** @hidden */
  65766. _isRGBD: boolean;
  65767. /** @hidden */
  65768. _webGLTexture: Nullable<WebGLTexture>;
  65769. /** @hidden */
  65770. _references: number;
  65771. private _engine;
  65772. /**
  65773. * Gets the Engine the texture belongs to.
  65774. * @returns The babylon engine
  65775. */
  65776. getEngine(): Engine;
  65777. /**
  65778. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65779. */
  65780. readonly dataSource: number;
  65781. /**
  65782. * Creates a new InternalTexture
  65783. * @param engine defines the engine to use
  65784. * @param dataSource defines the type of data that will be used
  65785. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65786. */
  65787. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65788. /**
  65789. * Increments the number of references (ie. the number of Texture that point to it)
  65790. */
  65791. incrementReferences(): void;
  65792. /**
  65793. * Change the size of the texture (not the size of the content)
  65794. * @param width defines the new width
  65795. * @param height defines the new height
  65796. * @param depth defines the new depth (1 by default)
  65797. */
  65798. updateSize(width: int, height: int, depth?: int): void;
  65799. /** @hidden */
  65800. _rebuild(): void;
  65801. /** @hidden */
  65802. _swapAndDie(target: InternalTexture): void;
  65803. /**
  65804. * Dispose the current allocated resources
  65805. */
  65806. dispose(): void;
  65807. }
  65808. }
  65809. declare module BABYLON {
  65810. /**
  65811. * This represents the main contract an easing function should follow.
  65812. * Easing functions are used throughout the animation system.
  65813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65814. */
  65815. export interface IEasingFunction {
  65816. /**
  65817. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65818. * of the easing function.
  65819. * The link below provides some of the most common examples of easing functions.
  65820. * @see https://easings.net/
  65821. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65822. * @returns the corresponding value on the curve defined by the easing function
  65823. */
  65824. ease(gradient: number): number;
  65825. }
  65826. /**
  65827. * Base class used for every default easing function.
  65828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65829. */
  65830. export class EasingFunction implements IEasingFunction {
  65831. /**
  65832. * Interpolation follows the mathematical formula associated with the easing function.
  65833. */
  65834. static readonly EASINGMODE_EASEIN: number;
  65835. /**
  65836. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65837. */
  65838. static readonly EASINGMODE_EASEOUT: number;
  65839. /**
  65840. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65841. */
  65842. static readonly EASINGMODE_EASEINOUT: number;
  65843. private _easingMode;
  65844. /**
  65845. * Sets the easing mode of the current function.
  65846. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65847. */
  65848. setEasingMode(easingMode: number): void;
  65849. /**
  65850. * Gets the current easing mode.
  65851. * @returns the easing mode
  65852. */
  65853. getEasingMode(): number;
  65854. /**
  65855. * @hidden
  65856. */
  65857. easeInCore(gradient: number): number;
  65858. /**
  65859. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65860. * of the easing function.
  65861. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65862. * @returns the corresponding value on the curve defined by the easing function
  65863. */
  65864. ease(gradient: number): number;
  65865. }
  65866. /**
  65867. * Easing function with a circle shape (see link below).
  65868. * @see https://easings.net/#easeInCirc
  65869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65870. */
  65871. export class CircleEase extends EasingFunction implements IEasingFunction {
  65872. /** @hidden */
  65873. easeInCore(gradient: number): number;
  65874. }
  65875. /**
  65876. * Easing function with a ease back shape (see link below).
  65877. * @see https://easings.net/#easeInBack
  65878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65879. */
  65880. export class BackEase extends EasingFunction implements IEasingFunction {
  65881. /** Defines the amplitude of the function */
  65882. amplitude: number;
  65883. /**
  65884. * Instantiates a back ease easing
  65885. * @see https://easings.net/#easeInBack
  65886. * @param amplitude Defines the amplitude of the function
  65887. */
  65888. constructor(
  65889. /** Defines the amplitude of the function */
  65890. amplitude?: number);
  65891. /** @hidden */
  65892. easeInCore(gradient: number): number;
  65893. }
  65894. /**
  65895. * Easing function with a bouncing shape (see link below).
  65896. * @see https://easings.net/#easeInBounce
  65897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65898. */
  65899. export class BounceEase extends EasingFunction implements IEasingFunction {
  65900. /** Defines the number of bounces */
  65901. bounces: number;
  65902. /** Defines the amplitude of the bounce */
  65903. bounciness: number;
  65904. /**
  65905. * Instantiates a bounce easing
  65906. * @see https://easings.net/#easeInBounce
  65907. * @param bounces Defines the number of bounces
  65908. * @param bounciness Defines the amplitude of the bounce
  65909. */
  65910. constructor(
  65911. /** Defines the number of bounces */
  65912. bounces?: number,
  65913. /** Defines the amplitude of the bounce */
  65914. bounciness?: number);
  65915. /** @hidden */
  65916. easeInCore(gradient: number): number;
  65917. }
  65918. /**
  65919. * Easing function with a power of 3 shape (see link below).
  65920. * @see https://easings.net/#easeInCubic
  65921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65922. */
  65923. export class CubicEase extends EasingFunction implements IEasingFunction {
  65924. /** @hidden */
  65925. easeInCore(gradient: number): number;
  65926. }
  65927. /**
  65928. * Easing function with an elastic shape (see link below).
  65929. * @see https://easings.net/#easeInElastic
  65930. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65931. */
  65932. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65933. /** Defines the number of oscillations*/
  65934. oscillations: number;
  65935. /** Defines the amplitude of the oscillations*/
  65936. springiness: number;
  65937. /**
  65938. * Instantiates an elastic easing function
  65939. * @see https://easings.net/#easeInElastic
  65940. * @param oscillations Defines the number of oscillations
  65941. * @param springiness Defines the amplitude of the oscillations
  65942. */
  65943. constructor(
  65944. /** Defines the number of oscillations*/
  65945. oscillations?: number,
  65946. /** Defines the amplitude of the oscillations*/
  65947. springiness?: number);
  65948. /** @hidden */
  65949. easeInCore(gradient: number): number;
  65950. }
  65951. /**
  65952. * Easing function with an exponential shape (see link below).
  65953. * @see https://easings.net/#easeInExpo
  65954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65955. */
  65956. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65957. /** Defines the exponent of the function */
  65958. exponent: number;
  65959. /**
  65960. * Instantiates an exponential easing function
  65961. * @see https://easings.net/#easeInExpo
  65962. * @param exponent Defines the exponent of the function
  65963. */
  65964. constructor(
  65965. /** Defines the exponent of the function */
  65966. exponent?: number);
  65967. /** @hidden */
  65968. easeInCore(gradient: number): number;
  65969. }
  65970. /**
  65971. * Easing function with a power shape (see link below).
  65972. * @see https://easings.net/#easeInQuad
  65973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65974. */
  65975. export class PowerEase extends EasingFunction implements IEasingFunction {
  65976. /** Defines the power of the function */
  65977. power: number;
  65978. /**
  65979. * Instantiates an power base easing function
  65980. * @see https://easings.net/#easeInQuad
  65981. * @param power Defines the power of the function
  65982. */
  65983. constructor(
  65984. /** Defines the power of the function */
  65985. power?: number);
  65986. /** @hidden */
  65987. easeInCore(gradient: number): number;
  65988. }
  65989. /**
  65990. * Easing function with a power of 2 shape (see link below).
  65991. * @see https://easings.net/#easeInQuad
  65992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65993. */
  65994. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65995. /** @hidden */
  65996. easeInCore(gradient: number): number;
  65997. }
  65998. /**
  65999. * Easing function with a power of 4 shape (see link below).
  66000. * @see https://easings.net/#easeInQuart
  66001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66002. */
  66003. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66004. /** @hidden */
  66005. easeInCore(gradient: number): number;
  66006. }
  66007. /**
  66008. * Easing function with a power of 5 shape (see link below).
  66009. * @see https://easings.net/#easeInQuint
  66010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66011. */
  66012. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66013. /** @hidden */
  66014. easeInCore(gradient: number): number;
  66015. }
  66016. /**
  66017. * Easing function with a sin shape (see link below).
  66018. * @see https://easings.net/#easeInSine
  66019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66020. */
  66021. export class SineEase extends EasingFunction implements IEasingFunction {
  66022. /** @hidden */
  66023. easeInCore(gradient: number): number;
  66024. }
  66025. /**
  66026. * Easing function with a bezier shape (see link below).
  66027. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66028. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66029. */
  66030. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66031. /** Defines the x component of the start tangent in the bezier curve */
  66032. x1: number;
  66033. /** Defines the y component of the start tangent in the bezier curve */
  66034. y1: number;
  66035. /** Defines the x component of the end tangent in the bezier curve */
  66036. x2: number;
  66037. /** Defines the y component of the end tangent in the bezier curve */
  66038. y2: number;
  66039. /**
  66040. * Instantiates a bezier function
  66041. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66042. * @param x1 Defines the x component of the start tangent in the bezier curve
  66043. * @param y1 Defines the y component of the start tangent in the bezier curve
  66044. * @param x2 Defines the x component of the end tangent in the bezier curve
  66045. * @param y2 Defines the y component of the end tangent in the bezier curve
  66046. */
  66047. constructor(
  66048. /** Defines the x component of the start tangent in the bezier curve */
  66049. x1?: number,
  66050. /** Defines the y component of the start tangent in the bezier curve */
  66051. y1?: number,
  66052. /** Defines the x component of the end tangent in the bezier curve */
  66053. x2?: number,
  66054. /** Defines the y component of the end tangent in the bezier curve */
  66055. y2?: number);
  66056. /** @hidden */
  66057. easeInCore(gradient: number): number;
  66058. }
  66059. }
  66060. declare module BABYLON {
  66061. /**
  66062. * Defines an interface which represents an animation key frame
  66063. */
  66064. export interface IAnimationKey {
  66065. /**
  66066. * Frame of the key frame
  66067. */
  66068. frame: number;
  66069. /**
  66070. * Value at the specifies key frame
  66071. */
  66072. value: any;
  66073. /**
  66074. * The input tangent for the cubic hermite spline
  66075. */
  66076. inTangent?: any;
  66077. /**
  66078. * The output tangent for the cubic hermite spline
  66079. */
  66080. outTangent?: any;
  66081. /**
  66082. * The animation interpolation type
  66083. */
  66084. interpolation?: AnimationKeyInterpolation;
  66085. }
  66086. /**
  66087. * Enum for the animation key frame interpolation type
  66088. */
  66089. export enum AnimationKeyInterpolation {
  66090. /**
  66091. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66092. */
  66093. STEP = 1
  66094. }
  66095. }
  66096. declare module BABYLON {
  66097. /**
  66098. * Represents the range of an animation
  66099. */
  66100. export class AnimationRange {
  66101. /**The name of the animation range**/
  66102. name: string;
  66103. /**The starting frame of the animation */
  66104. from: number;
  66105. /**The ending frame of the animation*/
  66106. to: number;
  66107. /**
  66108. * Initializes the range of an animation
  66109. * @param name The name of the animation range
  66110. * @param from The starting frame of the animation
  66111. * @param to The ending frame of the animation
  66112. */
  66113. constructor(
  66114. /**The name of the animation range**/
  66115. name: string,
  66116. /**The starting frame of the animation */
  66117. from: number,
  66118. /**The ending frame of the animation*/
  66119. to: number);
  66120. /**
  66121. * Makes a copy of the animation range
  66122. * @returns A copy of the animation range
  66123. */
  66124. clone(): AnimationRange;
  66125. }
  66126. }
  66127. declare module BABYLON {
  66128. /**
  66129. * Composed of a frame, and an action function
  66130. */
  66131. export class AnimationEvent {
  66132. /** The frame for which the event is triggered **/
  66133. frame: number;
  66134. /** The event to perform when triggered **/
  66135. action: (currentFrame: number) => void;
  66136. /** Specifies if the event should be triggered only once**/
  66137. onlyOnce?: boolean | undefined;
  66138. /**
  66139. * Specifies if the animation event is done
  66140. */
  66141. isDone: boolean;
  66142. /**
  66143. * Initializes the animation event
  66144. * @param frame The frame for which the event is triggered
  66145. * @param action The event to perform when triggered
  66146. * @param onlyOnce Specifies if the event should be triggered only once
  66147. */
  66148. constructor(
  66149. /** The frame for which the event is triggered **/
  66150. frame: number,
  66151. /** The event to perform when triggered **/
  66152. action: (currentFrame: number) => void,
  66153. /** Specifies if the event should be triggered only once**/
  66154. onlyOnce?: boolean | undefined);
  66155. /** @hidden */
  66156. _clone(): AnimationEvent;
  66157. }
  66158. }
  66159. declare module BABYLON {
  66160. /**
  66161. * Interface used to define a behavior
  66162. */
  66163. export interface Behavior<T> {
  66164. /** gets or sets behavior's name */
  66165. name: string;
  66166. /**
  66167. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66168. */
  66169. init(): void;
  66170. /**
  66171. * Called when the behavior is attached to a target
  66172. * @param target defines the target where the behavior is attached to
  66173. */
  66174. attach(target: T): void;
  66175. /**
  66176. * Called when the behavior is detached from its target
  66177. */
  66178. detach(): void;
  66179. }
  66180. /**
  66181. * Interface implemented by classes supporting behaviors
  66182. */
  66183. export interface IBehaviorAware<T> {
  66184. /**
  66185. * Attach a behavior
  66186. * @param behavior defines the behavior to attach
  66187. * @returns the current host
  66188. */
  66189. addBehavior(behavior: Behavior<T>): T;
  66190. /**
  66191. * Remove a behavior from the current object
  66192. * @param behavior defines the behavior to detach
  66193. * @returns the current host
  66194. */
  66195. removeBehavior(behavior: Behavior<T>): T;
  66196. /**
  66197. * Gets a behavior using its name to search
  66198. * @param name defines the name to search
  66199. * @returns the behavior or null if not found
  66200. */
  66201. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66202. }
  66203. }
  66204. declare module BABYLON {
  66205. /**
  66206. * @hidden
  66207. */
  66208. export class IntersectionInfo {
  66209. bu: Nullable<number>;
  66210. bv: Nullable<number>;
  66211. distance: number;
  66212. faceId: number;
  66213. subMeshId: number;
  66214. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66215. }
  66216. }
  66217. declare module BABYLON {
  66218. /**
  66219. * Class used to store bounding sphere information
  66220. */
  66221. export class BoundingSphere {
  66222. /**
  66223. * Gets the center of the bounding sphere in local space
  66224. */
  66225. readonly center: Vector3;
  66226. /**
  66227. * Radius of the bounding sphere in local space
  66228. */
  66229. radius: number;
  66230. /**
  66231. * Gets the center of the bounding sphere in world space
  66232. */
  66233. readonly centerWorld: Vector3;
  66234. /**
  66235. * Radius of the bounding sphere in world space
  66236. */
  66237. radiusWorld: number;
  66238. /**
  66239. * Gets the minimum vector in local space
  66240. */
  66241. readonly minimum: Vector3;
  66242. /**
  66243. * Gets the maximum vector in local space
  66244. */
  66245. readonly maximum: Vector3;
  66246. private _worldMatrix;
  66247. private static readonly TmpVector3;
  66248. /**
  66249. * Creates a new bounding sphere
  66250. * @param min defines the minimum vector (in local space)
  66251. * @param max defines the maximum vector (in local space)
  66252. * @param worldMatrix defines the new world matrix
  66253. */
  66254. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66255. /**
  66256. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66257. * @param min defines the new minimum vector (in local space)
  66258. * @param max defines the new maximum vector (in local space)
  66259. * @param worldMatrix defines the new world matrix
  66260. */
  66261. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66262. /**
  66263. * Scale the current bounding sphere by applying a scale factor
  66264. * @param factor defines the scale factor to apply
  66265. * @returns the current bounding box
  66266. */
  66267. scale(factor: number): BoundingSphere;
  66268. /**
  66269. * Gets the world matrix of the bounding box
  66270. * @returns a matrix
  66271. */
  66272. getWorldMatrix(): DeepImmutable<Matrix>;
  66273. /** @hidden */
  66274. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66275. /**
  66276. * Tests if the bounding sphere is intersecting the frustum planes
  66277. * @param frustumPlanes defines the frustum planes to test
  66278. * @returns true if there is an intersection
  66279. */
  66280. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66281. /**
  66282. * Tests if the bounding sphere center is in between the frustum planes.
  66283. * Used for optimistic fast inclusion.
  66284. * @param frustumPlanes defines the frustum planes to test
  66285. * @returns true if the sphere center is in between the frustum planes
  66286. */
  66287. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66288. /**
  66289. * Tests if a point is inside the bounding sphere
  66290. * @param point defines the point to test
  66291. * @returns true if the point is inside the bounding sphere
  66292. */
  66293. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66294. /**
  66295. * Checks if two sphere intersct
  66296. * @param sphere0 sphere 0
  66297. * @param sphere1 sphere 1
  66298. * @returns true if the speres intersect
  66299. */
  66300. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66301. }
  66302. }
  66303. declare module BABYLON {
  66304. /**
  66305. * Class used to store bounding box information
  66306. */
  66307. export class BoundingBox implements ICullable {
  66308. /**
  66309. * Gets the 8 vectors representing the bounding box in local space
  66310. */
  66311. readonly vectors: Vector3[];
  66312. /**
  66313. * Gets the center of the bounding box in local space
  66314. */
  66315. readonly center: Vector3;
  66316. /**
  66317. * Gets the center of the bounding box in world space
  66318. */
  66319. readonly centerWorld: Vector3;
  66320. /**
  66321. * Gets the extend size in local space
  66322. */
  66323. readonly extendSize: Vector3;
  66324. /**
  66325. * Gets the extend size in world space
  66326. */
  66327. readonly extendSizeWorld: Vector3;
  66328. /**
  66329. * Gets the OBB (object bounding box) directions
  66330. */
  66331. readonly directions: Vector3[];
  66332. /**
  66333. * Gets the 8 vectors representing the bounding box in world space
  66334. */
  66335. readonly vectorsWorld: Vector3[];
  66336. /**
  66337. * Gets the minimum vector in world space
  66338. */
  66339. readonly minimumWorld: Vector3;
  66340. /**
  66341. * Gets the maximum vector in world space
  66342. */
  66343. readonly maximumWorld: Vector3;
  66344. /**
  66345. * Gets the minimum vector in local space
  66346. */
  66347. readonly minimum: Vector3;
  66348. /**
  66349. * Gets the maximum vector in local space
  66350. */
  66351. readonly maximum: Vector3;
  66352. private _worldMatrix;
  66353. private static readonly TmpVector3;
  66354. /**
  66355. * @hidden
  66356. */
  66357. _tag: number;
  66358. /**
  66359. * Creates a new bounding box
  66360. * @param min defines the minimum vector (in local space)
  66361. * @param max defines the maximum vector (in local space)
  66362. * @param worldMatrix defines the new world matrix
  66363. */
  66364. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66365. /**
  66366. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66367. * @param min defines the new minimum vector (in local space)
  66368. * @param max defines the new maximum vector (in local space)
  66369. * @param worldMatrix defines the new world matrix
  66370. */
  66371. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66372. /**
  66373. * Scale the current bounding box by applying a scale factor
  66374. * @param factor defines the scale factor to apply
  66375. * @returns the current bounding box
  66376. */
  66377. scale(factor: number): BoundingBox;
  66378. /**
  66379. * Gets the world matrix of the bounding box
  66380. * @returns a matrix
  66381. */
  66382. getWorldMatrix(): DeepImmutable<Matrix>;
  66383. /** @hidden */
  66384. _update(world: DeepImmutable<Matrix>): void;
  66385. /**
  66386. * Tests if the bounding box is intersecting the frustum planes
  66387. * @param frustumPlanes defines the frustum planes to test
  66388. * @returns true if there is an intersection
  66389. */
  66390. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66391. /**
  66392. * Tests if the bounding box is entirely inside the frustum planes
  66393. * @param frustumPlanes defines the frustum planes to test
  66394. * @returns true if there is an inclusion
  66395. */
  66396. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66397. /**
  66398. * Tests if a point is inside the bounding box
  66399. * @param point defines the point to test
  66400. * @returns true if the point is inside the bounding box
  66401. */
  66402. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66403. /**
  66404. * Tests if the bounding box intersects with a bounding sphere
  66405. * @param sphere defines the sphere to test
  66406. * @returns true if there is an intersection
  66407. */
  66408. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66409. /**
  66410. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66411. * @param min defines the min vector to use
  66412. * @param max defines the max vector to use
  66413. * @returns true if there is an intersection
  66414. */
  66415. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66416. /**
  66417. * Tests if two bounding boxes are intersections
  66418. * @param box0 defines the first box to test
  66419. * @param box1 defines the second box to test
  66420. * @returns true if there is an intersection
  66421. */
  66422. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66423. /**
  66424. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66425. * @param minPoint defines the minimum vector of the bounding box
  66426. * @param maxPoint defines the maximum vector of the bounding box
  66427. * @param sphereCenter defines the sphere center
  66428. * @param sphereRadius defines the sphere radius
  66429. * @returns true if there is an intersection
  66430. */
  66431. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66432. /**
  66433. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66434. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66435. * @param frustumPlanes defines the frustum planes to test
  66436. * @return true if there is an inclusion
  66437. */
  66438. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66439. /**
  66440. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66441. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66442. * @param frustumPlanes defines the frustum planes to test
  66443. * @return true if there is an intersection
  66444. */
  66445. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66446. }
  66447. }
  66448. declare module BABYLON {
  66449. /** @hidden */
  66450. export class Collider {
  66451. /** Define if a collision was found */
  66452. collisionFound: boolean;
  66453. /**
  66454. * Define last intersection point in local space
  66455. */
  66456. intersectionPoint: Vector3;
  66457. /**
  66458. * Define last collided mesh
  66459. */
  66460. collidedMesh: Nullable<AbstractMesh>;
  66461. private _collisionPoint;
  66462. private _planeIntersectionPoint;
  66463. private _tempVector;
  66464. private _tempVector2;
  66465. private _tempVector3;
  66466. private _tempVector4;
  66467. private _edge;
  66468. private _baseToVertex;
  66469. private _destinationPoint;
  66470. private _slidePlaneNormal;
  66471. private _displacementVector;
  66472. /** @hidden */
  66473. _radius: Vector3;
  66474. /** @hidden */
  66475. _retry: number;
  66476. private _velocity;
  66477. private _basePoint;
  66478. private _epsilon;
  66479. /** @hidden */
  66480. _velocityWorldLength: number;
  66481. /** @hidden */
  66482. _basePointWorld: Vector3;
  66483. private _velocityWorld;
  66484. private _normalizedVelocity;
  66485. /** @hidden */
  66486. _initialVelocity: Vector3;
  66487. /** @hidden */
  66488. _initialPosition: Vector3;
  66489. private _nearestDistance;
  66490. private _collisionMask;
  66491. collisionMask: number;
  66492. /**
  66493. * Gets the plane normal used to compute the sliding response (in local space)
  66494. */
  66495. readonly slidePlaneNormal: Vector3;
  66496. /** @hidden */
  66497. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66498. /** @hidden */
  66499. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66500. /** @hidden */
  66501. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66502. /** @hidden */
  66503. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66504. /** @hidden */
  66505. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66506. /** @hidden */
  66507. _getResponse(pos: Vector3, vel: Vector3): void;
  66508. }
  66509. }
  66510. declare module BABYLON {
  66511. /**
  66512. * Interface for cullable objects
  66513. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66514. */
  66515. export interface ICullable {
  66516. /**
  66517. * Checks if the object or part of the object is in the frustum
  66518. * @param frustumPlanes Camera near/planes
  66519. * @returns true if the object is in frustum otherwise false
  66520. */
  66521. isInFrustum(frustumPlanes: Plane[]): boolean;
  66522. /**
  66523. * Checks if a cullable object (mesh...) is in the camera frustum
  66524. * Unlike isInFrustum this cheks the full bounding box
  66525. * @param frustumPlanes Camera near/planes
  66526. * @returns true if the object is in frustum otherwise false
  66527. */
  66528. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66529. }
  66530. /**
  66531. * Info for a bounding data of a mesh
  66532. */
  66533. export class BoundingInfo implements ICullable {
  66534. /**
  66535. * Bounding box for the mesh
  66536. */
  66537. readonly boundingBox: BoundingBox;
  66538. /**
  66539. * Bounding sphere for the mesh
  66540. */
  66541. readonly boundingSphere: BoundingSphere;
  66542. private _isLocked;
  66543. private static readonly TmpVector3;
  66544. /**
  66545. * Constructs bounding info
  66546. * @param minimum min vector of the bounding box/sphere
  66547. * @param maximum max vector of the bounding box/sphere
  66548. * @param worldMatrix defines the new world matrix
  66549. */
  66550. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66551. /**
  66552. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66553. * @param min defines the new minimum vector (in local space)
  66554. * @param max defines the new maximum vector (in local space)
  66555. * @param worldMatrix defines the new world matrix
  66556. */
  66557. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66558. /**
  66559. * min vector of the bounding box/sphere
  66560. */
  66561. readonly minimum: Vector3;
  66562. /**
  66563. * max vector of the bounding box/sphere
  66564. */
  66565. readonly maximum: Vector3;
  66566. /**
  66567. * If the info is locked and won't be updated to avoid perf overhead
  66568. */
  66569. isLocked: boolean;
  66570. /**
  66571. * Updates the bounding sphere and box
  66572. * @param world world matrix to be used to update
  66573. */
  66574. update(world: DeepImmutable<Matrix>): void;
  66575. /**
  66576. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66577. * @param center New center of the bounding info
  66578. * @param extend New extend of the bounding info
  66579. * @returns the current bounding info
  66580. */
  66581. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66582. /**
  66583. * Scale the current bounding info by applying a scale factor
  66584. * @param factor defines the scale factor to apply
  66585. * @returns the current bounding info
  66586. */
  66587. scale(factor: number): BoundingInfo;
  66588. /**
  66589. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66590. * @param frustumPlanes defines the frustum to test
  66591. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66592. * @returns true if the bounding info is in the frustum planes
  66593. */
  66594. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66595. /**
  66596. * Gets the world distance between the min and max points of the bounding box
  66597. */
  66598. readonly diagonalLength: number;
  66599. /**
  66600. * Checks if a cullable object (mesh...) is in the camera frustum
  66601. * Unlike isInFrustum this cheks the full bounding box
  66602. * @param frustumPlanes Camera near/planes
  66603. * @returns true if the object is in frustum otherwise false
  66604. */
  66605. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66606. /** @hidden */
  66607. _checkCollision(collider: Collider): boolean;
  66608. /**
  66609. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66610. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66611. * @param point the point to check intersection with
  66612. * @returns if the point intersects
  66613. */
  66614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66615. /**
  66616. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66617. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66618. * @param boundingInfo the bounding info to check intersection with
  66619. * @param precise if the intersection should be done using OBB
  66620. * @returns if the bounding info intersects
  66621. */
  66622. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66623. }
  66624. }
  66625. declare module BABYLON {
  66626. /**
  66627. * Defines an array and its length.
  66628. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66629. */
  66630. export interface ISmartArrayLike<T> {
  66631. /**
  66632. * The data of the array.
  66633. */
  66634. data: Array<T>;
  66635. /**
  66636. * The active length of the array.
  66637. */
  66638. length: number;
  66639. }
  66640. /**
  66641. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66642. */
  66643. export class SmartArray<T> implements ISmartArrayLike<T> {
  66644. /**
  66645. * The full set of data from the array.
  66646. */
  66647. data: Array<T>;
  66648. /**
  66649. * The active length of the array.
  66650. */
  66651. length: number;
  66652. protected _id: number;
  66653. /**
  66654. * Instantiates a Smart Array.
  66655. * @param capacity defines the default capacity of the array.
  66656. */
  66657. constructor(capacity: number);
  66658. /**
  66659. * Pushes a value at the end of the active data.
  66660. * @param value defines the object to push in the array.
  66661. */
  66662. push(value: T): void;
  66663. /**
  66664. * Iterates over the active data and apply the lambda to them.
  66665. * @param func defines the action to apply on each value.
  66666. */
  66667. forEach(func: (content: T) => void): void;
  66668. /**
  66669. * Sorts the full sets of data.
  66670. * @param compareFn defines the comparison function to apply.
  66671. */
  66672. sort(compareFn: (a: T, b: T) => number): void;
  66673. /**
  66674. * Resets the active data to an empty array.
  66675. */
  66676. reset(): void;
  66677. /**
  66678. * Releases all the data from the array as well as the array.
  66679. */
  66680. dispose(): void;
  66681. /**
  66682. * Concats the active data with a given array.
  66683. * @param array defines the data to concatenate with.
  66684. */
  66685. concat(array: any): void;
  66686. /**
  66687. * Returns the position of a value in the active data.
  66688. * @param value defines the value to find the index for
  66689. * @returns the index if found in the active data otherwise -1
  66690. */
  66691. indexOf(value: T): number;
  66692. /**
  66693. * Returns whether an element is part of the active data.
  66694. * @param value defines the value to look for
  66695. * @returns true if found in the active data otherwise false
  66696. */
  66697. contains(value: T): boolean;
  66698. private static _GlobalId;
  66699. }
  66700. /**
  66701. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66702. * The data in this array can only be present once
  66703. */
  66704. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66705. private _duplicateId;
  66706. /**
  66707. * Pushes a value at the end of the active data.
  66708. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66709. * @param value defines the object to push in the array.
  66710. */
  66711. push(value: T): void;
  66712. /**
  66713. * Pushes a value at the end of the active data.
  66714. * If the data is already present, it won t be added again
  66715. * @param value defines the object to push in the array.
  66716. * @returns true if added false if it was already present
  66717. */
  66718. pushNoDuplicate(value: T): boolean;
  66719. /**
  66720. * Resets the active data to an empty array.
  66721. */
  66722. reset(): void;
  66723. /**
  66724. * Concats the active data with a given array.
  66725. * This ensures no dupplicate will be present in the result.
  66726. * @param array defines the data to concatenate with.
  66727. */
  66728. concatWithNoDuplicate(array: any): void;
  66729. }
  66730. }
  66731. declare module BABYLON {
  66732. /**
  66733. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66734. * separate meshes. This can be use to improve performances.
  66735. * @see http://doc.babylonjs.com/how_to/multi_materials
  66736. */
  66737. export class MultiMaterial extends Material {
  66738. private _subMaterials;
  66739. /**
  66740. * Gets or Sets the list of Materials used within the multi material.
  66741. * They need to be ordered according to the submeshes order in the associated mesh
  66742. */
  66743. subMaterials: Nullable<Material>[];
  66744. /**
  66745. * Function used to align with Node.getChildren()
  66746. * @returns the list of Materials used within the multi material
  66747. */
  66748. getChildren(): Nullable<Material>[];
  66749. /**
  66750. * Instantiates a new Multi Material
  66751. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66752. * separate meshes. This can be use to improve performances.
  66753. * @see http://doc.babylonjs.com/how_to/multi_materials
  66754. * @param name Define the name in the scene
  66755. * @param scene Define the scene the material belongs to
  66756. */
  66757. constructor(name: string, scene: Scene);
  66758. private _hookArray;
  66759. /**
  66760. * Get one of the submaterial by its index in the submaterials array
  66761. * @param index The index to look the sub material at
  66762. * @returns The Material if the index has been defined
  66763. */
  66764. getSubMaterial(index: number): Nullable<Material>;
  66765. /**
  66766. * Get the list of active textures for the whole sub materials list.
  66767. * @returns All the textures that will be used during the rendering
  66768. */
  66769. getActiveTextures(): BaseTexture[];
  66770. /**
  66771. * Gets the current class name of the material e.g. "MultiMaterial"
  66772. * Mainly use in serialization.
  66773. * @returns the class name
  66774. */
  66775. getClassName(): string;
  66776. /**
  66777. * Checks if the material is ready to render the requested sub mesh
  66778. * @param mesh Define the mesh the submesh belongs to
  66779. * @param subMesh Define the sub mesh to look readyness for
  66780. * @param useInstances Define whether or not the material is used with instances
  66781. * @returns true if ready, otherwise false
  66782. */
  66783. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66784. /**
  66785. * Clones the current material and its related sub materials
  66786. * @param name Define the name of the newly cloned material
  66787. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66788. * @returns the cloned material
  66789. */
  66790. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66791. /**
  66792. * Serializes the materials into a JSON representation.
  66793. * @returns the JSON representation
  66794. */
  66795. serialize(): any;
  66796. /**
  66797. * Dispose the material and release its associated resources
  66798. * @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)
  66799. * @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)
  66800. * @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)
  66801. */
  66802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66803. /**
  66804. * Creates a MultiMaterial from parsed MultiMaterial data.
  66805. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66806. * @param scene defines the hosting scene
  66807. * @returns a new MultiMaterial
  66808. */
  66809. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66810. }
  66811. }
  66812. declare module BABYLON {
  66813. /**
  66814. * Class used to represent data loading progression
  66815. */
  66816. export class SceneLoaderFlags {
  66817. private static _ForceFullSceneLoadingForIncremental;
  66818. private static _ShowLoadingScreen;
  66819. private static _CleanBoneMatrixWeights;
  66820. private static _loggingLevel;
  66821. /**
  66822. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66823. */
  66824. static ForceFullSceneLoadingForIncremental: boolean;
  66825. /**
  66826. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66827. */
  66828. static ShowLoadingScreen: boolean;
  66829. /**
  66830. * Defines the current logging level (while loading the scene)
  66831. * @ignorenaming
  66832. */
  66833. static loggingLevel: number;
  66834. /**
  66835. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66836. */
  66837. static CleanBoneMatrixWeights: boolean;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * 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.
  66843. * @see https://doc.babylonjs.com/how_to/transformnode
  66844. */
  66845. export class TransformNode extends Node {
  66846. /**
  66847. * Object will not rotate to face the camera
  66848. */
  66849. static BILLBOARDMODE_NONE: number;
  66850. /**
  66851. * Object will rotate to face the camera but only on the x axis
  66852. */
  66853. static BILLBOARDMODE_X: number;
  66854. /**
  66855. * Object will rotate to face the camera but only on the y axis
  66856. */
  66857. static BILLBOARDMODE_Y: number;
  66858. /**
  66859. * Object will rotate to face the camera but only on the z axis
  66860. */
  66861. static BILLBOARDMODE_Z: number;
  66862. /**
  66863. * Object will rotate to face the camera
  66864. */
  66865. static BILLBOARDMODE_ALL: number;
  66866. private _forward;
  66867. private _forwardInverted;
  66868. private _up;
  66869. private _right;
  66870. private _rightInverted;
  66871. private _position;
  66872. private _rotation;
  66873. private _rotationQuaternion;
  66874. protected _scaling: Vector3;
  66875. protected _isDirty: boolean;
  66876. private _transformToBoneReferal;
  66877. /**
  66878. * Set the billboard mode. Default is 0.
  66879. *
  66880. * | Value | Type | Description |
  66881. * | --- | --- | --- |
  66882. * | 0 | BILLBOARDMODE_NONE | |
  66883. * | 1 | BILLBOARDMODE_X | |
  66884. * | 2 | BILLBOARDMODE_Y | |
  66885. * | 4 | BILLBOARDMODE_Z | |
  66886. * | 7 | BILLBOARDMODE_ALL | |
  66887. *
  66888. */
  66889. billboardMode: number;
  66890. /**
  66891. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66892. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66893. */
  66894. preserveParentRotationForBillboard: boolean;
  66895. /**
  66896. * 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
  66897. */
  66898. scalingDeterminant: number;
  66899. /**
  66900. * Sets the distance of the object to max, often used by skybox
  66901. */
  66902. infiniteDistance: boolean;
  66903. /**
  66904. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66905. * By default the system will update normals to compensate
  66906. */
  66907. ignoreNonUniformScaling: boolean;
  66908. /** @hidden */
  66909. _poseMatrix: Matrix;
  66910. /** @hidden */
  66911. _localMatrix: Matrix;
  66912. private _absolutePosition;
  66913. private _pivotMatrix;
  66914. private _pivotMatrixInverse;
  66915. protected _postMultiplyPivotMatrix: boolean;
  66916. private _tempMatrix;
  66917. private _tempMatrix2;
  66918. protected _isWorldMatrixFrozen: boolean;
  66919. /** @hidden */
  66920. _indexInSceneTransformNodesArray: number;
  66921. /**
  66922. * An event triggered after the world matrix is updated
  66923. */
  66924. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66925. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66926. /**
  66927. * Gets a string identifying the name of the class
  66928. * @returns "TransformNode" string
  66929. */
  66930. getClassName(): string;
  66931. /**
  66932. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66933. */
  66934. position: Vector3;
  66935. /**
  66936. * 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)).
  66937. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66938. */
  66939. rotation: Vector3;
  66940. /**
  66941. * 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)).
  66942. */
  66943. scaling: Vector3;
  66944. /**
  66945. * 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).
  66946. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66947. */
  66948. rotationQuaternion: Nullable<Quaternion>;
  66949. /**
  66950. * The forward direction of that transform in world space.
  66951. */
  66952. readonly forward: Vector3;
  66953. /**
  66954. * The up direction of that transform in world space.
  66955. */
  66956. readonly up: Vector3;
  66957. /**
  66958. * The right direction of that transform in world space.
  66959. */
  66960. readonly right: Vector3;
  66961. /**
  66962. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66963. * @param matrix the matrix to copy the pose from
  66964. * @returns this TransformNode.
  66965. */
  66966. updatePoseMatrix(matrix: Matrix): TransformNode;
  66967. /**
  66968. * Returns the mesh Pose matrix.
  66969. * @returns the pose matrix
  66970. */
  66971. getPoseMatrix(): Matrix;
  66972. /** @hidden */
  66973. _isSynchronized(): boolean;
  66974. /** @hidden */
  66975. _initCache(): void;
  66976. /**
  66977. * Flag the transform node as dirty (Forcing it to update everything)
  66978. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66979. * @returns this transform node
  66980. */
  66981. markAsDirty(property: string): TransformNode;
  66982. /**
  66983. * Returns the current mesh absolute position.
  66984. * Returns a Vector3.
  66985. */
  66986. readonly absolutePosition: Vector3;
  66987. /**
  66988. * Sets a new matrix to apply before all other transformation
  66989. * @param matrix defines the transform matrix
  66990. * @returns the current TransformNode
  66991. */
  66992. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66993. /**
  66994. * Sets a new pivot matrix to the current node
  66995. * @param matrix defines the new pivot matrix to use
  66996. * @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
  66997. * @returns the current TransformNode
  66998. */
  66999. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67000. /**
  67001. * Returns the mesh pivot matrix.
  67002. * Default : Identity.
  67003. * @returns the matrix
  67004. */
  67005. getPivotMatrix(): Matrix;
  67006. /**
  67007. * Prevents the World matrix to be computed any longer.
  67008. * @returns the TransformNode.
  67009. */
  67010. freezeWorldMatrix(): TransformNode;
  67011. /**
  67012. * Allows back the World matrix computation.
  67013. * @returns the TransformNode.
  67014. */
  67015. unfreezeWorldMatrix(): this;
  67016. /**
  67017. * True if the World matrix has been frozen.
  67018. */
  67019. readonly isWorldMatrixFrozen: boolean;
  67020. /**
  67021. * Retuns the mesh absolute position in the World.
  67022. * @returns a Vector3.
  67023. */
  67024. getAbsolutePosition(): Vector3;
  67025. /**
  67026. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67027. * @param absolutePosition the absolute position to set
  67028. * @returns the TransformNode.
  67029. */
  67030. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67031. /**
  67032. * Sets the mesh position in its local space.
  67033. * @param vector3 the position to set in localspace
  67034. * @returns the TransformNode.
  67035. */
  67036. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67037. /**
  67038. * Returns the mesh position in the local space from the current World matrix values.
  67039. * @returns a new Vector3.
  67040. */
  67041. getPositionExpressedInLocalSpace(): Vector3;
  67042. /**
  67043. * Translates the mesh along the passed Vector3 in its local space.
  67044. * @param vector3 the distance to translate in localspace
  67045. * @returns the TransformNode.
  67046. */
  67047. locallyTranslate(vector3: Vector3): TransformNode;
  67048. private static _lookAtVectorCache;
  67049. /**
  67050. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67051. * @param targetPoint the position (must be in same space as current mesh) to look at
  67052. * @param yawCor optional yaw (y-axis) correction in radians
  67053. * @param pitchCor optional pitch (x-axis) correction in radians
  67054. * @param rollCor optional roll (z-axis) correction in radians
  67055. * @param space the choosen space of the target
  67056. * @returns the TransformNode.
  67057. */
  67058. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67059. /**
  67060. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67061. * This Vector3 is expressed in the World space.
  67062. * @param localAxis axis to rotate
  67063. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67064. */
  67065. getDirection(localAxis: Vector3): Vector3;
  67066. /**
  67067. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67068. * localAxis is expressed in the mesh local space.
  67069. * result is computed in the Wordl space from the mesh World matrix.
  67070. * @param localAxis axis to rotate
  67071. * @param result the resulting transformnode
  67072. * @returns this TransformNode.
  67073. */
  67074. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67075. /**
  67076. * Sets this transform node rotation to the given local axis.
  67077. * @param localAxis the axis in local space
  67078. * @param yawCor optional yaw (y-axis) correction in radians
  67079. * @param pitchCor optional pitch (x-axis) correction in radians
  67080. * @param rollCor optional roll (z-axis) correction in radians
  67081. * @returns this TransformNode
  67082. */
  67083. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67084. /**
  67085. * Sets a new pivot point to the current node
  67086. * @param point defines the new pivot point to use
  67087. * @param space defines if the point is in world or local space (local by default)
  67088. * @returns the current TransformNode
  67089. */
  67090. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67091. /**
  67092. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67093. * @returns the pivot point
  67094. */
  67095. getPivotPoint(): Vector3;
  67096. /**
  67097. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67098. * @param result the vector3 to store the result
  67099. * @returns this TransformNode.
  67100. */
  67101. getPivotPointToRef(result: Vector3): TransformNode;
  67102. /**
  67103. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67104. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67105. */
  67106. getAbsolutePivotPoint(): Vector3;
  67107. /**
  67108. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67109. * @param result vector3 to store the result
  67110. * @returns this TransformNode.
  67111. */
  67112. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67113. /**
  67114. * Defines the passed node as the parent of the current node.
  67115. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67116. * @see https://doc.babylonjs.com/how_to/parenting
  67117. * @param node the node ot set as the parent
  67118. * @returns this TransformNode.
  67119. */
  67120. setParent(node: Nullable<Node>): TransformNode;
  67121. private _nonUniformScaling;
  67122. /**
  67123. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67124. */
  67125. readonly nonUniformScaling: boolean;
  67126. /** @hidden */
  67127. _updateNonUniformScalingState(value: boolean): boolean;
  67128. /**
  67129. * Attach the current TransformNode to another TransformNode associated with a bone
  67130. * @param bone Bone affecting the TransformNode
  67131. * @param affectedTransformNode TransformNode associated with the bone
  67132. * @returns this object
  67133. */
  67134. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67135. /**
  67136. * Detach the transform node if its associated with a bone
  67137. * @returns this object
  67138. */
  67139. detachFromBone(): TransformNode;
  67140. private static _rotationAxisCache;
  67141. /**
  67142. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67143. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67144. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67145. * The passed axis is also normalized.
  67146. * @param axis the axis to rotate around
  67147. * @param amount the amount to rotate in radians
  67148. * @param space Space to rotate in (Default: local)
  67149. * @returns the TransformNode.
  67150. */
  67151. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67152. /**
  67153. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67154. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67155. * The passed axis is also normalized. .
  67156. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67157. * @param point the point to rotate around
  67158. * @param axis the axis to rotate around
  67159. * @param amount the amount to rotate in radians
  67160. * @returns the TransformNode
  67161. */
  67162. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67163. /**
  67164. * Translates the mesh along the axis vector for the passed distance in the given space.
  67165. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67166. * @param axis the axis to translate in
  67167. * @param distance the distance to translate
  67168. * @param space Space to rotate in (Default: local)
  67169. * @returns the TransformNode.
  67170. */
  67171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67172. /**
  67173. * Adds a rotation step to the mesh current rotation.
  67174. * x, y, z are Euler angles expressed in radians.
  67175. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67176. * This means this rotation is made in the mesh local space only.
  67177. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67178. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67179. * ```javascript
  67180. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67181. * ```
  67182. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67183. * 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.
  67184. * @param x Rotation to add
  67185. * @param y Rotation to add
  67186. * @param z Rotation to add
  67187. * @returns the TransformNode.
  67188. */
  67189. addRotation(x: number, y: number, z: number): TransformNode;
  67190. /**
  67191. * @hidden
  67192. */
  67193. protected _getEffectiveParent(): Nullable<Node>;
  67194. /**
  67195. * Computes the world matrix of the node
  67196. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67197. * @returns the world matrix
  67198. */
  67199. computeWorldMatrix(force?: boolean): Matrix;
  67200. protected _afterComputeWorldMatrix(): void;
  67201. /**
  67202. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67203. * @param func callback function to add
  67204. *
  67205. * @returns the TransformNode.
  67206. */
  67207. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67208. /**
  67209. * Removes a registered callback function.
  67210. * @param func callback function to remove
  67211. * @returns the TransformNode.
  67212. */
  67213. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67214. /**
  67215. * Gets the position of the current mesh in camera space
  67216. * @param camera defines the camera to use
  67217. * @returns a position
  67218. */
  67219. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67220. /**
  67221. * Returns the distance from the mesh to the active camera
  67222. * @param camera defines the camera to use
  67223. * @returns the distance
  67224. */
  67225. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67226. /**
  67227. * Clone the current transform node
  67228. * @param name Name of the new clone
  67229. * @param newParent New parent for the clone
  67230. * @param doNotCloneChildren Do not clone children hierarchy
  67231. * @returns the new transform node
  67232. */
  67233. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67234. /**
  67235. * Serializes the objects information.
  67236. * @param currentSerializationObject defines the object to serialize in
  67237. * @returns the serialized object
  67238. */
  67239. serialize(currentSerializationObject?: any): any;
  67240. /**
  67241. * Returns a new TransformNode object parsed from the source provided.
  67242. * @param parsedTransformNode is the source.
  67243. * @param scene the scne the object belongs to
  67244. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67245. * @returns a new TransformNode object parsed from the source provided.
  67246. */
  67247. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67248. /**
  67249. * Get all child-transformNodes of this node
  67250. * @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
  67251. * @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
  67252. * @returns an array of TransformNode
  67253. */
  67254. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67255. /**
  67256. * Releases resources associated with this transform node.
  67257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67259. */
  67260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67261. }
  67262. }
  67263. declare module BABYLON {
  67264. /**
  67265. * Class used to override all child animations of a given target
  67266. */
  67267. export class AnimationPropertiesOverride {
  67268. /**
  67269. * Gets or sets a value indicating if animation blending must be used
  67270. */
  67271. enableBlending: boolean;
  67272. /**
  67273. * Gets or sets the blending speed to use when enableBlending is true
  67274. */
  67275. blendingSpeed: number;
  67276. /**
  67277. * Gets or sets the default loop mode to use
  67278. */
  67279. loopMode: number;
  67280. }
  67281. }
  67282. declare module BABYLON {
  67283. /**
  67284. * Class used to store bone information
  67285. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67286. */
  67287. export class Bone extends Node {
  67288. /**
  67289. * defines the bone name
  67290. */
  67291. name: string;
  67292. private static _tmpVecs;
  67293. private static _tmpQuat;
  67294. private static _tmpMats;
  67295. /**
  67296. * Gets the list of child bones
  67297. */
  67298. children: Bone[];
  67299. /** Gets the animations associated with this bone */
  67300. animations: Animation[];
  67301. /**
  67302. * Gets or sets bone length
  67303. */
  67304. length: number;
  67305. /**
  67306. * @hidden Internal only
  67307. * Set this value to map this bone to a different index in the transform matrices
  67308. * Set this value to -1 to exclude the bone from the transform matrices
  67309. */
  67310. _index: Nullable<number>;
  67311. private _skeleton;
  67312. private _localMatrix;
  67313. private _restPose;
  67314. private _baseMatrix;
  67315. private _absoluteTransform;
  67316. private _invertedAbsoluteTransform;
  67317. private _parent;
  67318. private _scalingDeterminant;
  67319. private _worldTransform;
  67320. private _localScaling;
  67321. private _localRotation;
  67322. private _localPosition;
  67323. private _needToDecompose;
  67324. private _needToCompose;
  67325. /** @hidden */
  67326. _linkedTransformNode: Nullable<TransformNode>;
  67327. /** @hidden */
  67328. /** @hidden */
  67329. _matrix: Matrix;
  67330. /**
  67331. * Create a new bone
  67332. * @param name defines the bone name
  67333. * @param skeleton defines the parent skeleton
  67334. * @param parentBone defines the parent (can be null if the bone is the root)
  67335. * @param localMatrix defines the local matrix
  67336. * @param restPose defines the rest pose matrix
  67337. * @param baseMatrix defines the base matrix
  67338. * @param index defines index of the bone in the hiearchy
  67339. */
  67340. constructor(
  67341. /**
  67342. * defines the bone name
  67343. */
  67344. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67345. /**
  67346. * Gets the current object class name.
  67347. * @return the class name
  67348. */
  67349. getClassName(): string;
  67350. /**
  67351. * Gets the parent skeleton
  67352. * @returns a skeleton
  67353. */
  67354. getSkeleton(): Skeleton;
  67355. /**
  67356. * Gets parent bone
  67357. * @returns a bone or null if the bone is the root of the bone hierarchy
  67358. */
  67359. getParent(): Nullable<Bone>;
  67360. /**
  67361. * Returns an array containing the root bones
  67362. * @returns an array containing the root bones
  67363. */
  67364. getChildren(): Array<Bone>;
  67365. /**
  67366. * Sets the parent bone
  67367. * @param parent defines the parent (can be null if the bone is the root)
  67368. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67369. */
  67370. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67371. /**
  67372. * Gets the local matrix
  67373. * @returns a matrix
  67374. */
  67375. getLocalMatrix(): Matrix;
  67376. /**
  67377. * Gets the base matrix (initial matrix which remains unchanged)
  67378. * @returns a matrix
  67379. */
  67380. getBaseMatrix(): Matrix;
  67381. /**
  67382. * Gets the rest pose matrix
  67383. * @returns a matrix
  67384. */
  67385. getRestPose(): Matrix;
  67386. /**
  67387. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67388. */
  67389. getWorldMatrix(): Matrix;
  67390. /**
  67391. * Sets the local matrix to rest pose matrix
  67392. */
  67393. returnToRest(): void;
  67394. /**
  67395. * Gets the inverse of the absolute transform matrix.
  67396. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67397. * @returns a matrix
  67398. */
  67399. getInvertedAbsoluteTransform(): Matrix;
  67400. /**
  67401. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67402. * @returns a matrix
  67403. */
  67404. getAbsoluteTransform(): Matrix;
  67405. /**
  67406. * Links with the given transform node.
  67407. * The local matrix of this bone is copied from the transform node every frame.
  67408. * @param transformNode defines the transform node to link to
  67409. */
  67410. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67411. /** Gets or sets current position (in local space) */
  67412. position: Vector3;
  67413. /** Gets or sets current rotation (in local space) */
  67414. rotation: Vector3;
  67415. /** Gets or sets current rotation quaternion (in local space) */
  67416. rotationQuaternion: Quaternion;
  67417. /** Gets or sets current scaling (in local space) */
  67418. scaling: Vector3;
  67419. /**
  67420. * Gets the animation properties override
  67421. */
  67422. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67423. private _decompose;
  67424. private _compose;
  67425. /**
  67426. * Update the base and local matrices
  67427. * @param matrix defines the new base or local matrix
  67428. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67429. * @param updateLocalMatrix defines if the local matrix should be updated
  67430. */
  67431. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67432. /** @hidden */
  67433. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67434. /**
  67435. * Flag the bone as dirty (Forcing it to update everything)
  67436. */
  67437. markAsDirty(): void;
  67438. private _markAsDirtyAndCompose;
  67439. private _markAsDirtyAndDecompose;
  67440. /**
  67441. * Translate the bone in local or world space
  67442. * @param vec The amount to translate the bone
  67443. * @param space The space that the translation is in
  67444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67445. */
  67446. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67447. /**
  67448. * Set the postion of the bone in local or world space
  67449. * @param position The position to set the bone
  67450. * @param space The space that the position is in
  67451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67452. */
  67453. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67454. /**
  67455. * Set the absolute position of the bone (world space)
  67456. * @param position The position to set the bone
  67457. * @param mesh The mesh that this bone is attached to
  67458. */
  67459. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67460. /**
  67461. * Scale the bone on the x, y and z axes (in local space)
  67462. * @param x The amount to scale the bone on the x axis
  67463. * @param y The amount to scale the bone on the y axis
  67464. * @param z The amount to scale the bone on the z axis
  67465. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67466. */
  67467. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67468. /**
  67469. * Set the bone scaling in local space
  67470. * @param scale defines the scaling vector
  67471. */
  67472. setScale(scale: Vector3): void;
  67473. /**
  67474. * Gets the current scaling in local space
  67475. * @returns the current scaling vector
  67476. */
  67477. getScale(): Vector3;
  67478. /**
  67479. * Gets the current scaling in local space and stores it in a target vector
  67480. * @param result defines the target vector
  67481. */
  67482. getScaleToRef(result: Vector3): void;
  67483. /**
  67484. * Set the yaw, pitch, and roll of the bone in local or world space
  67485. * @param yaw The rotation of the bone on the y axis
  67486. * @param pitch The rotation of the bone on the x axis
  67487. * @param roll The rotation of the bone on the z axis
  67488. * @param space The space that the axes of rotation are in
  67489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67490. */
  67491. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67492. /**
  67493. * Add a rotation to the bone on an axis in local or world space
  67494. * @param axis The axis to rotate the bone on
  67495. * @param amount The amount to rotate the bone
  67496. * @param space The space that the axis is in
  67497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67498. */
  67499. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67500. /**
  67501. * Set the rotation of the bone to a particular axis angle in local or world space
  67502. * @param axis The axis to rotate the bone on
  67503. * @param angle The angle that the bone should be rotated to
  67504. * @param space The space that the axis is in
  67505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67506. */
  67507. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67508. /**
  67509. * Set the euler rotation of the bone in local of world space
  67510. * @param rotation The euler rotation that the bone should be set to
  67511. * @param space The space that the rotation is in
  67512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67513. */
  67514. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67515. /**
  67516. * Set the quaternion rotation of the bone in local of world space
  67517. * @param quat The quaternion rotation that the bone should be set to
  67518. * @param space The space that the rotation is in
  67519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67520. */
  67521. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67522. /**
  67523. * Set the rotation matrix of the bone in local of world space
  67524. * @param rotMat The rotation matrix that the bone should be set to
  67525. * @param space The space that the rotation is in
  67526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67527. */
  67528. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67529. private _rotateWithMatrix;
  67530. private _getNegativeRotationToRef;
  67531. /**
  67532. * Get the position of the bone in local or world space
  67533. * @param space The space that the returned position is in
  67534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67535. * @returns The position of the bone
  67536. */
  67537. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67538. /**
  67539. * Copy the position of the bone to a vector3 in local or world space
  67540. * @param space The space that the returned position is in
  67541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67542. * @param result The vector3 to copy the position to
  67543. */
  67544. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67545. /**
  67546. * Get the absolute position of the bone (world space)
  67547. * @param mesh The mesh that this bone is attached to
  67548. * @returns The absolute position of the bone
  67549. */
  67550. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67551. /**
  67552. * Copy the absolute position of the bone (world space) to the result param
  67553. * @param mesh The mesh that this bone is attached to
  67554. * @param result The vector3 to copy the absolute position to
  67555. */
  67556. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67557. /**
  67558. * Compute the absolute transforms of this bone and its children
  67559. */
  67560. computeAbsoluteTransforms(): void;
  67561. /**
  67562. * Get the world direction from an axis that is in the local space of the bone
  67563. * @param localAxis The local direction that is used to compute the world direction
  67564. * @param mesh The mesh that this bone is attached to
  67565. * @returns The world direction
  67566. */
  67567. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67568. /**
  67569. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67570. * @param localAxis The local direction that is used to compute the world direction
  67571. * @param mesh The mesh that this bone is attached to
  67572. * @param result The vector3 that the world direction will be copied to
  67573. */
  67574. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67575. /**
  67576. * Get the euler rotation of the bone in local or world space
  67577. * @param space The space that the rotation should be in
  67578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67579. * @returns The euler rotation
  67580. */
  67581. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67582. /**
  67583. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67584. * @param space The space that the rotation should be in
  67585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67586. * @param result The vector3 that the rotation should be copied to
  67587. */
  67588. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67589. /**
  67590. * Get the quaternion rotation of the bone in either local or world space
  67591. * @param space The space that the rotation should be in
  67592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67593. * @returns The quaternion rotation
  67594. */
  67595. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67596. /**
  67597. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67598. * @param space The space that the rotation should be in
  67599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67600. * @param result The quaternion that the rotation should be copied to
  67601. */
  67602. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67603. /**
  67604. * Get the rotation matrix of the bone in local or world space
  67605. * @param space The space that the rotation should be in
  67606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67607. * @returns The rotation matrix
  67608. */
  67609. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67610. /**
  67611. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67612. * @param space The space that the rotation should be in
  67613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67614. * @param result The quaternion that the rotation should be copied to
  67615. */
  67616. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67617. /**
  67618. * Get the world position of a point that is in the local space of the bone
  67619. * @param position The local position
  67620. * @param mesh The mesh that this bone is attached to
  67621. * @returns The world position
  67622. */
  67623. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67624. /**
  67625. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67626. * @param position The local position
  67627. * @param mesh The mesh that this bone is attached to
  67628. * @param result The vector3 that the world position should be copied to
  67629. */
  67630. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67631. /**
  67632. * Get the local position of a point that is in world space
  67633. * @param position The world position
  67634. * @param mesh The mesh that this bone is attached to
  67635. * @returns The local position
  67636. */
  67637. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67638. /**
  67639. * Get the local position of a point that is in world space and copy it to the result param
  67640. * @param position The world position
  67641. * @param mesh The mesh that this bone is attached to
  67642. * @param result The vector3 that the local position should be copied to
  67643. */
  67644. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67645. }
  67646. }
  67647. declare module BABYLON {
  67648. /**
  67649. * Enum that determines the text-wrapping mode to use.
  67650. */
  67651. export enum InspectableType {
  67652. /**
  67653. * Checkbox for booleans
  67654. */
  67655. Checkbox = 0,
  67656. /**
  67657. * Sliders for numbers
  67658. */
  67659. Slider = 1,
  67660. /**
  67661. * Vector3
  67662. */
  67663. Vector3 = 2,
  67664. /**
  67665. * Quaternions
  67666. */
  67667. Quaternion = 3,
  67668. /**
  67669. * Color3
  67670. */
  67671. Color3 = 4
  67672. }
  67673. /**
  67674. * Interface used to define custom inspectable properties.
  67675. * This interface is used by the inspector to display custom property grids
  67676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67677. */
  67678. export interface IInspectable {
  67679. /**
  67680. * Gets the label to display
  67681. */
  67682. label: string;
  67683. /**
  67684. * Gets the name of the property to edit
  67685. */
  67686. propertyName: string;
  67687. /**
  67688. * Gets the type of the editor to use
  67689. */
  67690. type: InspectableType;
  67691. /**
  67692. * Gets the minimum value of the property when using in "slider" mode
  67693. */
  67694. min?: number;
  67695. /**
  67696. * Gets the maximum value of the property when using in "slider" mode
  67697. */
  67698. max?: number;
  67699. /**
  67700. * Gets the setp to use when using in "slider" mode
  67701. */
  67702. step?: number;
  67703. }
  67704. }
  67705. declare module BABYLON {
  67706. /**
  67707. * Class for creating a cube texture
  67708. */
  67709. export class CubeTexture extends BaseTexture {
  67710. private _delayedOnLoad;
  67711. /**
  67712. * The url of the texture
  67713. */
  67714. url: string;
  67715. /**
  67716. * Gets or sets the center of the bounding box associated with the cube texture.
  67717. * It must define where the camera used to render the texture was set
  67718. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67719. */
  67720. boundingBoxPosition: Vector3;
  67721. private _boundingBoxSize;
  67722. /**
  67723. * Gets or sets the size of the bounding box associated with the cube texture
  67724. * When defined, the cubemap will switch to local mode
  67725. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67726. * @example https://www.babylonjs-playground.com/#RNASML
  67727. */
  67728. /**
  67729. * Returns the bounding box size
  67730. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67731. */
  67732. boundingBoxSize: Vector3;
  67733. protected _rotationY: number;
  67734. /**
  67735. * Sets texture matrix rotation angle around Y axis in radians.
  67736. */
  67737. /**
  67738. * Gets texture matrix rotation angle around Y axis radians.
  67739. */
  67740. rotationY: number;
  67741. /**
  67742. * Are mip maps generated for this texture or not.
  67743. */
  67744. readonly noMipmap: boolean;
  67745. private _noMipmap;
  67746. private _files;
  67747. private _extensions;
  67748. private _textureMatrix;
  67749. private _format;
  67750. private _createPolynomials;
  67751. /** @hidden */
  67752. _prefiltered: boolean;
  67753. /**
  67754. * Creates a cube texture from an array of image urls
  67755. * @param files defines an array of image urls
  67756. * @param scene defines the hosting scene
  67757. * @param noMipmap specifies if mip maps are not used
  67758. * @returns a cube texture
  67759. */
  67760. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67761. /**
  67762. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67763. * @param url defines the url of the prefiltered texture
  67764. * @param scene defines the scene the texture is attached to
  67765. * @param forcedExtension defines the extension of the file if different from the url
  67766. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67767. * @return the prefiltered texture
  67768. */
  67769. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67770. /**
  67771. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67772. * as prefiltered data.
  67773. * @param rootUrl defines the url of the texture or the root name of the six images
  67774. * @param scene defines the scene the texture is attached to
  67775. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67776. * @param noMipmap defines if mipmaps should be created or not
  67777. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67778. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67779. * @param onError defines a callback triggered in case of error during load
  67780. * @param format defines the internal format to use for the texture once loaded
  67781. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67782. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67783. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67786. * @return the cube texture
  67787. */
  67788. 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);
  67789. /**
  67790. * Get the current class name of the texture useful for serialization or dynamic coding.
  67791. * @returns "CubeTexture"
  67792. */
  67793. getClassName(): string;
  67794. /**
  67795. * Update the url (and optional buffer) of this texture if url was null during construction.
  67796. * @param url the url of the texture
  67797. * @param forcedExtension defines the extension to use
  67798. * @param onLoad callback called when the texture is loaded (defaults to null)
  67799. */
  67800. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67801. /**
  67802. * Delays loading of the cube texture
  67803. * @param forcedExtension defines the extension to use
  67804. */
  67805. delayLoad(forcedExtension?: string): void;
  67806. /**
  67807. * Returns the reflection texture matrix
  67808. * @returns the reflection texture matrix
  67809. */
  67810. getReflectionTextureMatrix(): Matrix;
  67811. /**
  67812. * Sets the reflection texture matrix
  67813. * @param value Reflection texture matrix
  67814. */
  67815. setReflectionTextureMatrix(value: Matrix): void;
  67816. /**
  67817. * Parses text to create a cube texture
  67818. * @param parsedTexture define the serialized text to read from
  67819. * @param scene defines the hosting scene
  67820. * @param rootUrl defines the root url of the cube texture
  67821. * @returns a cube texture
  67822. */
  67823. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67824. /**
  67825. * Makes a clone, or deep copy, of the cube texture
  67826. * @returns a new cube texture
  67827. */
  67828. clone(): CubeTexture;
  67829. }
  67830. }
  67831. declare module BABYLON {
  67832. /** @hidden */
  67833. export var postprocessVertexShader: {
  67834. name: string;
  67835. shader: string;
  67836. };
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67841. * This is the base of the follow, arc rotate cameras and Free camera
  67842. * @see http://doc.babylonjs.com/features/cameras
  67843. */
  67844. export class TargetCamera extends Camera {
  67845. private static _RigCamTransformMatrix;
  67846. private static _TargetTransformMatrix;
  67847. private static _TargetFocalPoint;
  67848. /**
  67849. * Define the current direction the camera is moving to
  67850. */
  67851. cameraDirection: Vector3;
  67852. /**
  67853. * Define the current rotation the camera is rotating to
  67854. */
  67855. cameraRotation: Vector2;
  67856. /**
  67857. * When set, the up vector of the camera will be updated by the rotation of the camera
  67858. */
  67859. updateUpVectorFromRotation: boolean;
  67860. private _tmpQuaternion;
  67861. /**
  67862. * Define the current rotation of the camera
  67863. */
  67864. rotation: Vector3;
  67865. /**
  67866. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67867. */
  67868. rotationQuaternion: Quaternion;
  67869. /**
  67870. * Define the current speed of the camera
  67871. */
  67872. speed: number;
  67873. /**
  67874. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67875. * around all axis.
  67876. */
  67877. noRotationConstraint: boolean;
  67878. /**
  67879. * Define the current target of the camera as an object or a position.
  67880. */
  67881. lockedTarget: any;
  67882. /** @hidden */
  67883. _currentTarget: Vector3;
  67884. /** @hidden */
  67885. _initialFocalDistance: number;
  67886. /** @hidden */
  67887. _viewMatrix: Matrix;
  67888. /** @hidden */
  67889. _camMatrix: Matrix;
  67890. /** @hidden */
  67891. _cameraTransformMatrix: Matrix;
  67892. /** @hidden */
  67893. _cameraRotationMatrix: Matrix;
  67894. /** @hidden */
  67895. _referencePoint: Vector3;
  67896. /** @hidden */
  67897. _transformedReferencePoint: Vector3;
  67898. protected _globalCurrentTarget: Vector3;
  67899. protected _globalCurrentUpVector: Vector3;
  67900. /** @hidden */
  67901. _reset: () => void;
  67902. private _defaultUp;
  67903. /**
  67904. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67905. * This is the base of the follow, arc rotate cameras and Free camera
  67906. * @see http://doc.babylonjs.com/features/cameras
  67907. * @param name Defines the name of the camera in the scene
  67908. * @param position Defines the start position of the camera in the scene
  67909. * @param scene Defines the scene the camera belongs to
  67910. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67911. */
  67912. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67913. /**
  67914. * Gets the position in front of the camera at a given distance.
  67915. * @param distance The distance from the camera we want the position to be
  67916. * @returns the position
  67917. */
  67918. getFrontPosition(distance: number): Vector3;
  67919. /** @hidden */
  67920. _getLockedTargetPosition(): Nullable<Vector3>;
  67921. private _storedPosition;
  67922. private _storedRotation;
  67923. private _storedRotationQuaternion;
  67924. /**
  67925. * Store current camera state of the camera (fov, position, rotation, etc..)
  67926. * @returns the camera
  67927. */
  67928. storeState(): Camera;
  67929. /**
  67930. * Restored camera state. You must call storeState() first
  67931. * @returns whether it was successful or not
  67932. * @hidden
  67933. */
  67934. _restoreStateValues(): boolean;
  67935. /** @hidden */
  67936. _initCache(): void;
  67937. /** @hidden */
  67938. _updateCache(ignoreParentClass?: boolean): void;
  67939. /** @hidden */
  67940. _isSynchronizedViewMatrix(): boolean;
  67941. /** @hidden */
  67942. _computeLocalCameraSpeed(): number;
  67943. /**
  67944. * Defines the target the camera should look at.
  67945. * This will automatically adapt alpha beta and radius to fit within the new target.
  67946. * @param target Defines the new target as a Vector or a mesh
  67947. */
  67948. setTarget(target: Vector3): void;
  67949. /**
  67950. * Return the current target position of the camera. This value is expressed in local space.
  67951. * @returns the target position
  67952. */
  67953. getTarget(): Vector3;
  67954. /** @hidden */
  67955. _decideIfNeedsToMove(): boolean;
  67956. /** @hidden */
  67957. _updatePosition(): void;
  67958. /** @hidden */
  67959. _checkInputs(): void;
  67960. protected _updateCameraRotationMatrix(): void;
  67961. /**
  67962. * 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)
  67963. * @returns the current camera
  67964. */
  67965. private _rotateUpVectorWithCameraRotationMatrix;
  67966. private _cachedRotationZ;
  67967. private _cachedQuaternionRotationZ;
  67968. /** @hidden */
  67969. _getViewMatrix(): Matrix;
  67970. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67971. /**
  67972. * @hidden
  67973. */
  67974. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67975. /**
  67976. * @hidden
  67977. */
  67978. _updateRigCameras(): void;
  67979. private _getRigCamPositionAndTarget;
  67980. /**
  67981. * Gets the current object class name.
  67982. * @return the class name
  67983. */
  67984. getClassName(): string;
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /**
  67989. * @ignore
  67990. * This is a list of all the different input types that are available in the application.
  67991. * Fo instance: ArcRotateCameraGamepadInput...
  67992. */
  67993. export var CameraInputTypes: {};
  67994. /**
  67995. * This is the contract to implement in order to create a new input class.
  67996. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67997. */
  67998. export interface ICameraInput<TCamera extends Camera> {
  67999. /**
  68000. * Defines the camera the input is attached to.
  68001. */
  68002. camera: Nullable<TCamera>;
  68003. /**
  68004. * Gets the class name of the current intput.
  68005. * @returns the class name
  68006. */
  68007. getClassName(): string;
  68008. /**
  68009. * Get the friendly name associated with the input class.
  68010. * @returns the input friendly name
  68011. */
  68012. getSimpleName(): string;
  68013. /**
  68014. * Attach the input controls to a specific dom element to get the input from.
  68015. * @param element Defines the element the controls should be listened from
  68016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68017. */
  68018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68019. /**
  68020. * Detach the current controls from the specified dom element.
  68021. * @param element Defines the element to stop listening the inputs from
  68022. */
  68023. detachControl(element: Nullable<HTMLElement>): void;
  68024. /**
  68025. * Update the current camera state depending on the inputs that have been used this frame.
  68026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68027. */
  68028. checkInputs?: () => void;
  68029. }
  68030. /**
  68031. * Represents a map of input types to input instance or input index to input instance.
  68032. */
  68033. export interface CameraInputsMap<TCamera extends Camera> {
  68034. /**
  68035. * Accessor to the input by input type.
  68036. */
  68037. [name: string]: ICameraInput<TCamera>;
  68038. /**
  68039. * Accessor to the input by input index.
  68040. */
  68041. [idx: number]: ICameraInput<TCamera>;
  68042. }
  68043. /**
  68044. * This represents the input manager used within a camera.
  68045. * It helps dealing with all the different kind of input attached to a camera.
  68046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68047. */
  68048. export class CameraInputsManager<TCamera extends Camera> {
  68049. /**
  68050. * Defines the list of inputs attahed to the camera.
  68051. */
  68052. attached: CameraInputsMap<TCamera>;
  68053. /**
  68054. * Defines the dom element the camera is collecting inputs from.
  68055. * This is null if the controls have not been attached.
  68056. */
  68057. attachedElement: Nullable<HTMLElement>;
  68058. /**
  68059. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68060. */
  68061. noPreventDefault: boolean;
  68062. /**
  68063. * Defined the camera the input manager belongs to.
  68064. */
  68065. camera: TCamera;
  68066. /**
  68067. * Update the current camera state depending on the inputs that have been used this frame.
  68068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68069. */
  68070. checkInputs: () => void;
  68071. /**
  68072. * Instantiate a new Camera Input Manager.
  68073. * @param camera Defines the camera the input manager blongs to
  68074. */
  68075. constructor(camera: TCamera);
  68076. /**
  68077. * Add an input method to a camera
  68078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68079. * @param input camera input method
  68080. */
  68081. add(input: ICameraInput<TCamera>): void;
  68082. /**
  68083. * Remove a specific input method from a camera
  68084. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68085. * @param inputToRemove camera input method
  68086. */
  68087. remove(inputToRemove: ICameraInput<TCamera>): void;
  68088. /**
  68089. * Remove a specific input type from a camera
  68090. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68091. * @param inputType the type of the input to remove
  68092. */
  68093. removeByType(inputType: string): void;
  68094. private _addCheckInputs;
  68095. /**
  68096. * Attach the input controls to the currently attached dom element to listen the events from.
  68097. * @param input Defines the input to attach
  68098. */
  68099. attachInput(input: ICameraInput<TCamera>): void;
  68100. /**
  68101. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68102. * @param element Defines the dom element to collect the events from
  68103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68104. */
  68105. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68106. /**
  68107. * Detach the current manager inputs controls from a specific dom element.
  68108. * @param element Defines the dom element to collect the events from
  68109. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68110. */
  68111. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68112. /**
  68113. * Rebuild the dynamic inputCheck function from the current list of
  68114. * defined inputs in the manager.
  68115. */
  68116. rebuildInputCheck(): void;
  68117. /**
  68118. * Remove all attached input methods from a camera
  68119. */
  68120. clear(): void;
  68121. /**
  68122. * Serialize the current input manager attached to a camera.
  68123. * This ensures than once parsed,
  68124. * the input associated to the camera will be identical to the current ones
  68125. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68126. */
  68127. serialize(serializedCamera: any): void;
  68128. /**
  68129. * Parses an input manager serialized JSON to restore the previous list of inputs
  68130. * and states associated to a camera.
  68131. * @param parsedCamera Defines the JSON to parse
  68132. */
  68133. parse(parsedCamera: any): void;
  68134. }
  68135. }
  68136. declare module BABYLON {
  68137. /**
  68138. * Gather the list of keyboard event types as constants.
  68139. */
  68140. export class KeyboardEventTypes {
  68141. /**
  68142. * The keydown event is fired when a key becomes active (pressed).
  68143. */
  68144. static readonly KEYDOWN: number;
  68145. /**
  68146. * The keyup event is fired when a key has been released.
  68147. */
  68148. static readonly KEYUP: number;
  68149. }
  68150. /**
  68151. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68152. */
  68153. export class KeyboardInfo {
  68154. /**
  68155. * Defines the type of event (KeyboardEventTypes)
  68156. */
  68157. type: number;
  68158. /**
  68159. * Defines the related dom event
  68160. */
  68161. event: KeyboardEvent;
  68162. /**
  68163. * Instantiates a new keyboard info.
  68164. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68165. * @param type Defines the type of event (KeyboardEventTypes)
  68166. * @param event Defines the related dom event
  68167. */
  68168. constructor(
  68169. /**
  68170. * Defines the type of event (KeyboardEventTypes)
  68171. */
  68172. type: number,
  68173. /**
  68174. * Defines the related dom event
  68175. */
  68176. event: KeyboardEvent);
  68177. }
  68178. /**
  68179. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68180. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68181. */
  68182. export class KeyboardInfoPre extends KeyboardInfo {
  68183. /**
  68184. * Defines the type of event (KeyboardEventTypes)
  68185. */
  68186. type: number;
  68187. /**
  68188. * Defines the related dom event
  68189. */
  68190. event: KeyboardEvent;
  68191. /**
  68192. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68193. */
  68194. skipOnPointerObservable: boolean;
  68195. /**
  68196. * Instantiates a new keyboard pre info.
  68197. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68198. * @param type Defines the type of event (KeyboardEventTypes)
  68199. * @param event Defines the related dom event
  68200. */
  68201. constructor(
  68202. /**
  68203. * Defines the type of event (KeyboardEventTypes)
  68204. */
  68205. type: number,
  68206. /**
  68207. * Defines the related dom event
  68208. */
  68209. event: KeyboardEvent);
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /**
  68214. * Manage the keyboard inputs to control the movement of a free camera.
  68215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68216. */
  68217. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68218. /**
  68219. * Defines the camera the input is attached to.
  68220. */
  68221. camera: FreeCamera;
  68222. /**
  68223. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68224. */
  68225. keysUp: number[];
  68226. /**
  68227. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68228. */
  68229. keysDown: number[];
  68230. /**
  68231. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68232. */
  68233. keysLeft: number[];
  68234. /**
  68235. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68236. */
  68237. keysRight: number[];
  68238. private _keys;
  68239. private _onCanvasBlurObserver;
  68240. private _onKeyboardObserver;
  68241. private _engine;
  68242. private _scene;
  68243. /**
  68244. * Attach the input controls to a specific dom element to get the input from.
  68245. * @param element Defines the element the controls should be listened from
  68246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68247. */
  68248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68249. /**
  68250. * Detach the current controls from the specified dom element.
  68251. * @param element Defines the element to stop listening the inputs from
  68252. */
  68253. detachControl(element: Nullable<HTMLElement>): void;
  68254. /**
  68255. * Update the current camera state depending on the inputs that have been used this frame.
  68256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68257. */
  68258. checkInputs(): void;
  68259. /**
  68260. * Gets the class name of the current intput.
  68261. * @returns the class name
  68262. */
  68263. getClassName(): string;
  68264. /** @hidden */
  68265. _onLostFocus(): void;
  68266. /**
  68267. * Get the friendly name associated with the input class.
  68268. * @returns the input friendly name
  68269. */
  68270. getSimpleName(): string;
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. /**
  68275. * Interface describing all the common properties and methods a shadow light needs to implement.
  68276. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68277. * as well as binding the different shadow properties to the effects.
  68278. */
  68279. export interface IShadowLight extends Light {
  68280. /**
  68281. * The light id in the scene (used in scene.findLighById for instance)
  68282. */
  68283. id: string;
  68284. /**
  68285. * The position the shdow will be casted from.
  68286. */
  68287. position: Vector3;
  68288. /**
  68289. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68290. */
  68291. direction: Vector3;
  68292. /**
  68293. * The transformed position. Position of the light in world space taking parenting in account.
  68294. */
  68295. transformedPosition: Vector3;
  68296. /**
  68297. * The transformed direction. Direction of the light in world space taking parenting in account.
  68298. */
  68299. transformedDirection: Vector3;
  68300. /**
  68301. * The friendly name of the light in the scene.
  68302. */
  68303. name: string;
  68304. /**
  68305. * Defines the shadow projection clipping minimum z value.
  68306. */
  68307. shadowMinZ: number;
  68308. /**
  68309. * Defines the shadow projection clipping maximum z value.
  68310. */
  68311. shadowMaxZ: number;
  68312. /**
  68313. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68314. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68315. */
  68316. computeTransformedInformation(): boolean;
  68317. /**
  68318. * Gets the scene the light belongs to.
  68319. * @returns The scene
  68320. */
  68321. getScene(): Scene;
  68322. /**
  68323. * Callback defining a custom Projection Matrix Builder.
  68324. * This can be used to override the default projection matrix computation.
  68325. */
  68326. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68327. /**
  68328. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68329. * @param matrix The materix to updated with the projection information
  68330. * @param viewMatrix The transform matrix of the light
  68331. * @param renderList The list of mesh to render in the map
  68332. * @returns The current light
  68333. */
  68334. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68335. /**
  68336. * Gets the current depth scale used in ESM.
  68337. * @returns The scale
  68338. */
  68339. getDepthScale(): number;
  68340. /**
  68341. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68342. * @returns true if a cube texture needs to be use
  68343. */
  68344. needCube(): boolean;
  68345. /**
  68346. * Detects if the projection matrix requires to be recomputed this frame.
  68347. * @returns true if it requires to be recomputed otherwise, false.
  68348. */
  68349. needProjectionMatrixCompute(): boolean;
  68350. /**
  68351. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68352. */
  68353. forceProjectionMatrixCompute(): void;
  68354. /**
  68355. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68356. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68357. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68358. */
  68359. getShadowDirection(faceIndex?: number): Vector3;
  68360. /**
  68361. * Gets the minZ used for shadow according to both the scene and the light.
  68362. * @param activeCamera The camera we are returning the min for
  68363. * @returns the depth min z
  68364. */
  68365. getDepthMinZ(activeCamera: Camera): number;
  68366. /**
  68367. * Gets the maxZ used for shadow according to both the scene and the light.
  68368. * @param activeCamera The camera we are returning the max for
  68369. * @returns the depth max z
  68370. */
  68371. getDepthMaxZ(activeCamera: Camera): number;
  68372. }
  68373. /**
  68374. * Base implementation IShadowLight
  68375. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68376. */
  68377. export abstract class ShadowLight extends Light implements IShadowLight {
  68378. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68379. protected _position: Vector3;
  68380. protected _setPosition(value: Vector3): void;
  68381. /**
  68382. * Sets the position the shadow will be casted from. Also use as the light position for both
  68383. * point and spot lights.
  68384. */
  68385. /**
  68386. * Sets the position the shadow will be casted from. Also use as the light position for both
  68387. * point and spot lights.
  68388. */
  68389. position: Vector3;
  68390. protected _direction: Vector3;
  68391. protected _setDirection(value: Vector3): void;
  68392. /**
  68393. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68394. * Also use as the light direction on spot and directional lights.
  68395. */
  68396. /**
  68397. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68398. * Also use as the light direction on spot and directional lights.
  68399. */
  68400. direction: Vector3;
  68401. private _shadowMinZ;
  68402. /**
  68403. * Gets the shadow projection clipping minimum z value.
  68404. */
  68405. /**
  68406. * Sets the shadow projection clipping minimum z value.
  68407. */
  68408. shadowMinZ: number;
  68409. private _shadowMaxZ;
  68410. /**
  68411. * Sets the shadow projection clipping maximum z value.
  68412. */
  68413. /**
  68414. * Gets the shadow projection clipping maximum z value.
  68415. */
  68416. shadowMaxZ: number;
  68417. /**
  68418. * Callback defining a custom Projection Matrix Builder.
  68419. * This can be used to override the default projection matrix computation.
  68420. */
  68421. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68422. /**
  68423. * The transformed position. Position of the light in world space taking parenting in account.
  68424. */
  68425. transformedPosition: Vector3;
  68426. /**
  68427. * The transformed direction. Direction of the light in world space taking parenting in account.
  68428. */
  68429. transformedDirection: Vector3;
  68430. private _needProjectionMatrixCompute;
  68431. /**
  68432. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68433. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68434. */
  68435. computeTransformedInformation(): boolean;
  68436. /**
  68437. * Return the depth scale used for the shadow map.
  68438. * @returns the depth scale.
  68439. */
  68440. getDepthScale(): number;
  68441. /**
  68442. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68443. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68444. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68445. */
  68446. getShadowDirection(faceIndex?: number): Vector3;
  68447. /**
  68448. * Returns the ShadowLight absolute position in the World.
  68449. * @returns the position vector in world space
  68450. */
  68451. getAbsolutePosition(): Vector3;
  68452. /**
  68453. * Sets the ShadowLight direction toward the passed target.
  68454. * @param target The point to target in local space
  68455. * @returns the updated ShadowLight direction
  68456. */
  68457. setDirectionToTarget(target: Vector3): Vector3;
  68458. /**
  68459. * Returns the light rotation in euler definition.
  68460. * @returns the x y z rotation in local space.
  68461. */
  68462. getRotation(): Vector3;
  68463. /**
  68464. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68465. * @returns true if a cube texture needs to be use
  68466. */
  68467. needCube(): boolean;
  68468. /**
  68469. * Detects if the projection matrix requires to be recomputed this frame.
  68470. * @returns true if it requires to be recomputed otherwise, false.
  68471. */
  68472. needProjectionMatrixCompute(): boolean;
  68473. /**
  68474. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68475. */
  68476. forceProjectionMatrixCompute(): void;
  68477. /** @hidden */
  68478. _initCache(): void;
  68479. /** @hidden */
  68480. _isSynchronized(): boolean;
  68481. /**
  68482. * Computes the world matrix of the node
  68483. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68484. * @returns the world matrix
  68485. */
  68486. computeWorldMatrix(force?: boolean): Matrix;
  68487. /**
  68488. * Gets the minZ used for shadow according to both the scene and the light.
  68489. * @param activeCamera The camera we are returning the min for
  68490. * @returns the depth min z
  68491. */
  68492. getDepthMinZ(activeCamera: Camera): number;
  68493. /**
  68494. * Gets the maxZ used for shadow according to both the scene and the light.
  68495. * @param activeCamera The camera we are returning the max for
  68496. * @returns the depth max z
  68497. */
  68498. getDepthMaxZ(activeCamera: Camera): number;
  68499. /**
  68500. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68501. * @param matrix The materix to updated with the projection information
  68502. * @param viewMatrix The transform matrix of the light
  68503. * @param renderList The list of mesh to render in the map
  68504. * @returns The current light
  68505. */
  68506. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * "Static Class" containing the most commonly used helper while dealing with material for
  68512. * rendering purpose.
  68513. *
  68514. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68515. *
  68516. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68517. */
  68518. export class MaterialHelper {
  68519. /**
  68520. * Bind the current view position to an effect.
  68521. * @param effect The effect to be bound
  68522. * @param scene The scene the eyes position is used from
  68523. */
  68524. static BindEyePosition(effect: Effect, scene: Scene): void;
  68525. /**
  68526. * Helps preparing the defines values about the UVs in used in the effect.
  68527. * UVs are shared as much as we can accross channels in the shaders.
  68528. * @param texture The texture we are preparing the UVs for
  68529. * @param defines The defines to update
  68530. * @param key The channel key "diffuse", "specular"... used in the shader
  68531. */
  68532. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68533. /**
  68534. * Binds a texture matrix value to its corrsponding uniform
  68535. * @param texture The texture to bind the matrix for
  68536. * @param uniformBuffer The uniform buffer receivin the data
  68537. * @param key The channel key "diffuse", "specular"... used in the shader
  68538. */
  68539. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68540. /**
  68541. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68542. * @param mesh defines the current mesh
  68543. * @param scene defines the current scene
  68544. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68545. * @param pointsCloud defines if point cloud rendering has to be turned on
  68546. * @param fogEnabled defines if fog has to be turned on
  68547. * @param alphaTest defines if alpha testing has to be turned on
  68548. * @param defines defines the current list of defines
  68549. */
  68550. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68551. /**
  68552. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68553. * @param scene defines the current scene
  68554. * @param engine defines the current engine
  68555. * @param defines specifies the list of active defines
  68556. * @param useInstances defines if instances have to be turned on
  68557. * @param useClipPlane defines if clip plane have to be turned on
  68558. */
  68559. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68560. /**
  68561. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68562. * @param mesh The mesh containing the geometry data we will draw
  68563. * @param defines The defines to update
  68564. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68565. * @param useBones Precise whether bones should be used or not (override mesh info)
  68566. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68567. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68568. * @returns false if defines are considered not dirty and have not been checked
  68569. */
  68570. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68571. /**
  68572. * Prepares the defines related to multiview
  68573. * @param scene The scene we are intending to draw
  68574. * @param defines The defines to update
  68575. */
  68576. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68577. /**
  68578. * Prepares the defines related to the light information passed in parameter
  68579. * @param scene The scene we are intending to draw
  68580. * @param mesh The mesh the effect is compiling for
  68581. * @param defines The defines to update
  68582. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68583. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68584. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68585. * @returns true if normals will be required for the rest of the effect
  68586. */
  68587. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68588. /**
  68589. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68590. * that won t be acctive due to defines being turned off.
  68591. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68592. * @param samplersList The samplers list
  68593. * @param defines The defines helping in the list generation
  68594. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68595. */
  68596. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68597. /**
  68598. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68599. * @param defines The defines to update while falling back
  68600. * @param fallbacks The authorized effect fallbacks
  68601. * @param maxSimultaneousLights The maximum number of lights allowed
  68602. * @param rank the current rank of the Effect
  68603. * @returns The newly affected rank
  68604. */
  68605. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68606. /**
  68607. * Prepares the list of attributes required for morph targets according to the effect defines.
  68608. * @param attribs The current list of supported attribs
  68609. * @param mesh The mesh to prepare the morph targets attributes for
  68610. * @param defines The current Defines of the effect
  68611. */
  68612. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68613. /**
  68614. * Prepares the list of attributes required for bones according to the effect defines.
  68615. * @param attribs The current list of supported attribs
  68616. * @param mesh The mesh to prepare the bones attributes for
  68617. * @param defines The current Defines of the effect
  68618. * @param fallbacks The current efffect fallback strategy
  68619. */
  68620. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68621. /**
  68622. * Prepares the list of attributes required for instances according to the effect defines.
  68623. * @param attribs The current list of supported attribs
  68624. * @param defines The current Defines of the effect
  68625. */
  68626. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68627. /**
  68628. * Binds the light shadow information to the effect for the given mesh.
  68629. * @param light The light containing the generator
  68630. * @param scene The scene the lights belongs to
  68631. * @param mesh The mesh we are binding the information to render
  68632. * @param lightIndex The light index in the effect used to render the mesh
  68633. * @param effect The effect we are binding the data to
  68634. */
  68635. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68636. /**
  68637. * Binds the light information to the effect.
  68638. * @param light The light containing the generator
  68639. * @param effect The effect we are binding the data to
  68640. * @param lightIndex The light index in the effect used to render
  68641. */
  68642. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68643. /**
  68644. * Binds the lights information from the scene to the effect for the given mesh.
  68645. * @param scene The scene the lights belongs to
  68646. * @param mesh The mesh we are binding the information to render
  68647. * @param effect The effect we are binding the data to
  68648. * @param defines The generated defines for the effect
  68649. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68650. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68651. */
  68652. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68653. private static _tempFogColor;
  68654. /**
  68655. * Binds the fog information from the scene to the effect for the given mesh.
  68656. * @param scene The scene the lights belongs to
  68657. * @param mesh The mesh we are binding the information to render
  68658. * @param effect The effect we are binding the data to
  68659. * @param linearSpace Defines if the fog effect is applied in linear space
  68660. */
  68661. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68662. /**
  68663. * Binds the bones information from the mesh to the effect.
  68664. * @param mesh The mesh we are binding the information to render
  68665. * @param effect The effect we are binding the data to
  68666. */
  68667. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68668. /**
  68669. * Binds the morph targets information from the mesh to the effect.
  68670. * @param abstractMesh The mesh we are binding the information to render
  68671. * @param effect The effect we are binding the data to
  68672. */
  68673. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68674. /**
  68675. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68676. * @param defines The generated defines used in the effect
  68677. * @param effect The effect we are binding the data to
  68678. * @param scene The scene we are willing to render with logarithmic scale for
  68679. */
  68680. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68681. /**
  68682. * Binds the clip plane information from the scene to the effect.
  68683. * @param scene The scene the clip plane information are extracted from
  68684. * @param effect The effect we are binding the data to
  68685. */
  68686. static BindClipPlane(effect: Effect, scene: Scene): void;
  68687. }
  68688. }
  68689. declare module BABYLON {
  68690. /** @hidden */
  68691. export var kernelBlurVaryingDeclaration: {
  68692. name: string;
  68693. shader: string;
  68694. };
  68695. }
  68696. declare module BABYLON {
  68697. /** @hidden */
  68698. export var kernelBlurFragment: {
  68699. name: string;
  68700. shader: string;
  68701. };
  68702. }
  68703. declare module BABYLON {
  68704. /** @hidden */
  68705. export var kernelBlurFragment2: {
  68706. name: string;
  68707. shader: string;
  68708. };
  68709. }
  68710. declare module BABYLON {
  68711. /** @hidden */
  68712. export var kernelBlurPixelShader: {
  68713. name: string;
  68714. shader: string;
  68715. };
  68716. }
  68717. declare module BABYLON {
  68718. /** @hidden */
  68719. export var kernelBlurVertex: {
  68720. name: string;
  68721. shader: string;
  68722. };
  68723. }
  68724. declare module BABYLON {
  68725. /** @hidden */
  68726. export var kernelBlurVertexShader: {
  68727. name: string;
  68728. shader: string;
  68729. };
  68730. }
  68731. declare module BABYLON {
  68732. /**
  68733. * The Blur Post Process which blurs an image based on a kernel and direction.
  68734. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68735. */
  68736. export class BlurPostProcess extends PostProcess {
  68737. /** The direction in which to blur the image. */
  68738. direction: Vector2;
  68739. private blockCompilation;
  68740. protected _kernel: number;
  68741. protected _idealKernel: number;
  68742. protected _packedFloat: boolean;
  68743. private _staticDefines;
  68744. /**
  68745. * Sets the length in pixels of the blur sample region
  68746. */
  68747. /**
  68748. * Gets the length in pixels of the blur sample region
  68749. */
  68750. kernel: number;
  68751. /**
  68752. * Sets wether or not the blur needs to unpack/repack floats
  68753. */
  68754. /**
  68755. * Gets wether or not the blur is unpacking/repacking floats
  68756. */
  68757. packedFloat: boolean;
  68758. /**
  68759. * Creates a new instance BlurPostProcess
  68760. * @param name The name of the effect.
  68761. * @param direction The direction in which to blur the image.
  68762. * @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.
  68763. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68764. * @param camera The camera to apply the render pass to.
  68765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68766. * @param engine The engine which the post process will be applied. (default: current engine)
  68767. * @param reusable If the post process can be reused on the same frame. (default: false)
  68768. * @param textureType Type of textures used when performing the post process. (default: 0)
  68769. * @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)
  68770. */
  68771. constructor(name: string,
  68772. /** The direction in which to blur the image. */
  68773. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68774. /**
  68775. * Updates the effect with the current post process compile time values and recompiles the shader.
  68776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68779. * @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
  68780. * @param onCompiled Called when the shader has been compiled.
  68781. * @param onError Called if there is an error when compiling a shader.
  68782. */
  68783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68784. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68785. /**
  68786. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68787. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68788. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68789. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68790. * The gaps between physical kernels are compensated for in the weighting of the samples
  68791. * @param idealKernel Ideal blur kernel.
  68792. * @return Nearest best kernel.
  68793. */
  68794. protected _nearestBestKernel(idealKernel: number): number;
  68795. /**
  68796. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68797. * @param x The point on the Gaussian distribution to sample.
  68798. * @return the value of the Gaussian function at x.
  68799. */
  68800. protected _gaussianWeight(x: number): number;
  68801. /**
  68802. * Generates a string that can be used as a floating point number in GLSL.
  68803. * @param x Value to print.
  68804. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68805. * @return GLSL float string.
  68806. */
  68807. protected _glslFloat(x: number, decimalFigures?: number): string;
  68808. }
  68809. }
  68810. declare module BABYLON {
  68811. /** @hidden */
  68812. export var shadowMapPixelShader: {
  68813. name: string;
  68814. shader: string;
  68815. };
  68816. }
  68817. declare module BABYLON {
  68818. /** @hidden */
  68819. export var bonesDeclaration: {
  68820. name: string;
  68821. shader: string;
  68822. };
  68823. }
  68824. declare module BABYLON {
  68825. /** @hidden */
  68826. export var morphTargetsVertexGlobalDeclaration: {
  68827. name: string;
  68828. shader: string;
  68829. };
  68830. }
  68831. declare module BABYLON {
  68832. /** @hidden */
  68833. export var morphTargetsVertexDeclaration: {
  68834. name: string;
  68835. shader: string;
  68836. };
  68837. }
  68838. declare module BABYLON {
  68839. /** @hidden */
  68840. export var instancesDeclaration: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export var helperFunctions: {
  68848. name: string;
  68849. shader: string;
  68850. };
  68851. }
  68852. declare module BABYLON {
  68853. /** @hidden */
  68854. export var morphTargetsVertex: {
  68855. name: string;
  68856. shader: string;
  68857. };
  68858. }
  68859. declare module BABYLON {
  68860. /** @hidden */
  68861. export var instancesVertex: {
  68862. name: string;
  68863. shader: string;
  68864. };
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export var bonesVertex: {
  68869. name: string;
  68870. shader: string;
  68871. };
  68872. }
  68873. declare module BABYLON {
  68874. /** @hidden */
  68875. export var shadowMapVertexShader: {
  68876. name: string;
  68877. shader: string;
  68878. };
  68879. }
  68880. declare module BABYLON {
  68881. /** @hidden */
  68882. export var depthBoxBlurPixelShader: {
  68883. name: string;
  68884. shader: string;
  68885. };
  68886. }
  68887. declare module BABYLON {
  68888. /**
  68889. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68890. */
  68891. export interface ICustomShaderOptions {
  68892. /**
  68893. * Gets or sets the custom shader name to use
  68894. */
  68895. shaderName: string;
  68896. /**
  68897. * The list of attribute names used in the shader
  68898. */
  68899. attributes?: string[];
  68900. /**
  68901. * The list of unifrom names used in the shader
  68902. */
  68903. uniforms?: string[];
  68904. /**
  68905. * The list of sampler names used in the shader
  68906. */
  68907. samplers?: string[];
  68908. /**
  68909. * The list of defines used in the shader
  68910. */
  68911. defines?: string[];
  68912. }
  68913. /**
  68914. * Interface to implement to create a shadow generator compatible with BJS.
  68915. */
  68916. export interface IShadowGenerator {
  68917. /**
  68918. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68919. * @returns The render target texture if present otherwise, null
  68920. */
  68921. getShadowMap(): Nullable<RenderTargetTexture>;
  68922. /**
  68923. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68924. * @returns The render target texture if the shadow map is present otherwise, null
  68925. */
  68926. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68927. /**
  68928. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68929. * @param subMesh The submesh we want to render in the shadow map
  68930. * @param useInstances Defines wether will draw in the map using instances
  68931. * @returns true if ready otherwise, false
  68932. */
  68933. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68934. /**
  68935. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68936. * @param defines Defines of the material we want to update
  68937. * @param lightIndex Index of the light in the enabled light list of the material
  68938. */
  68939. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68940. /**
  68941. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68942. * defined in the generator but impacting the effect).
  68943. * It implies the unifroms available on the materials are the standard BJS ones.
  68944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68945. * @param effect The effect we are binfing the information for
  68946. */
  68947. bindShadowLight(lightIndex: string, effect: Effect): void;
  68948. /**
  68949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68950. * (eq to shadow prjection matrix * light transform matrix)
  68951. * @returns The transform matrix used to create the shadow map
  68952. */
  68953. getTransformMatrix(): Matrix;
  68954. /**
  68955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68956. * Cube and 2D textures for instance.
  68957. */
  68958. recreateShadowMap(): void;
  68959. /**
  68960. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68961. * @param onCompiled Callback triggered at the and of the effects compilation
  68962. * @param options Sets of optional options forcing the compilation with different modes
  68963. */
  68964. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68965. useInstances: boolean;
  68966. }>): void;
  68967. /**
  68968. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68969. * @param options Sets of optional options forcing the compilation with different modes
  68970. * @returns A promise that resolves when the compilation completes
  68971. */
  68972. forceCompilationAsync(options?: Partial<{
  68973. useInstances: boolean;
  68974. }>): Promise<void>;
  68975. /**
  68976. * Serializes the shadow generator setup to a json object.
  68977. * @returns The serialized JSON object
  68978. */
  68979. serialize(): any;
  68980. /**
  68981. * Disposes the Shadow map and related Textures and effects.
  68982. */
  68983. dispose(): void;
  68984. }
  68985. /**
  68986. * Default implementation IShadowGenerator.
  68987. * This is the main object responsible of generating shadows in the framework.
  68988. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68989. */
  68990. export class ShadowGenerator implements IShadowGenerator {
  68991. /**
  68992. * Shadow generator mode None: no filtering applied.
  68993. */
  68994. static readonly FILTER_NONE: number;
  68995. /**
  68996. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68997. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68998. */
  68999. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69000. /**
  69001. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69002. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69003. */
  69004. static readonly FILTER_POISSONSAMPLING: number;
  69005. /**
  69006. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69007. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69008. */
  69009. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69010. /**
  69011. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69012. * edge artifacts on steep falloff.
  69013. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69014. */
  69015. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69016. /**
  69017. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69018. * edge artifacts on steep falloff.
  69019. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69020. */
  69021. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69022. /**
  69023. * Shadow generator mode PCF: Percentage Closer Filtering
  69024. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69025. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69026. */
  69027. static readonly FILTER_PCF: number;
  69028. /**
  69029. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69030. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69031. * Contact Hardening
  69032. */
  69033. static readonly FILTER_PCSS: number;
  69034. /**
  69035. * Reserved for PCF and PCSS
  69036. * Highest Quality.
  69037. *
  69038. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69039. *
  69040. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69041. */
  69042. static readonly QUALITY_HIGH: number;
  69043. /**
  69044. * Reserved for PCF and PCSS
  69045. * Good tradeoff for quality/perf cross devices
  69046. *
  69047. * Execute PCF on a 3*3 kernel.
  69048. *
  69049. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69050. */
  69051. static readonly QUALITY_MEDIUM: number;
  69052. /**
  69053. * Reserved for PCF and PCSS
  69054. * The lowest quality but the fastest.
  69055. *
  69056. * Execute PCF on a 1*1 kernel.
  69057. *
  69058. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69059. */
  69060. static readonly QUALITY_LOW: number;
  69061. /** Gets or sets the custom shader name to use */
  69062. customShaderOptions: ICustomShaderOptions;
  69063. /**
  69064. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69065. */
  69066. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69067. /**
  69068. * Observable triggered before a mesh is rendered in the shadow map.
  69069. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69070. */
  69071. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69072. private _bias;
  69073. /**
  69074. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69075. */
  69076. /**
  69077. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69078. */
  69079. bias: number;
  69080. private _normalBias;
  69081. /**
  69082. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69083. */
  69084. /**
  69085. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69086. */
  69087. normalBias: number;
  69088. private _blurBoxOffset;
  69089. /**
  69090. * Gets the blur box offset: offset applied during the blur pass.
  69091. * Only useful if useKernelBlur = false
  69092. */
  69093. /**
  69094. * Sets the blur box offset: offset applied during the blur pass.
  69095. * Only useful if useKernelBlur = false
  69096. */
  69097. blurBoxOffset: number;
  69098. private _blurScale;
  69099. /**
  69100. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69101. * 2 means half of the size.
  69102. */
  69103. /**
  69104. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69105. * 2 means half of the size.
  69106. */
  69107. blurScale: number;
  69108. private _blurKernel;
  69109. /**
  69110. * Gets the blur kernel: kernel size of the blur pass.
  69111. * Only useful if useKernelBlur = true
  69112. */
  69113. /**
  69114. * Sets the blur kernel: kernel size of the blur pass.
  69115. * Only useful if useKernelBlur = true
  69116. */
  69117. blurKernel: number;
  69118. private _useKernelBlur;
  69119. /**
  69120. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69121. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69122. */
  69123. /**
  69124. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69125. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69126. */
  69127. useKernelBlur: boolean;
  69128. private _depthScale;
  69129. /**
  69130. * Gets the depth scale used in ESM mode.
  69131. */
  69132. /**
  69133. * Sets the depth scale used in ESM mode.
  69134. * This can override the scale stored on the light.
  69135. */
  69136. depthScale: number;
  69137. private _filter;
  69138. /**
  69139. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69140. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69141. */
  69142. /**
  69143. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69144. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69145. */
  69146. filter: number;
  69147. /**
  69148. * Gets if the current filter is set to Poisson Sampling.
  69149. */
  69150. /**
  69151. * Sets the current filter to Poisson Sampling.
  69152. */
  69153. usePoissonSampling: boolean;
  69154. /**
  69155. * Gets if the current filter is set to ESM.
  69156. */
  69157. /**
  69158. * Sets the current filter is to ESM.
  69159. */
  69160. useExponentialShadowMap: boolean;
  69161. /**
  69162. * Gets if the current filter is set to filtered ESM.
  69163. */
  69164. /**
  69165. * Gets if the current filter is set to filtered ESM.
  69166. */
  69167. useBlurExponentialShadowMap: boolean;
  69168. /**
  69169. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69170. * exponential to prevent steep falloff artifacts).
  69171. */
  69172. /**
  69173. * Sets the current filter to "close ESM" (using the inverse of the
  69174. * exponential to prevent steep falloff artifacts).
  69175. */
  69176. useCloseExponentialShadowMap: boolean;
  69177. /**
  69178. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69179. * exponential to prevent steep falloff artifacts).
  69180. */
  69181. /**
  69182. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69183. * exponential to prevent steep falloff artifacts).
  69184. */
  69185. useBlurCloseExponentialShadowMap: boolean;
  69186. /**
  69187. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69188. */
  69189. /**
  69190. * Sets the current filter to "PCF" (percentage closer filtering).
  69191. */
  69192. usePercentageCloserFiltering: boolean;
  69193. private _filteringQuality;
  69194. /**
  69195. * Gets the PCF or PCSS Quality.
  69196. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69197. */
  69198. /**
  69199. * Sets the PCF or PCSS Quality.
  69200. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69201. */
  69202. filteringQuality: number;
  69203. /**
  69204. * Gets if the current filter is set to "PCSS" (contact hardening).
  69205. */
  69206. /**
  69207. * Sets the current filter to "PCSS" (contact hardening).
  69208. */
  69209. useContactHardeningShadow: boolean;
  69210. private _contactHardeningLightSizeUVRatio;
  69211. /**
  69212. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69213. * Using a ratio helps keeping shape stability independently of the map size.
  69214. *
  69215. * It does not account for the light projection as it was having too much
  69216. * instability during the light setup or during light position changes.
  69217. *
  69218. * Only valid if useContactHardeningShadow is true.
  69219. */
  69220. /**
  69221. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69222. * Using a ratio helps keeping shape stability independently of the map size.
  69223. *
  69224. * It does not account for the light projection as it was having too much
  69225. * instability during the light setup or during light position changes.
  69226. *
  69227. * Only valid if useContactHardeningShadow is true.
  69228. */
  69229. contactHardeningLightSizeUVRatio: number;
  69230. private _darkness;
  69231. /**
  69232. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69233. * 0 means strongest and 1 would means no shadow.
  69234. * @returns the darkness.
  69235. */
  69236. getDarkness(): number;
  69237. /**
  69238. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69239. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69240. * @returns the shadow generator allowing fluent coding.
  69241. */
  69242. setDarkness(darkness: number): ShadowGenerator;
  69243. private _transparencyShadow;
  69244. /**
  69245. * Sets the ability to have transparent shadow (boolean).
  69246. * @param transparent True if transparent else False
  69247. * @returns the shadow generator allowing fluent coding
  69248. */
  69249. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69250. private _shadowMap;
  69251. private _shadowMap2;
  69252. /**
  69253. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69254. * @returns The render target texture if present otherwise, null
  69255. */
  69256. getShadowMap(): Nullable<RenderTargetTexture>;
  69257. /**
  69258. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69259. * @returns The render target texture if the shadow map is present otherwise, null
  69260. */
  69261. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69262. /**
  69263. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69264. * @param mesh Mesh to add
  69265. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69266. * @returns the Shadow Generator itself
  69267. */
  69268. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69269. /**
  69270. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69271. * @param mesh Mesh to remove
  69272. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69273. * @returns the Shadow Generator itself
  69274. */
  69275. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69276. /**
  69277. * Controls the extent to which the shadows fade out at the edge of the frustum
  69278. * Used only by directionals and spots
  69279. */
  69280. frustumEdgeFalloff: number;
  69281. private _light;
  69282. /**
  69283. * Returns the associated light object.
  69284. * @returns the light generating the shadow
  69285. */
  69286. getLight(): IShadowLight;
  69287. /**
  69288. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69289. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69290. * It might on the other hand introduce peter panning.
  69291. */
  69292. forceBackFacesOnly: boolean;
  69293. private _scene;
  69294. private _lightDirection;
  69295. private _effect;
  69296. private _viewMatrix;
  69297. private _projectionMatrix;
  69298. private _transformMatrix;
  69299. private _cachedPosition;
  69300. private _cachedDirection;
  69301. private _cachedDefines;
  69302. private _currentRenderID;
  69303. private _boxBlurPostprocess;
  69304. private _kernelBlurXPostprocess;
  69305. private _kernelBlurYPostprocess;
  69306. private _blurPostProcesses;
  69307. private _mapSize;
  69308. private _currentFaceIndex;
  69309. private _currentFaceIndexCache;
  69310. private _textureType;
  69311. private _defaultTextureMatrix;
  69312. /** @hidden */
  69313. static _SceneComponentInitialization: (scene: Scene) => void;
  69314. /**
  69315. * Creates a ShadowGenerator object.
  69316. * A ShadowGenerator is the required tool to use the shadows.
  69317. * Each light casting shadows needs to use its own ShadowGenerator.
  69318. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69319. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69320. * @param light The light object generating the shadows.
  69321. * @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.
  69322. */
  69323. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69324. private _initializeGenerator;
  69325. private _initializeShadowMap;
  69326. private _initializeBlurRTTAndPostProcesses;
  69327. private _renderForShadowMap;
  69328. private _renderSubMeshForShadowMap;
  69329. private _applyFilterValues;
  69330. /**
  69331. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69332. * @param onCompiled Callback triggered at the and of the effects compilation
  69333. * @param options Sets of optional options forcing the compilation with different modes
  69334. */
  69335. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69336. useInstances: boolean;
  69337. }>): void;
  69338. /**
  69339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69340. * @param options Sets of optional options forcing the compilation with different modes
  69341. * @returns A promise that resolves when the compilation completes
  69342. */
  69343. forceCompilationAsync(options?: Partial<{
  69344. useInstances: boolean;
  69345. }>): Promise<void>;
  69346. /**
  69347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69348. * @param subMesh The submesh we want to render in the shadow map
  69349. * @param useInstances Defines wether will draw in the map using instances
  69350. * @returns true if ready otherwise, false
  69351. */
  69352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69353. /**
  69354. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69355. * @param defines Defines of the material we want to update
  69356. * @param lightIndex Index of the light in the enabled light list of the material
  69357. */
  69358. prepareDefines(defines: any, lightIndex: number): void;
  69359. /**
  69360. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69361. * defined in the generator but impacting the effect).
  69362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69363. * @param effect The effect we are binfing the information for
  69364. */
  69365. bindShadowLight(lightIndex: string, effect: Effect): void;
  69366. /**
  69367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69368. * (eq to shadow prjection matrix * light transform matrix)
  69369. * @returns The transform matrix used to create the shadow map
  69370. */
  69371. getTransformMatrix(): Matrix;
  69372. /**
  69373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69374. * Cube and 2D textures for instance.
  69375. */
  69376. recreateShadowMap(): void;
  69377. private _disposeBlurPostProcesses;
  69378. private _disposeRTTandPostProcesses;
  69379. /**
  69380. * Disposes the ShadowGenerator.
  69381. * Returns nothing.
  69382. */
  69383. dispose(): void;
  69384. /**
  69385. * Serializes the shadow generator setup to a json object.
  69386. * @returns The serialized JSON object
  69387. */
  69388. serialize(): any;
  69389. /**
  69390. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69391. * @param parsedShadowGenerator The JSON object to parse
  69392. * @param scene The scene to create the shadow map for
  69393. * @returns The parsed shadow generator
  69394. */
  69395. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69401. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69402. * 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.
  69403. */
  69404. export abstract class Light extends Node {
  69405. /**
  69406. * Falloff Default: light is falling off following the material specification:
  69407. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69408. */
  69409. static readonly FALLOFF_DEFAULT: number;
  69410. /**
  69411. * Falloff Physical: light is falling off following the inverse squared distance law.
  69412. */
  69413. static readonly FALLOFF_PHYSICAL: number;
  69414. /**
  69415. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69416. * to enhance interoperability with other engines.
  69417. */
  69418. static readonly FALLOFF_GLTF: number;
  69419. /**
  69420. * Falloff Standard: light is falling off like in the standard material
  69421. * to enhance interoperability with other materials.
  69422. */
  69423. static readonly FALLOFF_STANDARD: number;
  69424. /**
  69425. * If every light affecting the material is in this lightmapMode,
  69426. * material.lightmapTexture adds or multiplies
  69427. * (depends on material.useLightmapAsShadowmap)
  69428. * after every other light calculations.
  69429. */
  69430. static readonly LIGHTMAP_DEFAULT: number;
  69431. /**
  69432. * material.lightmapTexture as only diffuse lighting from this light
  69433. * adds only specular lighting from this light
  69434. * adds dynamic shadows
  69435. */
  69436. static readonly LIGHTMAP_SPECULAR: number;
  69437. /**
  69438. * material.lightmapTexture as only lighting
  69439. * no light calculation from this light
  69440. * only adds dynamic shadows from this light
  69441. */
  69442. static readonly LIGHTMAP_SHADOWSONLY: number;
  69443. /**
  69444. * Each light type uses the default quantity according to its type:
  69445. * point/spot lights use luminous intensity
  69446. * directional lights use illuminance
  69447. */
  69448. static readonly INTENSITYMODE_AUTOMATIC: number;
  69449. /**
  69450. * lumen (lm)
  69451. */
  69452. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69453. /**
  69454. * candela (lm/sr)
  69455. */
  69456. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69457. /**
  69458. * lux (lm/m^2)
  69459. */
  69460. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69461. /**
  69462. * nit (cd/m^2)
  69463. */
  69464. static readonly INTENSITYMODE_LUMINANCE: number;
  69465. /**
  69466. * Light type const id of the point light.
  69467. */
  69468. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69469. /**
  69470. * Light type const id of the directional light.
  69471. */
  69472. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69473. /**
  69474. * Light type const id of the spot light.
  69475. */
  69476. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69477. /**
  69478. * Light type const id of the hemispheric light.
  69479. */
  69480. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69481. /**
  69482. * Diffuse gives the basic color to an object.
  69483. */
  69484. diffuse: Color3;
  69485. /**
  69486. * Specular produces a highlight color on an object.
  69487. * Note: This is note affecting PBR materials.
  69488. */
  69489. specular: Color3;
  69490. /**
  69491. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69492. * falling off base on range or angle.
  69493. * This can be set to any values in Light.FALLOFF_x.
  69494. *
  69495. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69496. * other types of materials.
  69497. */
  69498. falloffType: number;
  69499. /**
  69500. * Strength of the light.
  69501. * Note: By default it is define in the framework own unit.
  69502. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69503. */
  69504. intensity: number;
  69505. private _range;
  69506. protected _inverseSquaredRange: number;
  69507. /**
  69508. * Defines how far from the source the light is impacting in scene units.
  69509. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69510. */
  69511. /**
  69512. * Defines how far from the source the light is impacting in scene units.
  69513. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69514. */
  69515. range: number;
  69516. /**
  69517. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69518. * of light.
  69519. */
  69520. private _photometricScale;
  69521. private _intensityMode;
  69522. /**
  69523. * Gets the photometric scale used to interpret the intensity.
  69524. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69525. */
  69526. /**
  69527. * Sets the photometric scale used to interpret the intensity.
  69528. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69529. */
  69530. intensityMode: number;
  69531. private _radius;
  69532. /**
  69533. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69534. */
  69535. /**
  69536. * sets the light radius used by PBR Materials to simulate soft area lights.
  69537. */
  69538. radius: number;
  69539. private _renderPriority;
  69540. /**
  69541. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69542. * exceeding the number allowed of the materials.
  69543. */
  69544. renderPriority: number;
  69545. private _shadowEnabled;
  69546. /**
  69547. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69548. * the current shadow generator.
  69549. */
  69550. /**
  69551. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69552. * the current shadow generator.
  69553. */
  69554. shadowEnabled: boolean;
  69555. private _includedOnlyMeshes;
  69556. /**
  69557. * Gets the only meshes impacted by this light.
  69558. */
  69559. /**
  69560. * Sets the only meshes impacted by this light.
  69561. */
  69562. includedOnlyMeshes: AbstractMesh[];
  69563. private _excludedMeshes;
  69564. /**
  69565. * Gets the meshes not impacted by this light.
  69566. */
  69567. /**
  69568. * Sets the meshes not impacted by this light.
  69569. */
  69570. excludedMeshes: AbstractMesh[];
  69571. private _excludeWithLayerMask;
  69572. /**
  69573. * Gets the layer id use to find what meshes are not impacted by the light.
  69574. * Inactive if 0
  69575. */
  69576. /**
  69577. * Sets the layer id use to find what meshes are not impacted by the light.
  69578. * Inactive if 0
  69579. */
  69580. excludeWithLayerMask: number;
  69581. private _includeOnlyWithLayerMask;
  69582. /**
  69583. * Gets the layer id use to find what meshes are impacted by the light.
  69584. * Inactive if 0
  69585. */
  69586. /**
  69587. * Sets the layer id use to find what meshes are impacted by the light.
  69588. * Inactive if 0
  69589. */
  69590. includeOnlyWithLayerMask: number;
  69591. private _lightmapMode;
  69592. /**
  69593. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69594. */
  69595. /**
  69596. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69597. */
  69598. lightmapMode: number;
  69599. /**
  69600. * Shadow generator associted to the light.
  69601. * @hidden Internal use only.
  69602. */
  69603. _shadowGenerator: Nullable<IShadowGenerator>;
  69604. /**
  69605. * @hidden Internal use only.
  69606. */
  69607. _excludedMeshesIds: string[];
  69608. /**
  69609. * @hidden Internal use only.
  69610. */
  69611. _includedOnlyMeshesIds: string[];
  69612. /**
  69613. * The current light unifom buffer.
  69614. * @hidden Internal use only.
  69615. */
  69616. _uniformBuffer: UniformBuffer;
  69617. /**
  69618. * Creates a Light object in the scene.
  69619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69620. * @param name The firendly name of the light
  69621. * @param scene The scene the light belongs too
  69622. */
  69623. constructor(name: string, scene: Scene);
  69624. protected abstract _buildUniformLayout(): void;
  69625. /**
  69626. * Sets the passed Effect "effect" with the Light information.
  69627. * @param effect The effect to update
  69628. * @param lightIndex The index of the light in the effect to update
  69629. * @returns The light
  69630. */
  69631. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69632. /**
  69633. * Returns the string "Light".
  69634. * @returns the class name
  69635. */
  69636. getClassName(): string;
  69637. /** @hidden */
  69638. readonly _isLight: boolean;
  69639. /**
  69640. * Converts the light information to a readable string for debug purpose.
  69641. * @param fullDetails Supports for multiple levels of logging within scene loading
  69642. * @returns the human readable light info
  69643. */
  69644. toString(fullDetails?: boolean): string;
  69645. /** @hidden */
  69646. protected _syncParentEnabledState(): void;
  69647. /**
  69648. * Set the enabled state of this node.
  69649. * @param value - the new enabled state
  69650. */
  69651. setEnabled(value: boolean): void;
  69652. /**
  69653. * Returns the Light associated shadow generator if any.
  69654. * @return the associated shadow generator.
  69655. */
  69656. getShadowGenerator(): Nullable<IShadowGenerator>;
  69657. /**
  69658. * Returns a Vector3, the absolute light position in the World.
  69659. * @returns the world space position of the light
  69660. */
  69661. getAbsolutePosition(): Vector3;
  69662. /**
  69663. * Specifies if the light will affect the passed mesh.
  69664. * @param mesh The mesh to test against the light
  69665. * @return true the mesh is affected otherwise, false.
  69666. */
  69667. canAffectMesh(mesh: AbstractMesh): boolean;
  69668. /**
  69669. * Sort function to order lights for rendering.
  69670. * @param a First Light object to compare to second.
  69671. * @param b Second Light object to compare first.
  69672. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69673. */
  69674. static CompareLightsPriority(a: Light, b: Light): number;
  69675. /**
  69676. * Releases resources associated with this node.
  69677. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69678. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69679. */
  69680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69681. /**
  69682. * Returns the light type ID (integer).
  69683. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69684. */
  69685. getTypeID(): number;
  69686. /**
  69687. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69688. * @returns the scaled intensity in intensity mode unit
  69689. */
  69690. getScaledIntensity(): number;
  69691. /**
  69692. * Returns a new Light object, named "name", from the current one.
  69693. * @param name The name of the cloned light
  69694. * @returns the new created light
  69695. */
  69696. clone(name: string): Nullable<Light>;
  69697. /**
  69698. * Serializes the current light into a Serialization object.
  69699. * @returns the serialized object.
  69700. */
  69701. serialize(): any;
  69702. /**
  69703. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69704. * This new light is named "name" and added to the passed scene.
  69705. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69706. * @param name The friendly name of the light
  69707. * @param scene The scene the new light will belong to
  69708. * @returns the constructor function
  69709. */
  69710. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69711. /**
  69712. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69713. * @param parsedLight The JSON representation of the light
  69714. * @param scene The scene to create the parsed light in
  69715. * @returns the created light after parsing
  69716. */
  69717. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69718. private _hookArrayForExcluded;
  69719. private _hookArrayForIncludedOnly;
  69720. private _resyncMeshes;
  69721. /**
  69722. * Forces the meshes to update their light related information in their rendering used effects
  69723. * @hidden Internal Use Only
  69724. */
  69725. _markMeshesAsLightDirty(): void;
  69726. /**
  69727. * Recomputes the cached photometric scale if needed.
  69728. */
  69729. private _computePhotometricScale;
  69730. /**
  69731. * Returns the Photometric Scale according to the light type and intensity mode.
  69732. */
  69733. private _getPhotometricScale;
  69734. /**
  69735. * Reorder the light in the scene according to their defined priority.
  69736. * @hidden Internal Use Only
  69737. */
  69738. _reorderLightsInScene(): void;
  69739. /**
  69740. * Prepares the list of defines specific to the light type.
  69741. * @param defines the list of defines
  69742. * @param lightIndex defines the index of the light for the effect
  69743. */
  69744. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69745. }
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Interface used to define Action
  69750. */
  69751. export interface IAction {
  69752. /**
  69753. * Trigger for the action
  69754. */
  69755. trigger: number;
  69756. /** Options of the trigger */
  69757. triggerOptions: any;
  69758. /**
  69759. * Gets the trigger parameters
  69760. * @returns the trigger parameters
  69761. */
  69762. getTriggerParameter(): any;
  69763. /**
  69764. * Internal only - executes current action event
  69765. * @hidden
  69766. */
  69767. _executeCurrent(evt?: ActionEvent): void;
  69768. /**
  69769. * Serialize placeholder for child classes
  69770. * @param parent of child
  69771. * @returns the serialized object
  69772. */
  69773. serialize(parent: any): any;
  69774. /**
  69775. * Internal only
  69776. * @hidden
  69777. */
  69778. _prepare(): void;
  69779. /**
  69780. * Internal only - manager for action
  69781. * @hidden
  69782. */
  69783. _actionManager: AbstractActionManager;
  69784. }
  69785. /**
  69786. * The action to be carried out following a trigger
  69787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69788. */
  69789. export class Action implements IAction {
  69790. /** the trigger, with or without parameters, for the action */
  69791. triggerOptions: any;
  69792. /**
  69793. * Trigger for the action
  69794. */
  69795. trigger: number;
  69796. /**
  69797. * Internal only - manager for action
  69798. * @hidden
  69799. */
  69800. _actionManager: ActionManager;
  69801. private _nextActiveAction;
  69802. private _child;
  69803. private _condition?;
  69804. private _triggerParameter;
  69805. /**
  69806. * An event triggered prior to action being executed.
  69807. */
  69808. onBeforeExecuteObservable: Observable<Action>;
  69809. /**
  69810. * Creates a new Action
  69811. * @param triggerOptions the trigger, with or without parameters, for the action
  69812. * @param condition an optional determinant of action
  69813. */
  69814. constructor(
  69815. /** the trigger, with or without parameters, for the action */
  69816. triggerOptions: any, condition?: Condition);
  69817. /**
  69818. * Internal only
  69819. * @hidden
  69820. */
  69821. _prepare(): void;
  69822. /**
  69823. * Gets the trigger parameters
  69824. * @returns the trigger parameters
  69825. */
  69826. getTriggerParameter(): any;
  69827. /**
  69828. * Internal only - executes current action event
  69829. * @hidden
  69830. */
  69831. _executeCurrent(evt?: ActionEvent): void;
  69832. /**
  69833. * Execute placeholder for child classes
  69834. * @param evt optional action event
  69835. */
  69836. execute(evt?: ActionEvent): void;
  69837. /**
  69838. * Skips to next active action
  69839. */
  69840. skipToNextActiveAction(): void;
  69841. /**
  69842. * Adds action to chain of actions, may be a DoNothingAction
  69843. * @param action defines the next action to execute
  69844. * @returns The action passed in
  69845. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69846. */
  69847. then(action: Action): Action;
  69848. /**
  69849. * Internal only
  69850. * @hidden
  69851. */
  69852. _getProperty(propertyPath: string): string;
  69853. /**
  69854. * Internal only
  69855. * @hidden
  69856. */
  69857. _getEffectiveTarget(target: any, propertyPath: string): any;
  69858. /**
  69859. * Serialize placeholder for child classes
  69860. * @param parent of child
  69861. * @returns the serialized object
  69862. */
  69863. serialize(parent: any): any;
  69864. /**
  69865. * Internal only called by serialize
  69866. * @hidden
  69867. */
  69868. protected _serialize(serializedAction: any, parent?: any): any;
  69869. /**
  69870. * Internal only
  69871. * @hidden
  69872. */
  69873. static _SerializeValueAsString: (value: any) => string;
  69874. /**
  69875. * Internal only
  69876. * @hidden
  69877. */
  69878. static _GetTargetProperty: (target: Scene | Node) => {
  69879. name: string;
  69880. targetType: string;
  69881. value: string;
  69882. };
  69883. }
  69884. }
  69885. declare module BABYLON {
  69886. /**
  69887. * A Condition applied to an Action
  69888. */
  69889. export class Condition {
  69890. /**
  69891. * Internal only - manager for action
  69892. * @hidden
  69893. */
  69894. _actionManager: ActionManager;
  69895. /**
  69896. * Internal only
  69897. * @hidden
  69898. */
  69899. _evaluationId: number;
  69900. /**
  69901. * Internal only
  69902. * @hidden
  69903. */
  69904. _currentResult: boolean;
  69905. /**
  69906. * Creates a new Condition
  69907. * @param actionManager the manager of the action the condition is applied to
  69908. */
  69909. constructor(actionManager: ActionManager);
  69910. /**
  69911. * Check if the current condition is valid
  69912. * @returns a boolean
  69913. */
  69914. isValid(): boolean;
  69915. /**
  69916. * Internal only
  69917. * @hidden
  69918. */
  69919. _getProperty(propertyPath: string): string;
  69920. /**
  69921. * Internal only
  69922. * @hidden
  69923. */
  69924. _getEffectiveTarget(target: any, propertyPath: string): any;
  69925. /**
  69926. * Serialize placeholder for child classes
  69927. * @returns the serialized object
  69928. */
  69929. serialize(): any;
  69930. /**
  69931. * Internal only
  69932. * @hidden
  69933. */
  69934. protected _serialize(serializedCondition: any): any;
  69935. }
  69936. /**
  69937. * Defines specific conditional operators as extensions of Condition
  69938. */
  69939. export class ValueCondition extends Condition {
  69940. /** path to specify the property of the target the conditional operator uses */
  69941. propertyPath: string;
  69942. /** the value compared by the conditional operator against the current value of the property */
  69943. value: any;
  69944. /** the conditional operator, default ValueCondition.IsEqual */
  69945. operator: number;
  69946. /**
  69947. * Internal only
  69948. * @hidden
  69949. */
  69950. private static _IsEqual;
  69951. /**
  69952. * Internal only
  69953. * @hidden
  69954. */
  69955. private static _IsDifferent;
  69956. /**
  69957. * Internal only
  69958. * @hidden
  69959. */
  69960. private static _IsGreater;
  69961. /**
  69962. * Internal only
  69963. * @hidden
  69964. */
  69965. private static _IsLesser;
  69966. /**
  69967. * returns the number for IsEqual
  69968. */
  69969. static readonly IsEqual: number;
  69970. /**
  69971. * Returns the number for IsDifferent
  69972. */
  69973. static readonly IsDifferent: number;
  69974. /**
  69975. * Returns the number for IsGreater
  69976. */
  69977. static readonly IsGreater: number;
  69978. /**
  69979. * Returns the number for IsLesser
  69980. */
  69981. static readonly IsLesser: number;
  69982. /**
  69983. * Internal only The action manager for the condition
  69984. * @hidden
  69985. */
  69986. _actionManager: ActionManager;
  69987. /**
  69988. * Internal only
  69989. * @hidden
  69990. */
  69991. private _target;
  69992. /**
  69993. * Internal only
  69994. * @hidden
  69995. */
  69996. private _effectiveTarget;
  69997. /**
  69998. * Internal only
  69999. * @hidden
  70000. */
  70001. private _property;
  70002. /**
  70003. * Creates a new ValueCondition
  70004. * @param actionManager manager for the action the condition applies to
  70005. * @param target for the action
  70006. * @param propertyPath path to specify the property of the target the conditional operator uses
  70007. * @param value the value compared by the conditional operator against the current value of the property
  70008. * @param operator the conditional operator, default ValueCondition.IsEqual
  70009. */
  70010. constructor(actionManager: ActionManager, target: any,
  70011. /** path to specify the property of the target the conditional operator uses */
  70012. propertyPath: string,
  70013. /** the value compared by the conditional operator against the current value of the property */
  70014. value: any,
  70015. /** the conditional operator, default ValueCondition.IsEqual */
  70016. operator?: number);
  70017. /**
  70018. * Compares the given value with the property value for the specified conditional operator
  70019. * @returns the result of the comparison
  70020. */
  70021. isValid(): boolean;
  70022. /**
  70023. * Serialize the ValueCondition into a JSON compatible object
  70024. * @returns serialization object
  70025. */
  70026. serialize(): any;
  70027. /**
  70028. * Gets the name of the conditional operator for the ValueCondition
  70029. * @param operator the conditional operator
  70030. * @returns the name
  70031. */
  70032. static GetOperatorName(operator: number): string;
  70033. }
  70034. /**
  70035. * Defines a predicate condition as an extension of Condition
  70036. */
  70037. export class PredicateCondition extends Condition {
  70038. /** defines the predicate function used to validate the condition */
  70039. predicate: () => boolean;
  70040. /**
  70041. * Internal only - manager for action
  70042. * @hidden
  70043. */
  70044. _actionManager: ActionManager;
  70045. /**
  70046. * Creates a new PredicateCondition
  70047. * @param actionManager manager for the action the condition applies to
  70048. * @param predicate defines the predicate function used to validate the condition
  70049. */
  70050. constructor(actionManager: ActionManager,
  70051. /** defines the predicate function used to validate the condition */
  70052. predicate: () => boolean);
  70053. /**
  70054. * @returns the validity of the predicate condition
  70055. */
  70056. isValid(): boolean;
  70057. }
  70058. /**
  70059. * Defines a state condition as an extension of Condition
  70060. */
  70061. export class StateCondition extends Condition {
  70062. /** Value to compare with target state */
  70063. value: string;
  70064. /**
  70065. * Internal only - manager for action
  70066. * @hidden
  70067. */
  70068. _actionManager: ActionManager;
  70069. /**
  70070. * Internal only
  70071. * @hidden
  70072. */
  70073. private _target;
  70074. /**
  70075. * Creates a new StateCondition
  70076. * @param actionManager manager for the action the condition applies to
  70077. * @param target of the condition
  70078. * @param value to compare with target state
  70079. */
  70080. constructor(actionManager: ActionManager, target: any,
  70081. /** Value to compare with target state */
  70082. value: string);
  70083. /**
  70084. * Gets a boolean indicating if the current condition is met
  70085. * @returns the validity of the state
  70086. */
  70087. isValid(): boolean;
  70088. /**
  70089. * Serialize the StateCondition into a JSON compatible object
  70090. * @returns serialization object
  70091. */
  70092. serialize(): any;
  70093. }
  70094. }
  70095. declare module BABYLON {
  70096. /**
  70097. * This defines an action responsible to toggle a boolean once triggered.
  70098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70099. */
  70100. export class SwitchBooleanAction extends Action {
  70101. /**
  70102. * The path to the boolean property in the target object
  70103. */
  70104. propertyPath: string;
  70105. private _target;
  70106. private _effectiveTarget;
  70107. private _property;
  70108. /**
  70109. * Instantiate the action
  70110. * @param triggerOptions defines the trigger options
  70111. * @param target defines the object containing the boolean
  70112. * @param propertyPath defines the path to the boolean property in the target object
  70113. * @param condition defines the trigger related conditions
  70114. */
  70115. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70116. /** @hidden */
  70117. _prepare(): void;
  70118. /**
  70119. * Execute the action toggle the boolean value.
  70120. */
  70121. execute(): void;
  70122. /**
  70123. * Serializes the actions and its related information.
  70124. * @param parent defines the object to serialize in
  70125. * @returns the serialized object
  70126. */
  70127. serialize(parent: any): any;
  70128. }
  70129. /**
  70130. * This defines an action responsible to set a the state field of the target
  70131. * to a desired value once triggered.
  70132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70133. */
  70134. export class SetStateAction extends Action {
  70135. /**
  70136. * The value to store in the state field.
  70137. */
  70138. value: string;
  70139. private _target;
  70140. /**
  70141. * Instantiate the action
  70142. * @param triggerOptions defines the trigger options
  70143. * @param target defines the object containing the state property
  70144. * @param value defines the value to store in the state field
  70145. * @param condition defines the trigger related conditions
  70146. */
  70147. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70148. /**
  70149. * Execute the action and store the value on the target state property.
  70150. */
  70151. execute(): void;
  70152. /**
  70153. * Serializes the actions and its related information.
  70154. * @param parent defines the object to serialize in
  70155. * @returns the serialized object
  70156. */
  70157. serialize(parent: any): any;
  70158. }
  70159. /**
  70160. * This defines an action responsible to set a property of the target
  70161. * to a desired value once triggered.
  70162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70163. */
  70164. export class SetValueAction extends Action {
  70165. /**
  70166. * The path of the property to set in the target.
  70167. */
  70168. propertyPath: string;
  70169. /**
  70170. * The value to set in the property
  70171. */
  70172. value: any;
  70173. private _target;
  70174. private _effectiveTarget;
  70175. private _property;
  70176. /**
  70177. * Instantiate the action
  70178. * @param triggerOptions defines the trigger options
  70179. * @param target defines the object containing the property
  70180. * @param propertyPath defines the path of the property to set in the target
  70181. * @param value defines the value to set in the property
  70182. * @param condition defines the trigger related conditions
  70183. */
  70184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70185. /** @hidden */
  70186. _prepare(): void;
  70187. /**
  70188. * Execute the action and set the targetted property to the desired value.
  70189. */
  70190. execute(): void;
  70191. /**
  70192. * Serializes the actions and its related information.
  70193. * @param parent defines the object to serialize in
  70194. * @returns the serialized object
  70195. */
  70196. serialize(parent: any): any;
  70197. }
  70198. /**
  70199. * This defines an action responsible to increment the target value
  70200. * to a desired value once triggered.
  70201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70202. */
  70203. export class IncrementValueAction extends Action {
  70204. /**
  70205. * The path of the property to increment in the target.
  70206. */
  70207. propertyPath: string;
  70208. /**
  70209. * The value we should increment the property by.
  70210. */
  70211. value: any;
  70212. private _target;
  70213. private _effectiveTarget;
  70214. private _property;
  70215. /**
  70216. * Instantiate the action
  70217. * @param triggerOptions defines the trigger options
  70218. * @param target defines the object containing the property
  70219. * @param propertyPath defines the path of the property to increment in the target
  70220. * @param value defines the value value we should increment the property by
  70221. * @param condition defines the trigger related conditions
  70222. */
  70223. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70224. /** @hidden */
  70225. _prepare(): void;
  70226. /**
  70227. * Execute the action and increment the target of the value amount.
  70228. */
  70229. execute(): void;
  70230. /**
  70231. * Serializes the actions and its related information.
  70232. * @param parent defines the object to serialize in
  70233. * @returns the serialized object
  70234. */
  70235. serialize(parent: any): any;
  70236. }
  70237. /**
  70238. * This defines an action responsible to start an animation once triggered.
  70239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70240. */
  70241. export class PlayAnimationAction extends Action {
  70242. /**
  70243. * Where the animation should start (animation frame)
  70244. */
  70245. from: number;
  70246. /**
  70247. * Where the animation should stop (animation frame)
  70248. */
  70249. to: number;
  70250. /**
  70251. * Define if the animation should loop or stop after the first play.
  70252. */
  70253. loop?: boolean;
  70254. private _target;
  70255. /**
  70256. * Instantiate the action
  70257. * @param triggerOptions defines the trigger options
  70258. * @param target defines the target animation or animation name
  70259. * @param from defines from where the animation should start (animation frame)
  70260. * @param end defines where the animation should stop (animation frame)
  70261. * @param loop defines if the animation should loop or stop after the first play
  70262. * @param condition defines the trigger related conditions
  70263. */
  70264. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70265. /** @hidden */
  70266. _prepare(): void;
  70267. /**
  70268. * Execute the action and play the animation.
  70269. */
  70270. execute(): void;
  70271. /**
  70272. * Serializes the actions and its related information.
  70273. * @param parent defines the object to serialize in
  70274. * @returns the serialized object
  70275. */
  70276. serialize(parent: any): any;
  70277. }
  70278. /**
  70279. * This defines an action responsible to stop an animation once triggered.
  70280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70281. */
  70282. export class StopAnimationAction extends Action {
  70283. private _target;
  70284. /**
  70285. * Instantiate the action
  70286. * @param triggerOptions defines the trigger options
  70287. * @param target defines the target animation or animation name
  70288. * @param condition defines the trigger related conditions
  70289. */
  70290. constructor(triggerOptions: any, target: any, condition?: Condition);
  70291. /** @hidden */
  70292. _prepare(): void;
  70293. /**
  70294. * Execute the action and stop the animation.
  70295. */
  70296. execute(): void;
  70297. /**
  70298. * Serializes the actions and its related information.
  70299. * @param parent defines the object to serialize in
  70300. * @returns the serialized object
  70301. */
  70302. serialize(parent: any): any;
  70303. }
  70304. /**
  70305. * This defines an action responsible that does nothing once triggered.
  70306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70307. */
  70308. export class DoNothingAction extends Action {
  70309. /**
  70310. * Instantiate the action
  70311. * @param triggerOptions defines the trigger options
  70312. * @param condition defines the trigger related conditions
  70313. */
  70314. constructor(triggerOptions?: any, condition?: Condition);
  70315. /**
  70316. * Execute the action and do nothing.
  70317. */
  70318. execute(): void;
  70319. /**
  70320. * Serializes the actions and its related information.
  70321. * @param parent defines the object to serialize in
  70322. * @returns the serialized object
  70323. */
  70324. serialize(parent: any): any;
  70325. }
  70326. /**
  70327. * This defines an action responsible to trigger several actions once triggered.
  70328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70329. */
  70330. export class CombineAction extends Action {
  70331. /**
  70332. * The list of aggregated animations to run.
  70333. */
  70334. children: Action[];
  70335. /**
  70336. * Instantiate the action
  70337. * @param triggerOptions defines the trigger options
  70338. * @param children defines the list of aggregated animations to run
  70339. * @param condition defines the trigger related conditions
  70340. */
  70341. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70342. /** @hidden */
  70343. _prepare(): void;
  70344. /**
  70345. * Execute the action and executes all the aggregated actions.
  70346. */
  70347. execute(evt: ActionEvent): void;
  70348. /**
  70349. * Serializes the actions and its related information.
  70350. * @param parent defines the object to serialize in
  70351. * @returns the serialized object
  70352. */
  70353. serialize(parent: any): any;
  70354. }
  70355. /**
  70356. * This defines an action responsible to run code (external event) once triggered.
  70357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70358. */
  70359. export class ExecuteCodeAction extends Action {
  70360. /**
  70361. * The callback function to run.
  70362. */
  70363. func: (evt: ActionEvent) => void;
  70364. /**
  70365. * Instantiate the action
  70366. * @param triggerOptions defines the trigger options
  70367. * @param func defines the callback function to run
  70368. * @param condition defines the trigger related conditions
  70369. */
  70370. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70371. /**
  70372. * Execute the action and run the attached code.
  70373. */
  70374. execute(evt: ActionEvent): void;
  70375. }
  70376. /**
  70377. * This defines an action responsible to set the parent property of the target once triggered.
  70378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70379. */
  70380. export class SetParentAction extends Action {
  70381. private _parent;
  70382. private _target;
  70383. /**
  70384. * Instantiate the action
  70385. * @param triggerOptions defines the trigger options
  70386. * @param target defines the target containing the parent property
  70387. * @param parent defines from where the animation should start (animation frame)
  70388. * @param condition defines the trigger related conditions
  70389. */
  70390. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70391. /** @hidden */
  70392. _prepare(): void;
  70393. /**
  70394. * Execute the action and set the parent property.
  70395. */
  70396. execute(): void;
  70397. /**
  70398. * Serializes the actions and its related information.
  70399. * @param parent defines the object to serialize in
  70400. * @returns the serialized object
  70401. */
  70402. serialize(parent: any): any;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /**
  70407. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70408. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70410. */
  70411. export class ActionManager extends AbstractActionManager {
  70412. /**
  70413. * Nothing
  70414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70415. */
  70416. static readonly NothingTrigger: number;
  70417. /**
  70418. * On pick
  70419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70420. */
  70421. static readonly OnPickTrigger: number;
  70422. /**
  70423. * On left pick
  70424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70425. */
  70426. static readonly OnLeftPickTrigger: number;
  70427. /**
  70428. * On right pick
  70429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70430. */
  70431. static readonly OnRightPickTrigger: number;
  70432. /**
  70433. * On center pick
  70434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70435. */
  70436. static readonly OnCenterPickTrigger: number;
  70437. /**
  70438. * On pick down
  70439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70440. */
  70441. static readonly OnPickDownTrigger: number;
  70442. /**
  70443. * On double pick
  70444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70445. */
  70446. static readonly OnDoublePickTrigger: number;
  70447. /**
  70448. * On pick up
  70449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70450. */
  70451. static readonly OnPickUpTrigger: number;
  70452. /**
  70453. * On pick out.
  70454. * This trigger will only be raised if you also declared a OnPickDown
  70455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70456. */
  70457. static readonly OnPickOutTrigger: number;
  70458. /**
  70459. * On long press
  70460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70461. */
  70462. static readonly OnLongPressTrigger: number;
  70463. /**
  70464. * On pointer over
  70465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70466. */
  70467. static readonly OnPointerOverTrigger: number;
  70468. /**
  70469. * On pointer out
  70470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70471. */
  70472. static readonly OnPointerOutTrigger: number;
  70473. /**
  70474. * On every frame
  70475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70476. */
  70477. static readonly OnEveryFrameTrigger: number;
  70478. /**
  70479. * On intersection enter
  70480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70481. */
  70482. static readonly OnIntersectionEnterTrigger: number;
  70483. /**
  70484. * On intersection exit
  70485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70486. */
  70487. static readonly OnIntersectionExitTrigger: number;
  70488. /**
  70489. * On key down
  70490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70491. */
  70492. static readonly OnKeyDownTrigger: number;
  70493. /**
  70494. * On key up
  70495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70496. */
  70497. static readonly OnKeyUpTrigger: number;
  70498. private _scene;
  70499. /**
  70500. * Creates a new action manager
  70501. * @param scene defines the hosting scene
  70502. */
  70503. constructor(scene: Scene);
  70504. /**
  70505. * Releases all associated resources
  70506. */
  70507. dispose(): void;
  70508. /**
  70509. * Gets hosting scene
  70510. * @returns the hosting scene
  70511. */
  70512. getScene(): Scene;
  70513. /**
  70514. * Does this action manager handles actions of any of the given triggers
  70515. * @param triggers defines the triggers to be tested
  70516. * @return a boolean indicating whether one (or more) of the triggers is handled
  70517. */
  70518. hasSpecificTriggers(triggers: number[]): boolean;
  70519. /**
  70520. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70521. * speed.
  70522. * @param triggerA defines the trigger to be tested
  70523. * @param triggerB defines the trigger to be tested
  70524. * @return a boolean indicating whether one (or more) of the triggers is handled
  70525. */
  70526. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70527. /**
  70528. * Does this action manager handles actions of a given trigger
  70529. * @param trigger defines the trigger to be tested
  70530. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70531. * @return whether the trigger is handled
  70532. */
  70533. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70534. /**
  70535. * Does this action manager has pointer triggers
  70536. */
  70537. readonly hasPointerTriggers: boolean;
  70538. /**
  70539. * Does this action manager has pick triggers
  70540. */
  70541. readonly hasPickTriggers: boolean;
  70542. /**
  70543. * Registers an action to this action manager
  70544. * @param action defines the action to be registered
  70545. * @return the action amended (prepared) after registration
  70546. */
  70547. registerAction(action: IAction): Nullable<IAction>;
  70548. /**
  70549. * Unregisters an action to this action manager
  70550. * @param action defines the action to be unregistered
  70551. * @return a boolean indicating whether the action has been unregistered
  70552. */
  70553. unregisterAction(action: IAction): Boolean;
  70554. /**
  70555. * Process a specific trigger
  70556. * @param trigger defines the trigger to process
  70557. * @param evt defines the event details to be processed
  70558. */
  70559. processTrigger(trigger: number, evt?: IActionEvent): void;
  70560. /** @hidden */
  70561. _getEffectiveTarget(target: any, propertyPath: string): any;
  70562. /** @hidden */
  70563. _getProperty(propertyPath: string): string;
  70564. /**
  70565. * Serialize this manager to a JSON object
  70566. * @param name defines the property name to store this manager
  70567. * @returns a JSON representation of this manager
  70568. */
  70569. serialize(name: string): any;
  70570. /**
  70571. * Creates a new ActionManager from a JSON data
  70572. * @param parsedActions defines the JSON data to read from
  70573. * @param object defines the hosting mesh
  70574. * @param scene defines the hosting scene
  70575. */
  70576. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70577. /**
  70578. * Get a trigger name by index
  70579. * @param trigger defines the trigger index
  70580. * @returns a trigger name
  70581. */
  70582. static GetTriggerName(trigger: number): string;
  70583. }
  70584. }
  70585. declare module BABYLON {
  70586. /**
  70587. * Class representing a ray with position and direction
  70588. */
  70589. export class Ray {
  70590. /** origin point */
  70591. origin: Vector3;
  70592. /** direction */
  70593. direction: Vector3;
  70594. /** length of the ray */
  70595. length: number;
  70596. private static readonly TmpVector3;
  70597. private _tmpRay;
  70598. /**
  70599. * Creates a new ray
  70600. * @param origin origin point
  70601. * @param direction direction
  70602. * @param length length of the ray
  70603. */
  70604. constructor(
  70605. /** origin point */
  70606. origin: Vector3,
  70607. /** direction */
  70608. direction: Vector3,
  70609. /** length of the ray */
  70610. length?: number);
  70611. /**
  70612. * Checks if the ray intersects a box
  70613. * @param minimum bound of the box
  70614. * @param maximum bound of the box
  70615. * @param intersectionTreshold extra extend to be added to the box in all direction
  70616. * @returns if the box was hit
  70617. */
  70618. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70619. /**
  70620. * Checks if the ray intersects a box
  70621. * @param box the bounding box to check
  70622. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70623. * @returns if the box was hit
  70624. */
  70625. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70626. /**
  70627. * If the ray hits a sphere
  70628. * @param sphere the bounding sphere to check
  70629. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70630. * @returns true if it hits the sphere
  70631. */
  70632. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70633. /**
  70634. * If the ray hits a triange
  70635. * @param vertex0 triangle vertex
  70636. * @param vertex1 triangle vertex
  70637. * @param vertex2 triangle vertex
  70638. * @returns intersection information if hit
  70639. */
  70640. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70641. /**
  70642. * Checks if ray intersects a plane
  70643. * @param plane the plane to check
  70644. * @returns the distance away it was hit
  70645. */
  70646. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70647. /**
  70648. * Checks if ray intersects a mesh
  70649. * @param mesh the mesh to check
  70650. * @param fastCheck if only the bounding box should checked
  70651. * @returns picking info of the intersecton
  70652. */
  70653. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70654. /**
  70655. * Checks if ray intersects a mesh
  70656. * @param meshes the meshes to check
  70657. * @param fastCheck if only the bounding box should checked
  70658. * @param results array to store result in
  70659. * @returns Array of picking infos
  70660. */
  70661. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70662. private _comparePickingInfo;
  70663. private static smallnum;
  70664. private static rayl;
  70665. /**
  70666. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70667. * @param sega the first point of the segment to test the intersection against
  70668. * @param segb the second point of the segment to test the intersection against
  70669. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70670. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70671. */
  70672. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70673. /**
  70674. * Update the ray from viewport position
  70675. * @param x position
  70676. * @param y y position
  70677. * @param viewportWidth viewport width
  70678. * @param viewportHeight viewport height
  70679. * @param world world matrix
  70680. * @param view view matrix
  70681. * @param projection projection matrix
  70682. * @returns this ray updated
  70683. */
  70684. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70685. /**
  70686. * Creates a ray with origin and direction of 0,0,0
  70687. * @returns the new ray
  70688. */
  70689. static Zero(): Ray;
  70690. /**
  70691. * Creates a new ray from screen space and viewport
  70692. * @param x position
  70693. * @param y y position
  70694. * @param viewportWidth viewport width
  70695. * @param viewportHeight viewport height
  70696. * @param world world matrix
  70697. * @param view view matrix
  70698. * @param projection projection matrix
  70699. * @returns new ray
  70700. */
  70701. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70702. /**
  70703. * 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
  70704. * transformed to the given world matrix.
  70705. * @param origin The origin point
  70706. * @param end The end point
  70707. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70708. * @returns the new ray
  70709. */
  70710. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70711. /**
  70712. * Transforms a ray by a matrix
  70713. * @param ray ray to transform
  70714. * @param matrix matrix to apply
  70715. * @returns the resulting new ray
  70716. */
  70717. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70718. /**
  70719. * Transforms a ray by a matrix
  70720. * @param ray ray to transform
  70721. * @param matrix matrix to apply
  70722. * @param result ray to store result in
  70723. */
  70724. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70725. /**
  70726. * Unproject a ray from screen space to object space
  70727. * @param sourceX defines the screen space x coordinate to use
  70728. * @param sourceY defines the screen space y coordinate to use
  70729. * @param viewportWidth defines the current width of the viewport
  70730. * @param viewportHeight defines the current height of the viewport
  70731. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70732. * @param view defines the view matrix to use
  70733. * @param projection defines the projection matrix to use
  70734. */
  70735. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70736. }
  70737. /**
  70738. * Type used to define predicate used to select faces when a mesh intersection is detected
  70739. */
  70740. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70741. interface Scene {
  70742. /** @hidden */
  70743. _tempPickingRay: Nullable<Ray>;
  70744. /** @hidden */
  70745. _cachedRayForTransform: Ray;
  70746. /** @hidden */
  70747. _pickWithRayInverseMatrix: Matrix;
  70748. /** @hidden */
  70749. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70750. /** @hidden */
  70751. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70752. }
  70753. }
  70754. declare module BABYLON {
  70755. /**
  70756. * Groups all the scene component constants in one place to ease maintenance.
  70757. * @hidden
  70758. */
  70759. export class SceneComponentConstants {
  70760. static readonly NAME_EFFECTLAYER: string;
  70761. static readonly NAME_LAYER: string;
  70762. static readonly NAME_LENSFLARESYSTEM: string;
  70763. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70764. static readonly NAME_PARTICLESYSTEM: string;
  70765. static readonly NAME_GAMEPAD: string;
  70766. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70767. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70768. static readonly NAME_DEPTHRENDERER: string;
  70769. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70770. static readonly NAME_SPRITE: string;
  70771. static readonly NAME_OUTLINERENDERER: string;
  70772. static readonly NAME_PROCEDURALTEXTURE: string;
  70773. static readonly NAME_SHADOWGENERATOR: string;
  70774. static readonly NAME_OCTREE: string;
  70775. static readonly NAME_PHYSICSENGINE: string;
  70776. static readonly NAME_AUDIO: string;
  70777. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70778. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70779. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70780. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70781. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70782. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70783. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70784. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70785. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70786. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70787. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70788. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70789. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70790. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70791. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70792. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70793. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70794. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70795. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70796. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70797. static readonly STEP_AFTERRENDER_AUDIO: number;
  70798. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70799. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70800. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70801. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70802. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70803. static readonly STEP_POINTERMOVE_SPRITE: number;
  70804. static readonly STEP_POINTERDOWN_SPRITE: number;
  70805. static readonly STEP_POINTERUP_SPRITE: number;
  70806. }
  70807. /**
  70808. * This represents a scene component.
  70809. *
  70810. * This is used to decouple the dependency the scene is having on the different workloads like
  70811. * layers, post processes...
  70812. */
  70813. export interface ISceneComponent {
  70814. /**
  70815. * The name of the component. Each component must have a unique name.
  70816. */
  70817. name: string;
  70818. /**
  70819. * The scene the component belongs to.
  70820. */
  70821. scene: Scene;
  70822. /**
  70823. * Register the component to one instance of a scene.
  70824. */
  70825. register(): void;
  70826. /**
  70827. * Rebuilds the elements related to this component in case of
  70828. * context lost for instance.
  70829. */
  70830. rebuild(): void;
  70831. /**
  70832. * Disposes the component and the associated ressources.
  70833. */
  70834. dispose(): void;
  70835. }
  70836. /**
  70837. * This represents a SERIALIZABLE scene component.
  70838. *
  70839. * This extends Scene Component to add Serialization methods on top.
  70840. */
  70841. export interface ISceneSerializableComponent extends ISceneComponent {
  70842. /**
  70843. * Adds all the element from the container to the scene
  70844. * @param container the container holding the elements
  70845. */
  70846. addFromContainer(container: AbstractScene): void;
  70847. /**
  70848. * Removes all the elements in the container from the scene
  70849. * @param container contains the elements to remove
  70850. * @param dispose if the removed element should be disposed (default: false)
  70851. */
  70852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70853. /**
  70854. * Serializes the component data to the specified json object
  70855. * @param serializationObject The object to serialize to
  70856. */
  70857. serialize(serializationObject: any): void;
  70858. }
  70859. /**
  70860. * Strong typing of a Mesh related stage step action
  70861. */
  70862. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70863. /**
  70864. * Strong typing of a Evaluate Sub Mesh related stage step action
  70865. */
  70866. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70867. /**
  70868. * Strong typing of a Active Mesh related stage step action
  70869. */
  70870. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70871. /**
  70872. * Strong typing of a Camera related stage step action
  70873. */
  70874. export type CameraStageAction = (camera: Camera) => void;
  70875. /**
  70876. * Strong typing of a Render Target related stage step action
  70877. */
  70878. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70879. /**
  70880. * Strong typing of a RenderingGroup related stage step action
  70881. */
  70882. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70883. /**
  70884. * Strong typing of a Mesh Render related stage step action
  70885. */
  70886. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70887. /**
  70888. * Strong typing of a simple stage step action
  70889. */
  70890. export type SimpleStageAction = () => void;
  70891. /**
  70892. * Strong typing of a render target action.
  70893. */
  70894. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70895. /**
  70896. * Strong typing of a pointer move action.
  70897. */
  70898. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70899. /**
  70900. * Strong typing of a pointer up/down action.
  70901. */
  70902. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70903. /**
  70904. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70905. * @hidden
  70906. */
  70907. export class Stage<T extends Function> extends Array<{
  70908. index: number;
  70909. component: ISceneComponent;
  70910. action: T;
  70911. }> {
  70912. /**
  70913. * Hide ctor from the rest of the world.
  70914. * @param items The items to add.
  70915. */
  70916. private constructor();
  70917. /**
  70918. * Creates a new Stage.
  70919. * @returns A new instance of a Stage
  70920. */
  70921. static Create<T extends Function>(): Stage<T>;
  70922. /**
  70923. * Registers a step in an ordered way in the targeted stage.
  70924. * @param index Defines the position to register the step in
  70925. * @param component Defines the component attached to the step
  70926. * @param action Defines the action to launch during the step
  70927. */
  70928. registerStep(index: number, component: ISceneComponent, action: T): void;
  70929. /**
  70930. * Clears all the steps from the stage.
  70931. */
  70932. clear(): void;
  70933. }
  70934. }
  70935. declare module BABYLON {
  70936. interface Scene {
  70937. /** @hidden */
  70938. _pointerOverSprite: Nullable<Sprite>;
  70939. /** @hidden */
  70940. _pickedDownSprite: Nullable<Sprite>;
  70941. /** @hidden */
  70942. _tempSpritePickingRay: Nullable<Ray>;
  70943. /**
  70944. * All of the sprite managers added to this scene
  70945. * @see http://doc.babylonjs.com/babylon101/sprites
  70946. */
  70947. spriteManagers: Array<ISpriteManager>;
  70948. /**
  70949. * An event triggered when sprites rendering is about to start
  70950. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70951. */
  70952. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70953. /**
  70954. * An event triggered when sprites rendering is done
  70955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70956. */
  70957. onAfterSpritesRenderingObservable: Observable<Scene>;
  70958. /** @hidden */
  70959. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70960. /** Launch a ray to try to pick a sprite in the scene
  70961. * @param x position on screen
  70962. * @param y position on screen
  70963. * @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
  70964. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70965. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70966. * @returns a PickingInfo
  70967. */
  70968. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70969. /** Use the given ray to pick a sprite in the scene
  70970. * @param ray The ray (in world space) to use to pick meshes
  70971. * @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
  70972. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70973. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70974. * @returns a PickingInfo
  70975. */
  70976. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70977. /**
  70978. * Force the sprite under the pointer
  70979. * @param sprite defines the sprite to use
  70980. */
  70981. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70982. /**
  70983. * Gets the sprite under the pointer
  70984. * @returns a Sprite or null if no sprite is under the pointer
  70985. */
  70986. getPointerOverSprite(): Nullable<Sprite>;
  70987. }
  70988. /**
  70989. * Defines the sprite scene component responsible to manage sprites
  70990. * in a given scene.
  70991. */
  70992. export class SpriteSceneComponent implements ISceneComponent {
  70993. /**
  70994. * The component name helpfull to identify the component in the list of scene components.
  70995. */
  70996. readonly name: string;
  70997. /**
  70998. * The scene the component belongs to.
  70999. */
  71000. scene: Scene;
  71001. /** @hidden */
  71002. private _spritePredicate;
  71003. /**
  71004. * Creates a new instance of the component for the given scene
  71005. * @param scene Defines the scene to register the component in
  71006. */
  71007. constructor(scene: Scene);
  71008. /**
  71009. * Registers the component in a given scene
  71010. */
  71011. register(): void;
  71012. /**
  71013. * Rebuilds the elements related to this component in case of
  71014. * context lost for instance.
  71015. */
  71016. rebuild(): void;
  71017. /**
  71018. * Disposes the component and the associated ressources.
  71019. */
  71020. dispose(): void;
  71021. private _pickSpriteButKeepRay;
  71022. private _pointerMove;
  71023. private _pointerDown;
  71024. private _pointerUp;
  71025. }
  71026. }
  71027. declare module BABYLON {
  71028. /** @hidden */
  71029. export var fogFragmentDeclaration: {
  71030. name: string;
  71031. shader: string;
  71032. };
  71033. }
  71034. declare module BABYLON {
  71035. /** @hidden */
  71036. export var fogFragment: {
  71037. name: string;
  71038. shader: string;
  71039. };
  71040. }
  71041. declare module BABYLON {
  71042. /** @hidden */
  71043. export var spritesPixelShader: {
  71044. name: string;
  71045. shader: string;
  71046. };
  71047. }
  71048. declare module BABYLON {
  71049. /** @hidden */
  71050. export var fogVertexDeclaration: {
  71051. name: string;
  71052. shader: string;
  71053. };
  71054. }
  71055. declare module BABYLON {
  71056. /** @hidden */
  71057. export var spritesVertexShader: {
  71058. name: string;
  71059. shader: string;
  71060. };
  71061. }
  71062. declare module BABYLON {
  71063. /**
  71064. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71065. */
  71066. export interface ISpriteManager extends IDisposable {
  71067. /**
  71068. * Restricts the camera to viewing objects with the same layerMask.
  71069. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71070. */
  71071. layerMask: number;
  71072. /**
  71073. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71074. */
  71075. isPickable: boolean;
  71076. /**
  71077. * Specifies the rendering group id for this mesh (0 by default)
  71078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71079. */
  71080. renderingGroupId: number;
  71081. /**
  71082. * Defines the list of sprites managed by the manager.
  71083. */
  71084. sprites: Array<Sprite>;
  71085. /**
  71086. * Tests the intersection of a sprite with a specific ray.
  71087. * @param ray The ray we are sending to test the collision
  71088. * @param camera The camera space we are sending rays in
  71089. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71090. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71091. * @returns picking info or null.
  71092. */
  71093. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71094. /**
  71095. * Renders the list of sprites on screen.
  71096. */
  71097. render(): void;
  71098. }
  71099. /**
  71100. * Class used to manage multiple sprites on the same spritesheet
  71101. * @see http://doc.babylonjs.com/babylon101/sprites
  71102. */
  71103. export class SpriteManager implements ISpriteManager {
  71104. /** defines the manager's name */
  71105. name: string;
  71106. /** Gets the list of sprites */
  71107. sprites: Sprite[];
  71108. /** Gets or sets the rendering group id (0 by default) */
  71109. renderingGroupId: number;
  71110. /** Gets or sets camera layer mask */
  71111. layerMask: number;
  71112. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71113. fogEnabled: boolean;
  71114. /** Gets or sets a boolean indicating if the sprites are pickable */
  71115. isPickable: boolean;
  71116. /** Defines the default width of a cell in the spritesheet */
  71117. cellWidth: number;
  71118. /** Defines the default height of a cell in the spritesheet */
  71119. cellHeight: number;
  71120. /**
  71121. * An event triggered when the manager is disposed.
  71122. */
  71123. onDisposeObservable: Observable<SpriteManager>;
  71124. private _onDisposeObserver;
  71125. /**
  71126. * Callback called when the manager is disposed
  71127. */
  71128. onDispose: () => void;
  71129. private _capacity;
  71130. private _spriteTexture;
  71131. private _epsilon;
  71132. private _scene;
  71133. private _vertexData;
  71134. private _buffer;
  71135. private _vertexBuffers;
  71136. private _indexBuffer;
  71137. private _effectBase;
  71138. private _effectFog;
  71139. /**
  71140. * Gets or sets the spritesheet texture
  71141. */
  71142. texture: Texture;
  71143. /**
  71144. * Creates a new sprite manager
  71145. * @param name defines the manager's name
  71146. * @param imgUrl defines the sprite sheet url
  71147. * @param capacity defines the maximum allowed number of sprites
  71148. * @param cellSize defines the size of a sprite cell
  71149. * @param scene defines the hosting scene
  71150. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71151. * @param samplingMode defines the smapling mode to use with spritesheet
  71152. */
  71153. constructor(
  71154. /** defines the manager's name */
  71155. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71156. private _appendSpriteVertex;
  71157. /**
  71158. * Intersects the sprites with a ray
  71159. * @param ray defines the ray to intersect with
  71160. * @param camera defines the current active camera
  71161. * @param predicate defines a predicate used to select candidate sprites
  71162. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71163. * @returns null if no hit or a PickingInfo
  71164. */
  71165. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71166. /**
  71167. * Render all child sprites
  71168. */
  71169. render(): void;
  71170. /**
  71171. * Release associated resources
  71172. */
  71173. dispose(): void;
  71174. }
  71175. }
  71176. declare module BABYLON {
  71177. /**
  71178. * Class used to represent a sprite
  71179. * @see http://doc.babylonjs.com/babylon101/sprites
  71180. */
  71181. export class Sprite {
  71182. /** defines the name */
  71183. name: string;
  71184. /** Gets or sets the current world position */
  71185. position: Vector3;
  71186. /** Gets or sets the main color */
  71187. color: Color4;
  71188. /** Gets or sets the width */
  71189. width: number;
  71190. /** Gets or sets the height */
  71191. height: number;
  71192. /** Gets or sets rotation angle */
  71193. angle: number;
  71194. /** Gets or sets the cell index in the sprite sheet */
  71195. cellIndex: number;
  71196. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71197. invertU: number;
  71198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71199. invertV: number;
  71200. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71201. disposeWhenFinishedAnimating: boolean;
  71202. /** Gets the list of attached animations */
  71203. animations: Animation[];
  71204. /** Gets or sets a boolean indicating if the sprite can be picked */
  71205. isPickable: boolean;
  71206. /**
  71207. * Gets or sets the associated action manager
  71208. */
  71209. actionManager: Nullable<ActionManager>;
  71210. private _animationStarted;
  71211. private _loopAnimation;
  71212. private _fromIndex;
  71213. private _toIndex;
  71214. private _delay;
  71215. private _direction;
  71216. private _manager;
  71217. private _time;
  71218. private _onAnimationEnd;
  71219. /**
  71220. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71221. */
  71222. isVisible: boolean;
  71223. /**
  71224. * Gets or sets the sprite size
  71225. */
  71226. size: number;
  71227. /**
  71228. * Creates a new Sprite
  71229. * @param name defines the name
  71230. * @param manager defines the manager
  71231. */
  71232. constructor(
  71233. /** defines the name */
  71234. name: string, manager: ISpriteManager);
  71235. /**
  71236. * Starts an animation
  71237. * @param from defines the initial key
  71238. * @param to defines the end key
  71239. * @param loop defines if the animation must loop
  71240. * @param delay defines the start delay (in ms)
  71241. * @param onAnimationEnd defines a callback to call when animation ends
  71242. */
  71243. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71244. /** Stops current animation (if any) */
  71245. stopAnimation(): void;
  71246. /** @hidden */
  71247. _animate(deltaTime: number): void;
  71248. /** Release associated resources */
  71249. dispose(): void;
  71250. }
  71251. }
  71252. declare module BABYLON {
  71253. /**
  71254. * Information about the result of picking within a scene
  71255. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71256. */
  71257. export class PickingInfo {
  71258. /** @hidden */
  71259. _pickingUnavailable: boolean;
  71260. /**
  71261. * If the pick collided with an object
  71262. */
  71263. hit: boolean;
  71264. /**
  71265. * Distance away where the pick collided
  71266. */
  71267. distance: number;
  71268. /**
  71269. * The location of pick collision
  71270. */
  71271. pickedPoint: Nullable<Vector3>;
  71272. /**
  71273. * The mesh corresponding the the pick collision
  71274. */
  71275. pickedMesh: Nullable<AbstractMesh>;
  71276. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71277. bu: number;
  71278. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71279. bv: number;
  71280. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71281. faceId: number;
  71282. /** Id of the the submesh that was picked */
  71283. subMeshId: number;
  71284. /** If a sprite was picked, this will be the sprite the pick collided with */
  71285. pickedSprite: Nullable<Sprite>;
  71286. /**
  71287. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71288. */
  71289. originMesh: Nullable<AbstractMesh>;
  71290. /**
  71291. * The ray that was used to perform the picking.
  71292. */
  71293. ray: Nullable<Ray>;
  71294. /**
  71295. * Gets the normal correspodning to the face the pick collided with
  71296. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71297. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71298. * @returns The normal correspodning to the face the pick collided with
  71299. */
  71300. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71301. /**
  71302. * Gets the texture coordinates of where the pick occured
  71303. * @returns the vector containing the coordnates of the texture
  71304. */
  71305. getTextureCoordinates(): Nullable<Vector2>;
  71306. }
  71307. }
  71308. declare module BABYLON {
  71309. /**
  71310. * Gather the list of pointer event types as constants.
  71311. */
  71312. export class PointerEventTypes {
  71313. /**
  71314. * 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.
  71315. */
  71316. static readonly POINTERDOWN: number;
  71317. /**
  71318. * The pointerup event is fired when a pointer is no longer active.
  71319. */
  71320. static readonly POINTERUP: number;
  71321. /**
  71322. * The pointermove event is fired when a pointer changes coordinates.
  71323. */
  71324. static readonly POINTERMOVE: number;
  71325. /**
  71326. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71327. */
  71328. static readonly POINTERWHEEL: number;
  71329. /**
  71330. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71331. */
  71332. static readonly POINTERPICK: number;
  71333. /**
  71334. * The pointertap event is fired when a the object has been touched and released without drag.
  71335. */
  71336. static readonly POINTERTAP: number;
  71337. /**
  71338. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71339. */
  71340. static readonly POINTERDOUBLETAP: number;
  71341. }
  71342. /**
  71343. * Base class of pointer info types.
  71344. */
  71345. export class PointerInfoBase {
  71346. /**
  71347. * Defines the type of event (PointerEventTypes)
  71348. */
  71349. type: number;
  71350. /**
  71351. * Defines the related dom event
  71352. */
  71353. event: PointerEvent | MouseWheelEvent;
  71354. /**
  71355. * Instantiates the base class of pointers info.
  71356. * @param type Defines the type of event (PointerEventTypes)
  71357. * @param event Defines the related dom event
  71358. */
  71359. constructor(
  71360. /**
  71361. * Defines the type of event (PointerEventTypes)
  71362. */
  71363. type: number,
  71364. /**
  71365. * Defines the related dom event
  71366. */
  71367. event: PointerEvent | MouseWheelEvent);
  71368. }
  71369. /**
  71370. * This class is used to store pointer related info for the onPrePointerObservable event.
  71371. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71372. */
  71373. export class PointerInfoPre extends PointerInfoBase {
  71374. /**
  71375. * Ray from a pointer if availible (eg. 6dof controller)
  71376. */
  71377. ray: Nullable<Ray>;
  71378. /**
  71379. * Defines the local position of the pointer on the canvas.
  71380. */
  71381. localPosition: Vector2;
  71382. /**
  71383. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71384. */
  71385. skipOnPointerObservable: boolean;
  71386. /**
  71387. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71388. * @param type Defines the type of event (PointerEventTypes)
  71389. * @param event Defines the related dom event
  71390. * @param localX Defines the local x coordinates of the pointer when the event occured
  71391. * @param localY Defines the local y coordinates of the pointer when the event occured
  71392. */
  71393. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71394. }
  71395. /**
  71396. * This type contains all the data related to a pointer event in Babylon.js.
  71397. * 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.
  71398. */
  71399. export class PointerInfo extends PointerInfoBase {
  71400. /**
  71401. * Defines the picking info associated to the info (if any)\
  71402. */
  71403. pickInfo: Nullable<PickingInfo>;
  71404. /**
  71405. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71406. * @param type Defines the type of event (PointerEventTypes)
  71407. * @param event Defines the related dom event
  71408. * @param pickInfo Defines the picking info associated to the info (if any)\
  71409. */
  71410. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71411. /**
  71412. * Defines the picking info associated to the info (if any)\
  71413. */
  71414. pickInfo: Nullable<PickingInfo>);
  71415. }
  71416. /**
  71417. * Data relating to a touch event on the screen.
  71418. */
  71419. export interface PointerTouch {
  71420. /**
  71421. * X coordinate of touch.
  71422. */
  71423. x: number;
  71424. /**
  71425. * Y coordinate of touch.
  71426. */
  71427. y: number;
  71428. /**
  71429. * Id of touch. Unique for each finger.
  71430. */
  71431. pointerId: number;
  71432. /**
  71433. * Event type passed from DOM.
  71434. */
  71435. type: any;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * Manage the mouse inputs to control the movement of a free camera.
  71441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71442. */
  71443. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71444. /**
  71445. * Define if touch is enabled in the mouse input
  71446. */
  71447. touchEnabled: boolean;
  71448. /**
  71449. * Defines the camera the input is attached to.
  71450. */
  71451. camera: FreeCamera;
  71452. /**
  71453. * Defines the buttons associated with the input to handle camera move.
  71454. */
  71455. buttons: number[];
  71456. /**
  71457. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71458. */
  71459. angularSensibility: number;
  71460. private _pointerInput;
  71461. private _onMouseMove;
  71462. private _observer;
  71463. private previousPosition;
  71464. /**
  71465. * Observable for when a pointer move event occurs containing the move offset
  71466. */
  71467. onPointerMovedObservable: Observable<{
  71468. offsetX: number;
  71469. offsetY: number;
  71470. }>;
  71471. /**
  71472. * @hidden
  71473. * If the camera should be rotated automatically based on pointer movement
  71474. */
  71475. _allowCameraRotation: boolean;
  71476. /**
  71477. * Manage the mouse inputs to control the movement of a free camera.
  71478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71479. * @param touchEnabled Defines if touch is enabled or not
  71480. */
  71481. constructor(
  71482. /**
  71483. * Define if touch is enabled in the mouse input
  71484. */
  71485. touchEnabled?: boolean);
  71486. /**
  71487. * Attach the input controls to a specific dom element to get the input from.
  71488. * @param element Defines the element the controls should be listened from
  71489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71490. */
  71491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71492. /**
  71493. * Called on JS contextmenu event.
  71494. * Override this method to provide functionality.
  71495. */
  71496. protected onContextMenu(evt: PointerEvent): void;
  71497. /**
  71498. * Detach the current controls from the specified dom element.
  71499. * @param element Defines the element to stop listening the inputs from
  71500. */
  71501. detachControl(element: Nullable<HTMLElement>): void;
  71502. /**
  71503. * Gets the class name of the current intput.
  71504. * @returns the class name
  71505. */
  71506. getClassName(): string;
  71507. /**
  71508. * Get the friendly name associated with the input class.
  71509. * @returns the input friendly name
  71510. */
  71511. getSimpleName(): string;
  71512. }
  71513. }
  71514. declare module BABYLON {
  71515. /**
  71516. * Manage the touch inputs to control the movement of a free camera.
  71517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71518. */
  71519. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71520. /**
  71521. * Defines the camera the input is attached to.
  71522. */
  71523. camera: FreeCamera;
  71524. /**
  71525. * Defines the touch sensibility for rotation.
  71526. * The higher the faster.
  71527. */
  71528. touchAngularSensibility: number;
  71529. /**
  71530. * Defines the touch sensibility for move.
  71531. * The higher the faster.
  71532. */
  71533. touchMoveSensibility: number;
  71534. private _offsetX;
  71535. private _offsetY;
  71536. private _pointerPressed;
  71537. private _pointerInput;
  71538. private _observer;
  71539. private _onLostFocus;
  71540. /**
  71541. * Attach the input controls to a specific dom element to get the input from.
  71542. * @param element Defines the element the controls should be listened from
  71543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71544. */
  71545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71546. /**
  71547. * Detach the current controls from the specified dom element.
  71548. * @param element Defines the element to stop listening the inputs from
  71549. */
  71550. detachControl(element: Nullable<HTMLElement>): void;
  71551. /**
  71552. * Update the current camera state depending on the inputs that have been used this frame.
  71553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71554. */
  71555. checkInputs(): void;
  71556. /**
  71557. * Gets the class name of the current intput.
  71558. * @returns the class name
  71559. */
  71560. getClassName(): string;
  71561. /**
  71562. * Get the friendly name associated with the input class.
  71563. * @returns the input friendly name
  71564. */
  71565. getSimpleName(): string;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /**
  71570. * Default Inputs manager for the FreeCamera.
  71571. * It groups all the default supported inputs for ease of use.
  71572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71573. */
  71574. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71575. /**
  71576. * @hidden
  71577. */
  71578. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71579. /**
  71580. * @hidden
  71581. */
  71582. _mouseInput: Nullable<FreeCameraMouseInput>;
  71583. /**
  71584. * Instantiates a new FreeCameraInputsManager.
  71585. * @param camera Defines the camera the inputs belong to
  71586. */
  71587. constructor(camera: FreeCamera);
  71588. /**
  71589. * Add keyboard input support to the input manager.
  71590. * @returns the current input manager
  71591. */
  71592. addKeyboard(): FreeCameraInputsManager;
  71593. /**
  71594. * Add mouse input support to the input manager.
  71595. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71596. * @returns the current input manager
  71597. */
  71598. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71599. /**
  71600. * Removes the mouse input support from the manager
  71601. * @returns the current input manager
  71602. */
  71603. removeMouse(): FreeCameraInputsManager;
  71604. /**
  71605. * Add touch input support to the input manager.
  71606. * @returns the current input manager
  71607. */
  71608. addTouch(): FreeCameraInputsManager;
  71609. }
  71610. }
  71611. declare module BABYLON {
  71612. /**
  71613. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71614. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71616. */
  71617. export class FreeCamera extends TargetCamera {
  71618. /**
  71619. * Define the collision ellipsoid of the camera.
  71620. * This is helpful to simulate a camera body like the player body around the camera
  71621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71622. */
  71623. ellipsoid: Vector3;
  71624. /**
  71625. * Define an offset for the position of the ellipsoid around the camera.
  71626. * This can be helpful to determine the center of the body near the gravity center of the body
  71627. * instead of its head.
  71628. */
  71629. ellipsoidOffset: Vector3;
  71630. /**
  71631. * Enable or disable collisions of the camera with the rest of the scene objects.
  71632. */
  71633. checkCollisions: boolean;
  71634. /**
  71635. * Enable or disable gravity on the camera.
  71636. */
  71637. applyGravity: boolean;
  71638. /**
  71639. * Define the input manager associated to the camera.
  71640. */
  71641. inputs: FreeCameraInputsManager;
  71642. /**
  71643. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71644. * Higher values reduce sensitivity.
  71645. */
  71646. /**
  71647. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71648. * Higher values reduce sensitivity.
  71649. */
  71650. angularSensibility: number;
  71651. /**
  71652. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71653. */
  71654. keysUp: number[];
  71655. /**
  71656. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71657. */
  71658. keysDown: number[];
  71659. /**
  71660. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71661. */
  71662. keysLeft: number[];
  71663. /**
  71664. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71665. */
  71666. keysRight: number[];
  71667. /**
  71668. * Event raised when the camera collide with a mesh in the scene.
  71669. */
  71670. onCollide: (collidedMesh: AbstractMesh) => void;
  71671. private _collider;
  71672. private _needMoveForGravity;
  71673. private _oldPosition;
  71674. private _diffPosition;
  71675. private _newPosition;
  71676. /** @hidden */
  71677. _localDirection: Vector3;
  71678. /** @hidden */
  71679. _transformedDirection: Vector3;
  71680. /**
  71681. * Instantiates a Free Camera.
  71682. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71683. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71684. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71685. * @param name Define the name of the camera in the scene
  71686. * @param position Define the start position of the camera in the scene
  71687. * @param scene Define the scene the camera belongs to
  71688. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71689. */
  71690. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71691. /**
  71692. * Attached controls to the current camera.
  71693. * @param element Defines the element the controls should be listened from
  71694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71695. */
  71696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71697. /**
  71698. * Detach the current controls from the camera.
  71699. * The camera will stop reacting to inputs.
  71700. * @param element Defines the element to stop listening the inputs from
  71701. */
  71702. detachControl(element: HTMLElement): void;
  71703. private _collisionMask;
  71704. /**
  71705. * Define a collision mask to limit the list of object the camera can collide with
  71706. */
  71707. collisionMask: number;
  71708. /** @hidden */
  71709. _collideWithWorld(displacement: Vector3): void;
  71710. private _onCollisionPositionChange;
  71711. /** @hidden */
  71712. _checkInputs(): void;
  71713. /** @hidden */
  71714. _decideIfNeedsToMove(): boolean;
  71715. /** @hidden */
  71716. _updatePosition(): void;
  71717. /**
  71718. * Destroy the camera and release the current resources hold by it.
  71719. */
  71720. dispose(): void;
  71721. /**
  71722. * Gets the current object class name.
  71723. * @return the class name
  71724. */
  71725. getClassName(): string;
  71726. }
  71727. }
  71728. declare module BABYLON {
  71729. /**
  71730. * Represents a gamepad control stick position
  71731. */
  71732. export class StickValues {
  71733. /**
  71734. * The x component of the control stick
  71735. */
  71736. x: number;
  71737. /**
  71738. * The y component of the control stick
  71739. */
  71740. y: number;
  71741. /**
  71742. * Initializes the gamepad x and y control stick values
  71743. * @param x The x component of the gamepad control stick value
  71744. * @param y The y component of the gamepad control stick value
  71745. */
  71746. constructor(
  71747. /**
  71748. * The x component of the control stick
  71749. */
  71750. x: number,
  71751. /**
  71752. * The y component of the control stick
  71753. */
  71754. y: number);
  71755. }
  71756. /**
  71757. * An interface which manages callbacks for gamepad button changes
  71758. */
  71759. export interface GamepadButtonChanges {
  71760. /**
  71761. * Called when a gamepad has been changed
  71762. */
  71763. changed: boolean;
  71764. /**
  71765. * Called when a gamepad press event has been triggered
  71766. */
  71767. pressChanged: boolean;
  71768. /**
  71769. * Called when a touch event has been triggered
  71770. */
  71771. touchChanged: boolean;
  71772. /**
  71773. * Called when a value has changed
  71774. */
  71775. valueChanged: boolean;
  71776. }
  71777. /**
  71778. * Represents a gamepad
  71779. */
  71780. export class Gamepad {
  71781. /**
  71782. * The id of the gamepad
  71783. */
  71784. id: string;
  71785. /**
  71786. * The index of the gamepad
  71787. */
  71788. index: number;
  71789. /**
  71790. * The browser gamepad
  71791. */
  71792. browserGamepad: any;
  71793. /**
  71794. * Specifies what type of gamepad this represents
  71795. */
  71796. type: number;
  71797. private _leftStick;
  71798. private _rightStick;
  71799. /** @hidden */
  71800. _isConnected: boolean;
  71801. private _leftStickAxisX;
  71802. private _leftStickAxisY;
  71803. private _rightStickAxisX;
  71804. private _rightStickAxisY;
  71805. /**
  71806. * Triggered when the left control stick has been changed
  71807. */
  71808. private _onleftstickchanged;
  71809. /**
  71810. * Triggered when the right control stick has been changed
  71811. */
  71812. private _onrightstickchanged;
  71813. /**
  71814. * Represents a gamepad controller
  71815. */
  71816. static GAMEPAD: number;
  71817. /**
  71818. * Represents a generic controller
  71819. */
  71820. static GENERIC: number;
  71821. /**
  71822. * Represents an XBox controller
  71823. */
  71824. static XBOX: number;
  71825. /**
  71826. * Represents a pose-enabled controller
  71827. */
  71828. static POSE_ENABLED: number;
  71829. /**
  71830. * Specifies whether the left control stick should be Y-inverted
  71831. */
  71832. protected _invertLeftStickY: boolean;
  71833. /**
  71834. * Specifies if the gamepad has been connected
  71835. */
  71836. readonly isConnected: boolean;
  71837. /**
  71838. * Initializes the gamepad
  71839. * @param id The id of the gamepad
  71840. * @param index The index of the gamepad
  71841. * @param browserGamepad The browser gamepad
  71842. * @param leftStickX The x component of the left joystick
  71843. * @param leftStickY The y component of the left joystick
  71844. * @param rightStickX The x component of the right joystick
  71845. * @param rightStickY The y component of the right joystick
  71846. */
  71847. constructor(
  71848. /**
  71849. * The id of the gamepad
  71850. */
  71851. id: string,
  71852. /**
  71853. * The index of the gamepad
  71854. */
  71855. index: number,
  71856. /**
  71857. * The browser gamepad
  71858. */
  71859. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71860. /**
  71861. * Callback triggered when the left joystick has changed
  71862. * @param callback
  71863. */
  71864. onleftstickchanged(callback: (values: StickValues) => void): void;
  71865. /**
  71866. * Callback triggered when the right joystick has changed
  71867. * @param callback
  71868. */
  71869. onrightstickchanged(callback: (values: StickValues) => void): void;
  71870. /**
  71871. * Gets the left joystick
  71872. */
  71873. /**
  71874. * Sets the left joystick values
  71875. */
  71876. leftStick: StickValues;
  71877. /**
  71878. * Gets the right joystick
  71879. */
  71880. /**
  71881. * Sets the right joystick value
  71882. */
  71883. rightStick: StickValues;
  71884. /**
  71885. * Updates the gamepad joystick positions
  71886. */
  71887. update(): void;
  71888. /**
  71889. * Disposes the gamepad
  71890. */
  71891. dispose(): void;
  71892. }
  71893. /**
  71894. * Represents a generic gamepad
  71895. */
  71896. export class GenericPad extends Gamepad {
  71897. private _buttons;
  71898. private _onbuttondown;
  71899. private _onbuttonup;
  71900. /**
  71901. * Observable triggered when a button has been pressed
  71902. */
  71903. onButtonDownObservable: Observable<number>;
  71904. /**
  71905. * Observable triggered when a button has been released
  71906. */
  71907. onButtonUpObservable: Observable<number>;
  71908. /**
  71909. * Callback triggered when a button has been pressed
  71910. * @param callback Called when a button has been pressed
  71911. */
  71912. onbuttondown(callback: (buttonPressed: number) => void): void;
  71913. /**
  71914. * Callback triggered when a button has been released
  71915. * @param callback Called when a button has been released
  71916. */
  71917. onbuttonup(callback: (buttonReleased: number) => void): void;
  71918. /**
  71919. * Initializes the generic gamepad
  71920. * @param id The id of the generic gamepad
  71921. * @param index The index of the generic gamepad
  71922. * @param browserGamepad The browser gamepad
  71923. */
  71924. constructor(id: string, index: number, browserGamepad: any);
  71925. private _setButtonValue;
  71926. /**
  71927. * Updates the generic gamepad
  71928. */
  71929. update(): void;
  71930. /**
  71931. * Disposes the generic gamepad
  71932. */
  71933. dispose(): void;
  71934. }
  71935. }
  71936. declare module BABYLON {
  71937. /**
  71938. * Defines the types of pose enabled controllers that are supported
  71939. */
  71940. export enum PoseEnabledControllerType {
  71941. /**
  71942. * HTC Vive
  71943. */
  71944. VIVE = 0,
  71945. /**
  71946. * Oculus Rift
  71947. */
  71948. OCULUS = 1,
  71949. /**
  71950. * Windows mixed reality
  71951. */
  71952. WINDOWS = 2,
  71953. /**
  71954. * Samsung gear VR
  71955. */
  71956. GEAR_VR = 3,
  71957. /**
  71958. * Google Daydream
  71959. */
  71960. DAYDREAM = 4,
  71961. /**
  71962. * Generic
  71963. */
  71964. GENERIC = 5
  71965. }
  71966. /**
  71967. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71968. */
  71969. export interface MutableGamepadButton {
  71970. /**
  71971. * Value of the button/trigger
  71972. */
  71973. value: number;
  71974. /**
  71975. * If the button/trigger is currently touched
  71976. */
  71977. touched: boolean;
  71978. /**
  71979. * If the button/trigger is currently pressed
  71980. */
  71981. pressed: boolean;
  71982. }
  71983. /**
  71984. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71985. * @hidden
  71986. */
  71987. export interface ExtendedGamepadButton extends GamepadButton {
  71988. /**
  71989. * If the button/trigger is currently pressed
  71990. */
  71991. readonly pressed: boolean;
  71992. /**
  71993. * If the button/trigger is currently touched
  71994. */
  71995. readonly touched: boolean;
  71996. /**
  71997. * Value of the button/trigger
  71998. */
  71999. readonly value: number;
  72000. }
  72001. /** @hidden */
  72002. export interface _GamePadFactory {
  72003. /**
  72004. * Returns wether or not the current gamepad can be created for this type of controller.
  72005. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72006. * @returns true if it can be created, otherwise false
  72007. */
  72008. canCreate(gamepadInfo: any): boolean;
  72009. /**
  72010. * Creates a new instance of the Gamepad.
  72011. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72012. * @returns the new gamepad instance
  72013. */
  72014. create(gamepadInfo: any): Gamepad;
  72015. }
  72016. /**
  72017. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72018. */
  72019. export class PoseEnabledControllerHelper {
  72020. /** @hidden */
  72021. static _ControllerFactories: _GamePadFactory[];
  72022. /** @hidden */
  72023. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72024. /**
  72025. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72026. * @param vrGamepad the gamepad to initialized
  72027. * @returns a vr controller of the type the gamepad identified as
  72028. */
  72029. static InitiateController(vrGamepad: any): Gamepad;
  72030. }
  72031. /**
  72032. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72033. */
  72034. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72035. private _deviceRoomPosition;
  72036. private _deviceRoomRotationQuaternion;
  72037. /**
  72038. * The device position in babylon space
  72039. */
  72040. devicePosition: Vector3;
  72041. /**
  72042. * The device rotation in babylon space
  72043. */
  72044. deviceRotationQuaternion: Quaternion;
  72045. /**
  72046. * The scale factor of the device in babylon space
  72047. */
  72048. deviceScaleFactor: number;
  72049. /**
  72050. * (Likely devicePosition should be used instead) The device position in its room space
  72051. */
  72052. position: Vector3;
  72053. /**
  72054. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72055. */
  72056. rotationQuaternion: Quaternion;
  72057. /**
  72058. * The type of controller (Eg. Windows mixed reality)
  72059. */
  72060. controllerType: PoseEnabledControllerType;
  72061. protected _calculatedPosition: Vector3;
  72062. private _calculatedRotation;
  72063. /**
  72064. * The raw pose from the device
  72065. */
  72066. rawPose: DevicePose;
  72067. private _trackPosition;
  72068. private _maxRotationDistFromHeadset;
  72069. private _draggedRoomRotation;
  72070. /**
  72071. * @hidden
  72072. */
  72073. _disableTrackPosition(fixedPosition: Vector3): void;
  72074. /**
  72075. * Internal, the mesh attached to the controller
  72076. * @hidden
  72077. */
  72078. _mesh: Nullable<AbstractMesh>;
  72079. private _poseControlledCamera;
  72080. private _leftHandSystemQuaternion;
  72081. /**
  72082. * Internal, matrix used to convert room space to babylon space
  72083. * @hidden
  72084. */
  72085. _deviceToWorld: Matrix;
  72086. /**
  72087. * Node to be used when casting a ray from the controller
  72088. * @hidden
  72089. */
  72090. _pointingPoseNode: Nullable<TransformNode>;
  72091. /**
  72092. * Name of the child mesh that can be used to cast a ray from the controller
  72093. */
  72094. static readonly POINTING_POSE: string;
  72095. /**
  72096. * Creates a new PoseEnabledController from a gamepad
  72097. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72098. */
  72099. constructor(browserGamepad: any);
  72100. private _workingMatrix;
  72101. /**
  72102. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72103. */
  72104. update(): void;
  72105. /**
  72106. * Updates only the pose device and mesh without doing any button event checking
  72107. */
  72108. protected _updatePoseAndMesh(): void;
  72109. /**
  72110. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72111. * @param poseData raw pose fromthe device
  72112. */
  72113. updateFromDevice(poseData: DevicePose): void;
  72114. /**
  72115. * @hidden
  72116. */
  72117. _meshAttachedObservable: Observable<AbstractMesh>;
  72118. /**
  72119. * Attaches a mesh to the controller
  72120. * @param mesh the mesh to be attached
  72121. */
  72122. attachToMesh(mesh: AbstractMesh): void;
  72123. /**
  72124. * Attaches the controllers mesh to a camera
  72125. * @param camera the camera the mesh should be attached to
  72126. */
  72127. attachToPoseControlledCamera(camera: TargetCamera): void;
  72128. /**
  72129. * Disposes of the controller
  72130. */
  72131. dispose(): void;
  72132. /**
  72133. * The mesh that is attached to the controller
  72134. */
  72135. readonly mesh: Nullable<AbstractMesh>;
  72136. /**
  72137. * Gets the ray of the controller in the direction the controller is pointing
  72138. * @param length the length the resulting ray should be
  72139. * @returns a ray in the direction the controller is pointing
  72140. */
  72141. getForwardRay(length?: number): Ray;
  72142. }
  72143. }
  72144. declare module BABYLON {
  72145. /**
  72146. * Defines the WebVRController object that represents controllers tracked in 3D space
  72147. */
  72148. export abstract class WebVRController extends PoseEnabledController {
  72149. /**
  72150. * Internal, the default controller model for the controller
  72151. */
  72152. protected _defaultModel: AbstractMesh;
  72153. /**
  72154. * Fired when the trigger state has changed
  72155. */
  72156. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72157. /**
  72158. * Fired when the main button state has changed
  72159. */
  72160. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72161. /**
  72162. * Fired when the secondary button state has changed
  72163. */
  72164. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72165. /**
  72166. * Fired when the pad state has changed
  72167. */
  72168. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72169. /**
  72170. * Fired when controllers stick values have changed
  72171. */
  72172. onPadValuesChangedObservable: Observable<StickValues>;
  72173. /**
  72174. * Array of button availible on the controller
  72175. */
  72176. protected _buttons: Array<MutableGamepadButton>;
  72177. private _onButtonStateChange;
  72178. /**
  72179. * Fired when a controller button's state has changed
  72180. * @param callback the callback containing the button that was modified
  72181. */
  72182. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72183. /**
  72184. * X and Y axis corrisponding to the controllers joystick
  72185. */
  72186. pad: StickValues;
  72187. /**
  72188. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72189. */
  72190. hand: string;
  72191. /**
  72192. * The default controller model for the controller
  72193. */
  72194. readonly defaultModel: AbstractMesh;
  72195. /**
  72196. * Creates a new WebVRController from a gamepad
  72197. * @param vrGamepad the gamepad that the WebVRController should be created from
  72198. */
  72199. constructor(vrGamepad: any);
  72200. /**
  72201. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72202. */
  72203. update(): void;
  72204. /**
  72205. * Function to be called when a button is modified
  72206. */
  72207. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72208. /**
  72209. * Loads a mesh and attaches it to the controller
  72210. * @param scene the scene the mesh should be added to
  72211. * @param meshLoaded callback for when the mesh has been loaded
  72212. */
  72213. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72214. private _setButtonValue;
  72215. private _changes;
  72216. private _checkChanges;
  72217. /**
  72218. * Disposes of th webVRCOntroller
  72219. */
  72220. dispose(): void;
  72221. }
  72222. }
  72223. declare module BABYLON {
  72224. /**
  72225. * The HemisphericLight simulates the ambient environment light,
  72226. * so the passed direction is the light reflection direction, not the incoming direction.
  72227. */
  72228. export class HemisphericLight extends Light {
  72229. /**
  72230. * The groundColor is the light in the opposite direction to the one specified during creation.
  72231. * 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.
  72232. */
  72233. groundColor: Color3;
  72234. /**
  72235. * The light reflection direction, not the incoming direction.
  72236. */
  72237. direction: Vector3;
  72238. /**
  72239. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72240. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72241. * The HemisphericLight can't cast shadows.
  72242. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72243. * @param name The friendly name of the light
  72244. * @param direction The direction of the light reflection
  72245. * @param scene The scene the light belongs to
  72246. */
  72247. constructor(name: string, direction: Vector3, scene: Scene);
  72248. protected _buildUniformLayout(): void;
  72249. /**
  72250. * Returns the string "HemisphericLight".
  72251. * @return The class name
  72252. */
  72253. getClassName(): string;
  72254. /**
  72255. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72256. * Returns the updated direction.
  72257. * @param target The target the direction should point to
  72258. * @return The computed direction
  72259. */
  72260. setDirectionToTarget(target: Vector3): Vector3;
  72261. /**
  72262. * Returns the shadow generator associated to the light.
  72263. * @returns Always null for hemispheric lights because it does not support shadows.
  72264. */
  72265. getShadowGenerator(): Nullable<IShadowGenerator>;
  72266. /**
  72267. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72268. * @param effect The effect to update
  72269. * @param lightIndex The index of the light in the effect to update
  72270. * @returns The hemispheric light
  72271. */
  72272. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72273. /**
  72274. * Computes the world matrix of the node
  72275. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72276. * @param useWasUpdatedFlag defines a reserved property
  72277. * @returns the world matrix
  72278. */
  72279. computeWorldMatrix(): Matrix;
  72280. /**
  72281. * Returns the integer 3.
  72282. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72283. */
  72284. getTypeID(): number;
  72285. /**
  72286. * Prepares the list of defines specific to the light type.
  72287. * @param defines the list of defines
  72288. * @param lightIndex defines the index of the light for the effect
  72289. */
  72290. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72291. }
  72292. }
  72293. declare module BABYLON {
  72294. /** @hidden */
  72295. export var vrMultiviewToSingleviewPixelShader: {
  72296. name: string;
  72297. shader: string;
  72298. };
  72299. }
  72300. declare module BABYLON {
  72301. /**
  72302. * Renders to multiple views with a single draw call
  72303. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72304. */
  72305. export class MultiviewRenderTarget extends RenderTargetTexture {
  72306. /**
  72307. * Creates a multiview render target
  72308. * @param scene scene used with the render target
  72309. * @param size the size of the render target (used for each view)
  72310. */
  72311. constructor(scene: Scene, size?: number | {
  72312. width: number;
  72313. height: number;
  72314. } | {
  72315. ratio: number;
  72316. });
  72317. /**
  72318. * @hidden
  72319. * @param faceIndex the face index, if its a cube texture
  72320. */
  72321. _bindFrameBuffer(faceIndex?: number): void;
  72322. /**
  72323. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72324. * @returns the view count
  72325. */
  72326. getViewCount(): number;
  72327. }
  72328. }
  72329. declare module BABYLON {
  72330. interface Engine {
  72331. /**
  72332. * Creates a new multiview render target
  72333. * @param width defines the width of the texture
  72334. * @param height defines the height of the texture
  72335. * @returns the created multiview texture
  72336. */
  72337. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72338. /**
  72339. * Binds a multiview framebuffer to be drawn to
  72340. * @param multiviewTexture texture to bind
  72341. */
  72342. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72343. }
  72344. interface Camera {
  72345. /**
  72346. * @hidden
  72347. * 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)
  72348. */
  72349. _useMultiviewToSingleView: boolean;
  72350. /**
  72351. * @hidden
  72352. * 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)
  72353. */
  72354. _multiviewTexture: Nullable<RenderTargetTexture>;
  72355. /**
  72356. * @hidden
  72357. * ensures the multiview texture of the camera exists and has the specified width/height
  72358. * @param width height to set on the multiview texture
  72359. * @param height width to set on the multiview texture
  72360. */
  72361. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72362. }
  72363. interface Scene {
  72364. /** @hidden */
  72365. _transformMatrixR: Matrix;
  72366. /** @hidden */
  72367. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72368. /** @hidden */
  72369. _createMultiviewUbo(): void;
  72370. /** @hidden */
  72371. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72372. /** @hidden */
  72373. _renderMultiviewToSingleView(camera: Camera): void;
  72374. }
  72375. }
  72376. declare module BABYLON {
  72377. /**
  72378. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72379. * This will not be used for webXR as it supports displaying texture arrays directly
  72380. */
  72381. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72382. /**
  72383. * Initializes a VRMultiviewToSingleview
  72384. * @param name name of the post process
  72385. * @param camera camera to be applied to
  72386. * @param scaleFactor scaling factor to the size of the output texture
  72387. */
  72388. constructor(name: string, camera: Camera, scaleFactor: number);
  72389. }
  72390. }
  72391. declare module BABYLON {
  72392. /**
  72393. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72394. * IMPORTANT!! The data is right-hand data.
  72395. * @export
  72396. * @interface DevicePose
  72397. */
  72398. export interface DevicePose {
  72399. /**
  72400. * The position of the device, values in array are [x,y,z].
  72401. */
  72402. readonly position: Nullable<Float32Array>;
  72403. /**
  72404. * The linearVelocity of the device, values in array are [x,y,z].
  72405. */
  72406. readonly linearVelocity: Nullable<Float32Array>;
  72407. /**
  72408. * The linearAcceleration of the device, values in array are [x,y,z].
  72409. */
  72410. readonly linearAcceleration: Nullable<Float32Array>;
  72411. /**
  72412. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72413. */
  72414. readonly orientation: Nullable<Float32Array>;
  72415. /**
  72416. * The angularVelocity of the device, values in array are [x,y,z].
  72417. */
  72418. readonly angularVelocity: Nullable<Float32Array>;
  72419. /**
  72420. * The angularAcceleration of the device, values in array are [x,y,z].
  72421. */
  72422. readonly angularAcceleration: Nullable<Float32Array>;
  72423. }
  72424. /**
  72425. * Interface representing a pose controlled object in Babylon.
  72426. * A pose controlled object has both regular pose values as well as pose values
  72427. * from an external device such as a VR head mounted display
  72428. */
  72429. export interface PoseControlled {
  72430. /**
  72431. * The position of the object in babylon space.
  72432. */
  72433. position: Vector3;
  72434. /**
  72435. * The rotation quaternion of the object in babylon space.
  72436. */
  72437. rotationQuaternion: Quaternion;
  72438. /**
  72439. * The position of the device in babylon space.
  72440. */
  72441. devicePosition?: Vector3;
  72442. /**
  72443. * The rotation quaternion of the device in babylon space.
  72444. */
  72445. deviceRotationQuaternion: Quaternion;
  72446. /**
  72447. * The raw pose coming from the device.
  72448. */
  72449. rawPose: Nullable<DevicePose>;
  72450. /**
  72451. * The scale of the device to be used when translating from device space to babylon space.
  72452. */
  72453. deviceScaleFactor: number;
  72454. /**
  72455. * Updates the poseControlled values based on the input device pose.
  72456. * @param poseData the pose data to update the object with
  72457. */
  72458. updateFromDevice(poseData: DevicePose): void;
  72459. }
  72460. /**
  72461. * Set of options to customize the webVRCamera
  72462. */
  72463. export interface WebVROptions {
  72464. /**
  72465. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72466. */
  72467. trackPosition?: boolean;
  72468. /**
  72469. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72470. */
  72471. positionScale?: number;
  72472. /**
  72473. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72474. */
  72475. displayName?: string;
  72476. /**
  72477. * Should the native controller meshes be initialized. (default: true)
  72478. */
  72479. controllerMeshes?: boolean;
  72480. /**
  72481. * Creating a default HemiLight only on controllers. (default: true)
  72482. */
  72483. defaultLightingOnControllers?: boolean;
  72484. /**
  72485. * If you don't want to use the default VR button of the helper. (default: false)
  72486. */
  72487. useCustomVRButton?: boolean;
  72488. /**
  72489. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72490. */
  72491. customVRButton?: HTMLButtonElement;
  72492. /**
  72493. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72494. */
  72495. rayLength?: number;
  72496. /**
  72497. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72498. */
  72499. defaultHeight?: number;
  72500. /**
  72501. * If multiview should be used if availible (default: false)
  72502. */
  72503. useMultiview?: boolean;
  72504. }
  72505. /**
  72506. * This represents a WebVR camera.
  72507. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72508. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72509. */
  72510. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72511. private webVROptions;
  72512. /**
  72513. * @hidden
  72514. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72515. */
  72516. _vrDevice: any;
  72517. /**
  72518. * The rawPose of the vrDevice.
  72519. */
  72520. rawPose: Nullable<DevicePose>;
  72521. private _onVREnabled;
  72522. private _specsVersion;
  72523. private _attached;
  72524. private _frameData;
  72525. protected _descendants: Array<Node>;
  72526. private _deviceRoomPosition;
  72527. /** @hidden */
  72528. _deviceRoomRotationQuaternion: Quaternion;
  72529. private _standingMatrix;
  72530. /**
  72531. * Represents device position in babylon space.
  72532. */
  72533. devicePosition: Vector3;
  72534. /**
  72535. * Represents device rotation in babylon space.
  72536. */
  72537. deviceRotationQuaternion: Quaternion;
  72538. /**
  72539. * The scale of the device to be used when translating from device space to babylon space.
  72540. */
  72541. deviceScaleFactor: number;
  72542. private _deviceToWorld;
  72543. private _worldToDevice;
  72544. /**
  72545. * References to the webVR controllers for the vrDevice.
  72546. */
  72547. controllers: Array<WebVRController>;
  72548. /**
  72549. * Emits an event when a controller is attached.
  72550. */
  72551. onControllersAttachedObservable: Observable<WebVRController[]>;
  72552. /**
  72553. * Emits an event when a controller's mesh has been loaded;
  72554. */
  72555. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72556. /**
  72557. * Emits an event when the HMD's pose has been updated.
  72558. */
  72559. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72560. private _poseSet;
  72561. /**
  72562. * If the rig cameras be used as parent instead of this camera.
  72563. */
  72564. rigParenting: boolean;
  72565. private _lightOnControllers;
  72566. private _defaultHeight?;
  72567. /**
  72568. * Instantiates a WebVRFreeCamera.
  72569. * @param name The name of the WebVRFreeCamera
  72570. * @param position The starting anchor position for the camera
  72571. * @param scene The scene the camera belongs to
  72572. * @param webVROptions a set of customizable options for the webVRCamera
  72573. */
  72574. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72575. /**
  72576. * Gets the device distance from the ground in meters.
  72577. * @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.
  72578. */
  72579. deviceDistanceToRoomGround(): number;
  72580. /**
  72581. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72582. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72583. */
  72584. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72585. /**
  72586. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72587. * @returns A promise with a boolean set to if the standing matrix is supported.
  72588. */
  72589. useStandingMatrixAsync(): Promise<boolean>;
  72590. /**
  72591. * Disposes the camera
  72592. */
  72593. dispose(): void;
  72594. /**
  72595. * Gets a vrController by name.
  72596. * @param name The name of the controller to retreive
  72597. * @returns the controller matching the name specified or null if not found
  72598. */
  72599. getControllerByName(name: string): Nullable<WebVRController>;
  72600. private _leftController;
  72601. /**
  72602. * The controller corrisponding to the users left hand.
  72603. */
  72604. readonly leftController: Nullable<WebVRController>;
  72605. private _rightController;
  72606. /**
  72607. * The controller corrisponding to the users right hand.
  72608. */
  72609. readonly rightController: Nullable<WebVRController>;
  72610. /**
  72611. * Casts a ray forward from the vrCamera's gaze.
  72612. * @param length Length of the ray (default: 100)
  72613. * @returns the ray corrisponding to the gaze
  72614. */
  72615. getForwardRay(length?: number): Ray;
  72616. /**
  72617. * @hidden
  72618. * Updates the camera based on device's frame data
  72619. */
  72620. _checkInputs(): void;
  72621. /**
  72622. * Updates the poseControlled values based on the input device pose.
  72623. * @param poseData Pose coming from the device
  72624. */
  72625. updateFromDevice(poseData: DevicePose): void;
  72626. private _htmlElementAttached;
  72627. private _detachIfAttached;
  72628. /**
  72629. * WebVR's attach control will start broadcasting frames to the device.
  72630. * Note that in certain browsers (chrome for example) this function must be called
  72631. * within a user-interaction callback. Example:
  72632. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72633. *
  72634. * @param element html element to attach the vrDevice to
  72635. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72636. */
  72637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72638. /**
  72639. * Detaches the camera from the html element and disables VR
  72640. *
  72641. * @param element html element to detach from
  72642. */
  72643. detachControl(element: HTMLElement): void;
  72644. /**
  72645. * @returns the name of this class
  72646. */
  72647. getClassName(): string;
  72648. /**
  72649. * Calls resetPose on the vrDisplay
  72650. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72651. */
  72652. resetToCurrentRotation(): void;
  72653. /**
  72654. * @hidden
  72655. * Updates the rig cameras (left and right eye)
  72656. */
  72657. _updateRigCameras(): void;
  72658. private _workingVector;
  72659. private _oneVector;
  72660. private _workingMatrix;
  72661. private updateCacheCalled;
  72662. private _correctPositionIfNotTrackPosition;
  72663. /**
  72664. * @hidden
  72665. * Updates the cached values of the camera
  72666. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72667. */
  72668. _updateCache(ignoreParentClass?: boolean): void;
  72669. /**
  72670. * @hidden
  72671. * Get current device position in babylon world
  72672. */
  72673. _computeDevicePosition(): void;
  72674. /**
  72675. * Updates the current device position and rotation in the babylon world
  72676. */
  72677. update(): void;
  72678. /**
  72679. * @hidden
  72680. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72681. * @returns an identity matrix
  72682. */
  72683. _getViewMatrix(): Matrix;
  72684. private _tmpMatrix;
  72685. /**
  72686. * This function is called by the two RIG cameras.
  72687. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72688. * @hidden
  72689. */
  72690. _getWebVRViewMatrix(): Matrix;
  72691. /** @hidden */
  72692. _getWebVRProjectionMatrix(): Matrix;
  72693. private _onGamepadConnectedObserver;
  72694. private _onGamepadDisconnectedObserver;
  72695. private _updateCacheWhenTrackingDisabledObserver;
  72696. /**
  72697. * Initializes the controllers and their meshes
  72698. */
  72699. initControllers(): void;
  72700. }
  72701. }
  72702. declare module BABYLON {
  72703. /**
  72704. * Size options for a post process
  72705. */
  72706. export type PostProcessOptions = {
  72707. width: number;
  72708. height: number;
  72709. };
  72710. /**
  72711. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72712. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72713. */
  72714. export class PostProcess {
  72715. /** Name of the PostProcess. */
  72716. name: string;
  72717. /**
  72718. * Gets or sets the unique id of the post process
  72719. */
  72720. uniqueId: number;
  72721. /**
  72722. * Width of the texture to apply the post process on
  72723. */
  72724. width: number;
  72725. /**
  72726. * Height of the texture to apply the post process on
  72727. */
  72728. height: number;
  72729. /**
  72730. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72731. * @hidden
  72732. */
  72733. _outputTexture: Nullable<InternalTexture>;
  72734. /**
  72735. * Sampling mode used by the shader
  72736. * See https://doc.babylonjs.com/classes/3.1/texture
  72737. */
  72738. renderTargetSamplingMode: number;
  72739. /**
  72740. * Clear color to use when screen clearing
  72741. */
  72742. clearColor: Color4;
  72743. /**
  72744. * If the buffer needs to be cleared before applying the post process. (default: true)
  72745. * Should be set to false if shader will overwrite all previous pixels.
  72746. */
  72747. autoClear: boolean;
  72748. /**
  72749. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72750. */
  72751. alphaMode: number;
  72752. /**
  72753. * Sets the setAlphaBlendConstants of the babylon engine
  72754. */
  72755. alphaConstants: Color4;
  72756. /**
  72757. * Animations to be used for the post processing
  72758. */
  72759. animations: Animation[];
  72760. /**
  72761. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72762. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72763. */
  72764. enablePixelPerfectMode: boolean;
  72765. /**
  72766. * Force the postprocess to be applied without taking in account viewport
  72767. */
  72768. forceFullscreenViewport: boolean;
  72769. /**
  72770. * List of inspectable custom properties (used by the Inspector)
  72771. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72772. */
  72773. inspectableCustomProperties: IInspectable[];
  72774. /**
  72775. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72776. *
  72777. * | Value | Type | Description |
  72778. * | ----- | ----------------------------------- | ----------- |
  72779. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72780. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72781. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72782. *
  72783. */
  72784. scaleMode: number;
  72785. /**
  72786. * Force textures to be a power of two (default: false)
  72787. */
  72788. alwaysForcePOT: boolean;
  72789. private _samples;
  72790. /**
  72791. * Number of sample textures (default: 1)
  72792. */
  72793. samples: number;
  72794. /**
  72795. * Modify the scale of the post process to be the same as the viewport (default: false)
  72796. */
  72797. adaptScaleToCurrentViewport: boolean;
  72798. private _camera;
  72799. private _scene;
  72800. private _engine;
  72801. private _options;
  72802. private _reusable;
  72803. private _textureType;
  72804. /**
  72805. * Smart array of input and output textures for the post process.
  72806. * @hidden
  72807. */
  72808. _textures: SmartArray<InternalTexture>;
  72809. /**
  72810. * The index in _textures that corresponds to the output texture.
  72811. * @hidden
  72812. */
  72813. _currentRenderTextureInd: number;
  72814. private _effect;
  72815. private _samplers;
  72816. private _fragmentUrl;
  72817. private _vertexUrl;
  72818. private _parameters;
  72819. private _scaleRatio;
  72820. protected _indexParameters: any;
  72821. private _shareOutputWithPostProcess;
  72822. private _texelSize;
  72823. private _forcedOutputTexture;
  72824. /**
  72825. * Returns the fragment url or shader name used in the post process.
  72826. * @returns the fragment url or name in the shader store.
  72827. */
  72828. getEffectName(): string;
  72829. /**
  72830. * An event triggered when the postprocess is activated.
  72831. */
  72832. onActivateObservable: Observable<Camera>;
  72833. private _onActivateObserver;
  72834. /**
  72835. * A function that is added to the onActivateObservable
  72836. */
  72837. onActivate: Nullable<(camera: Camera) => void>;
  72838. /**
  72839. * An event triggered when the postprocess changes its size.
  72840. */
  72841. onSizeChangedObservable: Observable<PostProcess>;
  72842. private _onSizeChangedObserver;
  72843. /**
  72844. * A function that is added to the onSizeChangedObservable
  72845. */
  72846. onSizeChanged: (postProcess: PostProcess) => void;
  72847. /**
  72848. * An event triggered when the postprocess applies its effect.
  72849. */
  72850. onApplyObservable: Observable<Effect>;
  72851. private _onApplyObserver;
  72852. /**
  72853. * A function that is added to the onApplyObservable
  72854. */
  72855. onApply: (effect: Effect) => void;
  72856. /**
  72857. * An event triggered before rendering the postprocess
  72858. */
  72859. onBeforeRenderObservable: Observable<Effect>;
  72860. private _onBeforeRenderObserver;
  72861. /**
  72862. * A function that is added to the onBeforeRenderObservable
  72863. */
  72864. onBeforeRender: (effect: Effect) => void;
  72865. /**
  72866. * An event triggered after rendering the postprocess
  72867. */
  72868. onAfterRenderObservable: Observable<Effect>;
  72869. private _onAfterRenderObserver;
  72870. /**
  72871. * A function that is added to the onAfterRenderObservable
  72872. */
  72873. onAfterRender: (efect: Effect) => void;
  72874. /**
  72875. * 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
  72876. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72877. */
  72878. inputTexture: InternalTexture;
  72879. /**
  72880. * Gets the camera which post process is applied to.
  72881. * @returns The camera the post process is applied to.
  72882. */
  72883. getCamera(): Camera;
  72884. /**
  72885. * Gets the texel size of the postprocess.
  72886. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72887. */
  72888. readonly texelSize: Vector2;
  72889. /**
  72890. * Creates a new instance PostProcess
  72891. * @param name The name of the PostProcess.
  72892. * @param fragmentUrl The url of the fragment shader to be used.
  72893. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72894. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72895. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72896. * @param camera The camera to apply the render pass to.
  72897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72898. * @param engine The engine which the post process will be applied. (default: current engine)
  72899. * @param reusable If the post process can be reused on the same frame. (default: false)
  72900. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72901. * @param textureType Type of textures used when performing the post process. (default: 0)
  72902. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72903. * @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
  72904. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72905. */
  72906. constructor(
  72907. /** Name of the PostProcess. */
  72908. 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);
  72909. /**
  72910. * Gets a string idenfifying the name of the class
  72911. * @returns "PostProcess" string
  72912. */
  72913. getClassName(): string;
  72914. /**
  72915. * Gets the engine which this post process belongs to.
  72916. * @returns The engine the post process was enabled with.
  72917. */
  72918. getEngine(): Engine;
  72919. /**
  72920. * The effect that is created when initializing the post process.
  72921. * @returns The created effect corrisponding the the postprocess.
  72922. */
  72923. getEffect(): Effect;
  72924. /**
  72925. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72926. * @param postProcess The post process to share the output with.
  72927. * @returns This post process.
  72928. */
  72929. shareOutputWith(postProcess: PostProcess): PostProcess;
  72930. /**
  72931. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72932. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72933. */
  72934. useOwnOutput(): void;
  72935. /**
  72936. * Updates the effect with the current post process compile time values and recompiles the shader.
  72937. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72938. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72939. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72940. * @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
  72941. * @param onCompiled Called when the shader has been compiled.
  72942. * @param onError Called if there is an error when compiling a shader.
  72943. */
  72944. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72945. /**
  72946. * The post process is reusable if it can be used multiple times within one frame.
  72947. * @returns If the post process is reusable
  72948. */
  72949. isReusable(): boolean;
  72950. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72951. markTextureDirty(): void;
  72952. /**
  72953. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72954. * 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.
  72955. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72956. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72957. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72958. * @returns The target texture that was bound to be written to.
  72959. */
  72960. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72961. /**
  72962. * If the post process is supported.
  72963. */
  72964. readonly isSupported: boolean;
  72965. /**
  72966. * The aspect ratio of the output texture.
  72967. */
  72968. readonly aspectRatio: number;
  72969. /**
  72970. * Get a value indicating if the post-process is ready to be used
  72971. * @returns true if the post-process is ready (shader is compiled)
  72972. */
  72973. isReady(): boolean;
  72974. /**
  72975. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72976. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72977. */
  72978. apply(): Nullable<Effect>;
  72979. private _disposeTextures;
  72980. /**
  72981. * Disposes the post process.
  72982. * @param camera The camera to dispose the post process on.
  72983. */
  72984. dispose(camera?: Camera): void;
  72985. }
  72986. }
  72987. declare module BABYLON {
  72988. /**
  72989. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72990. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72991. */
  72992. export class PostProcessManager {
  72993. private _scene;
  72994. private _indexBuffer;
  72995. private _vertexBuffers;
  72996. /**
  72997. * Creates a new instance PostProcess
  72998. * @param scene The scene that the post process is associated with.
  72999. */
  73000. constructor(scene: Scene);
  73001. private _prepareBuffers;
  73002. private _buildIndexBuffer;
  73003. /**
  73004. * Rebuilds the vertex buffers of the manager.
  73005. * @hidden
  73006. */
  73007. _rebuild(): void;
  73008. /**
  73009. * Prepares a frame to be run through a post process.
  73010. * @param sourceTexture The input texture to the post procesess. (default: null)
  73011. * @param postProcesses An array of post processes to be run. (default: null)
  73012. * @returns True if the post processes were able to be run.
  73013. * @hidden
  73014. */
  73015. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73016. /**
  73017. * Manually render a set of post processes to a texture.
  73018. * @param postProcesses An array of post processes to be run.
  73019. * @param targetTexture The target texture to render to.
  73020. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73021. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73022. * @param lodLevel defines which lod of the texture to render to
  73023. */
  73024. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73025. /**
  73026. * Finalize the result of the output of the postprocesses.
  73027. * @param doNotPresent If true the result will not be displayed to the screen.
  73028. * @param targetTexture The target texture to render to.
  73029. * @param faceIndex The index of the face to bind the target texture to.
  73030. * @param postProcesses The array of post processes to render.
  73031. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73032. * @hidden
  73033. */
  73034. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73035. /**
  73036. * Disposes of the post process manager.
  73037. */
  73038. dispose(): void;
  73039. }
  73040. }
  73041. declare module BABYLON {
  73042. interface AbstractScene {
  73043. /**
  73044. * The list of layers (background and foreground) of the scene
  73045. */
  73046. layers: Array<Layer>;
  73047. }
  73048. /**
  73049. * Defines the layer scene component responsible to manage any layers
  73050. * in a given scene.
  73051. */
  73052. export class LayerSceneComponent implements ISceneComponent {
  73053. /**
  73054. * The component name helpfull to identify the component in the list of scene components.
  73055. */
  73056. readonly name: string;
  73057. /**
  73058. * The scene the component belongs to.
  73059. */
  73060. scene: Scene;
  73061. private _engine;
  73062. /**
  73063. * Creates a new instance of the component for the given scene
  73064. * @param scene Defines the scene to register the component in
  73065. */
  73066. constructor(scene: Scene);
  73067. /**
  73068. * Registers the component in a given scene
  73069. */
  73070. register(): void;
  73071. /**
  73072. * Rebuilds the elements related to this component in case of
  73073. * context lost for instance.
  73074. */
  73075. rebuild(): void;
  73076. /**
  73077. * Disposes the component and the associated ressources.
  73078. */
  73079. dispose(): void;
  73080. private _draw;
  73081. private _drawCameraPredicate;
  73082. private _drawCameraBackground;
  73083. private _drawCameraForeground;
  73084. private _drawRenderTargetPredicate;
  73085. private _drawRenderTargetBackground;
  73086. private _drawRenderTargetForeground;
  73087. }
  73088. }
  73089. declare module BABYLON {
  73090. /** @hidden */
  73091. export var layerPixelShader: {
  73092. name: string;
  73093. shader: string;
  73094. };
  73095. }
  73096. declare module BABYLON {
  73097. /** @hidden */
  73098. export var layerVertexShader: {
  73099. name: string;
  73100. shader: string;
  73101. };
  73102. }
  73103. declare module BABYLON {
  73104. /**
  73105. * This represents a full screen 2d layer.
  73106. * This can be useful to display a picture in the background of your scene for instance.
  73107. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73108. */
  73109. export class Layer {
  73110. /**
  73111. * Define the name of the layer.
  73112. */
  73113. name: string;
  73114. /**
  73115. * Define the texture the layer should display.
  73116. */
  73117. texture: Nullable<Texture>;
  73118. /**
  73119. * Is the layer in background or foreground.
  73120. */
  73121. isBackground: boolean;
  73122. /**
  73123. * Define the color of the layer (instead of texture).
  73124. */
  73125. color: Color4;
  73126. /**
  73127. * Define the scale of the layer in order to zoom in out of the texture.
  73128. */
  73129. scale: Vector2;
  73130. /**
  73131. * Define an offset for the layer in order to shift the texture.
  73132. */
  73133. offset: Vector2;
  73134. /**
  73135. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73136. */
  73137. alphaBlendingMode: number;
  73138. /**
  73139. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73140. * Alpha test will not mix with the background color in case of transparency.
  73141. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73142. */
  73143. alphaTest: boolean;
  73144. /**
  73145. * Define a mask to restrict the layer to only some of the scene cameras.
  73146. */
  73147. layerMask: number;
  73148. /**
  73149. * Define the list of render target the layer is visible into.
  73150. */
  73151. renderTargetTextures: RenderTargetTexture[];
  73152. /**
  73153. * Define if the layer is only used in renderTarget or if it also
  73154. * renders in the main frame buffer of the canvas.
  73155. */
  73156. renderOnlyInRenderTargetTextures: boolean;
  73157. private _scene;
  73158. private _vertexBuffers;
  73159. private _indexBuffer;
  73160. private _effect;
  73161. private _alphaTestEffect;
  73162. /**
  73163. * An event triggered when the layer is disposed.
  73164. */
  73165. onDisposeObservable: Observable<Layer>;
  73166. private _onDisposeObserver;
  73167. /**
  73168. * Back compatibility with callback before the onDisposeObservable existed.
  73169. * The set callback will be triggered when the layer has been disposed.
  73170. */
  73171. onDispose: () => void;
  73172. /**
  73173. * An event triggered before rendering the scene
  73174. */
  73175. onBeforeRenderObservable: Observable<Layer>;
  73176. private _onBeforeRenderObserver;
  73177. /**
  73178. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73179. * The set callback will be triggered just before rendering the layer.
  73180. */
  73181. onBeforeRender: () => void;
  73182. /**
  73183. * An event triggered after rendering the scene
  73184. */
  73185. onAfterRenderObservable: Observable<Layer>;
  73186. private _onAfterRenderObserver;
  73187. /**
  73188. * Back compatibility with callback before the onAfterRenderObservable existed.
  73189. * The set callback will be triggered just after rendering the layer.
  73190. */
  73191. onAfterRender: () => void;
  73192. /**
  73193. * Instantiates a new layer.
  73194. * This represents a full screen 2d layer.
  73195. * This can be useful to display a picture in the background of your scene for instance.
  73196. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73197. * @param name Define the name of the layer in the scene
  73198. * @param imgUrl Define the url of the texture to display in the layer
  73199. * @param scene Define the scene the layer belongs to
  73200. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73201. * @param color Defines a color for the layer
  73202. */
  73203. constructor(
  73204. /**
  73205. * Define the name of the layer.
  73206. */
  73207. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73208. private _createIndexBuffer;
  73209. /** @hidden */
  73210. _rebuild(): void;
  73211. /**
  73212. * Renders the layer in the scene.
  73213. */
  73214. render(): void;
  73215. /**
  73216. * Disposes and releases the associated ressources.
  73217. */
  73218. dispose(): void;
  73219. }
  73220. }
  73221. declare module BABYLON {
  73222. interface AbstractScene {
  73223. /**
  73224. * The list of procedural textures added to the scene
  73225. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73226. */
  73227. proceduralTextures: Array<ProceduralTexture>;
  73228. }
  73229. /**
  73230. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73231. * in a given scene.
  73232. */
  73233. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73234. /**
  73235. * The component name helpfull to identify the component in the list of scene components.
  73236. */
  73237. readonly name: string;
  73238. /**
  73239. * The scene the component belongs to.
  73240. */
  73241. scene: Scene;
  73242. /**
  73243. * Creates a new instance of the component for the given scene
  73244. * @param scene Defines the scene to register the component in
  73245. */
  73246. constructor(scene: Scene);
  73247. /**
  73248. * Registers the component in a given scene
  73249. */
  73250. register(): void;
  73251. /**
  73252. * Rebuilds the elements related to this component in case of
  73253. * context lost for instance.
  73254. */
  73255. rebuild(): void;
  73256. /**
  73257. * Disposes the component and the associated ressources.
  73258. */
  73259. dispose(): void;
  73260. private _beforeClear;
  73261. }
  73262. }
  73263. declare module BABYLON {
  73264. /** @hidden */
  73265. export var proceduralVertexShader: {
  73266. name: string;
  73267. shader: string;
  73268. };
  73269. }
  73270. declare module BABYLON {
  73271. /**
  73272. * 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.
  73273. * This is the base class of any Procedural texture and contains most of the shareable code.
  73274. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73275. */
  73276. export class ProceduralTexture extends Texture {
  73277. isCube: boolean;
  73278. /**
  73279. * Define if the texture is enabled or not (disabled texture will not render)
  73280. */
  73281. isEnabled: boolean;
  73282. /**
  73283. * Define if the texture must be cleared before rendering (default is true)
  73284. */
  73285. autoClear: boolean;
  73286. /**
  73287. * Callback called when the texture is generated
  73288. */
  73289. onGenerated: () => void;
  73290. /**
  73291. * Event raised when the texture is generated
  73292. */
  73293. onGeneratedObservable: Observable<ProceduralTexture>;
  73294. /** @hidden */
  73295. _generateMipMaps: boolean;
  73296. /** @hidden **/
  73297. _effect: Effect;
  73298. /** @hidden */
  73299. _textures: {
  73300. [key: string]: Texture;
  73301. };
  73302. private _size;
  73303. private _currentRefreshId;
  73304. private _refreshRate;
  73305. private _vertexBuffers;
  73306. private _indexBuffer;
  73307. private _uniforms;
  73308. private _samplers;
  73309. private _fragment;
  73310. private _floats;
  73311. private _ints;
  73312. private _floatsArrays;
  73313. private _colors3;
  73314. private _colors4;
  73315. private _vectors2;
  73316. private _vectors3;
  73317. private _matrices;
  73318. private _fallbackTexture;
  73319. private _fallbackTextureUsed;
  73320. private _engine;
  73321. private _cachedDefines;
  73322. private _contentUpdateId;
  73323. private _contentData;
  73324. /**
  73325. * Instantiates a new procedural texture.
  73326. * 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.
  73327. * This is the base class of any Procedural texture and contains most of the shareable code.
  73328. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73329. * @param name Define the name of the texture
  73330. * @param size Define the size of the texture to create
  73331. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73332. * @param scene Define the scene the texture belongs to
  73333. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73334. * @param generateMipMaps Define if the texture should creates mip maps or not
  73335. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73336. */
  73337. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73338. /**
  73339. * The effect that is created when initializing the post process.
  73340. * @returns The created effect corrisponding the the postprocess.
  73341. */
  73342. getEffect(): Effect;
  73343. /**
  73344. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73345. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73346. */
  73347. getContent(): Nullable<ArrayBufferView>;
  73348. private _createIndexBuffer;
  73349. /** @hidden */
  73350. _rebuild(): void;
  73351. /**
  73352. * Resets the texture in order to recreate its associated resources.
  73353. * This can be called in case of context loss
  73354. */
  73355. reset(): void;
  73356. protected _getDefines(): string;
  73357. /**
  73358. * Is the texture ready to be used ? (rendered at least once)
  73359. * @returns true if ready, otherwise, false.
  73360. */
  73361. isReady(): boolean;
  73362. /**
  73363. * Resets the refresh counter of the texture and start bak from scratch.
  73364. * Could be useful to regenerate the texture if it is setup to render only once.
  73365. */
  73366. resetRefreshCounter(): void;
  73367. /**
  73368. * Set the fragment shader to use in order to render the texture.
  73369. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73370. */
  73371. setFragment(fragment: any): void;
  73372. /**
  73373. * Define the refresh rate of the texture or the rendering frequency.
  73374. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73375. */
  73376. refreshRate: number;
  73377. /** @hidden */
  73378. _shouldRender(): boolean;
  73379. /**
  73380. * Get the size the texture is rendering at.
  73381. * @returns the size (texture is always squared)
  73382. */
  73383. getRenderSize(): number;
  73384. /**
  73385. * Resize the texture to new value.
  73386. * @param size Define the new size the texture should have
  73387. * @param generateMipMaps Define whether the new texture should create mip maps
  73388. */
  73389. resize(size: number, generateMipMaps: boolean): void;
  73390. private _checkUniform;
  73391. /**
  73392. * Set a texture in the shader program used to render.
  73393. * @param name Define the name of the uniform samplers as defined in the shader
  73394. * @param texture Define the texture to bind to this sampler
  73395. * @return the texture itself allowing "fluent" like uniform updates
  73396. */
  73397. setTexture(name: string, texture: Texture): ProceduralTexture;
  73398. /**
  73399. * Set a float in the shader.
  73400. * @param name Define the name of the uniform as defined in the shader
  73401. * @param value Define the value to give to the uniform
  73402. * @return the texture itself allowing "fluent" like uniform updates
  73403. */
  73404. setFloat(name: string, value: number): ProceduralTexture;
  73405. /**
  73406. * Set a int in the shader.
  73407. * @param name Define the name of the uniform as defined in the shader
  73408. * @param value Define the value to give to the uniform
  73409. * @return the texture itself allowing "fluent" like uniform updates
  73410. */
  73411. setInt(name: string, value: number): ProceduralTexture;
  73412. /**
  73413. * Set an array of floats in the shader.
  73414. * @param name Define the name of the uniform as defined in the shader
  73415. * @param value Define the value to give to the uniform
  73416. * @return the texture itself allowing "fluent" like uniform updates
  73417. */
  73418. setFloats(name: string, value: number[]): ProceduralTexture;
  73419. /**
  73420. * Set a vec3 in the shader from a Color3.
  73421. * @param name Define the name of the uniform as defined in the shader
  73422. * @param value Define the value to give to the uniform
  73423. * @return the texture itself allowing "fluent" like uniform updates
  73424. */
  73425. setColor3(name: string, value: Color3): ProceduralTexture;
  73426. /**
  73427. * Set a vec4 in the shader from a Color4.
  73428. * @param name Define the name of the uniform as defined in the shader
  73429. * @param value Define the value to give to the uniform
  73430. * @return the texture itself allowing "fluent" like uniform updates
  73431. */
  73432. setColor4(name: string, value: Color4): ProceduralTexture;
  73433. /**
  73434. * Set a vec2 in the shader from a Vector2.
  73435. * @param name Define the name of the uniform as defined in the shader
  73436. * @param value Define the value to give to the uniform
  73437. * @return the texture itself allowing "fluent" like uniform updates
  73438. */
  73439. setVector2(name: string, value: Vector2): ProceduralTexture;
  73440. /**
  73441. * Set a vec3 in the shader from a Vector3.
  73442. * @param name Define the name of the uniform as defined in the shader
  73443. * @param value Define the value to give to the uniform
  73444. * @return the texture itself allowing "fluent" like uniform updates
  73445. */
  73446. setVector3(name: string, value: Vector3): ProceduralTexture;
  73447. /**
  73448. * Set a mat4 in the shader from a MAtrix.
  73449. * @param name Define the name of the uniform as defined in the shader
  73450. * @param value Define the value to give to the uniform
  73451. * @return the texture itself allowing "fluent" like uniform updates
  73452. */
  73453. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73454. /**
  73455. * Render the texture to its associated render target.
  73456. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73457. */
  73458. render(useCameraPostProcess?: boolean): void;
  73459. /**
  73460. * Clone the texture.
  73461. * @returns the cloned texture
  73462. */
  73463. clone(): ProceduralTexture;
  73464. /**
  73465. * Dispose the texture and release its asoociated resources.
  73466. */
  73467. dispose(): void;
  73468. }
  73469. }
  73470. declare module BABYLON {
  73471. /**
  73472. * This represents the base class for particle system in Babylon.
  73473. * 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.
  73474. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73475. * @example https://doc.babylonjs.com/babylon101/particles
  73476. */
  73477. export class BaseParticleSystem {
  73478. /**
  73479. * Source color is added to the destination color without alpha affecting the result
  73480. */
  73481. static BLENDMODE_ONEONE: number;
  73482. /**
  73483. * Blend current color and particle color using particle’s alpha
  73484. */
  73485. static BLENDMODE_STANDARD: number;
  73486. /**
  73487. * Add current color and particle color multiplied by particle’s alpha
  73488. */
  73489. static BLENDMODE_ADD: number;
  73490. /**
  73491. * Multiply current color with particle color
  73492. */
  73493. static BLENDMODE_MULTIPLY: number;
  73494. /**
  73495. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73496. */
  73497. static BLENDMODE_MULTIPLYADD: number;
  73498. /**
  73499. * List of animations used by the particle system.
  73500. */
  73501. animations: Animation[];
  73502. /**
  73503. * The id of the Particle system.
  73504. */
  73505. id: string;
  73506. /**
  73507. * The friendly name of the Particle system.
  73508. */
  73509. name: string;
  73510. /**
  73511. * The rendering group used by the Particle system to chose when to render.
  73512. */
  73513. renderingGroupId: number;
  73514. /**
  73515. * The emitter represents the Mesh or position we are attaching the particle system to.
  73516. */
  73517. emitter: Nullable<AbstractMesh | Vector3>;
  73518. /**
  73519. * The maximum number of particles to emit per frame
  73520. */
  73521. emitRate: number;
  73522. /**
  73523. * If you want to launch only a few particles at once, that can be done, as well.
  73524. */
  73525. manualEmitCount: number;
  73526. /**
  73527. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73528. */
  73529. updateSpeed: number;
  73530. /**
  73531. * The amount of time the particle system is running (depends of the overall update speed).
  73532. */
  73533. targetStopDuration: number;
  73534. /**
  73535. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73536. */
  73537. disposeOnStop: boolean;
  73538. /**
  73539. * Minimum power of emitting particles.
  73540. */
  73541. minEmitPower: number;
  73542. /**
  73543. * Maximum power of emitting particles.
  73544. */
  73545. maxEmitPower: number;
  73546. /**
  73547. * Minimum life time of emitting particles.
  73548. */
  73549. minLifeTime: number;
  73550. /**
  73551. * Maximum life time of emitting particles.
  73552. */
  73553. maxLifeTime: number;
  73554. /**
  73555. * Minimum Size of emitting particles.
  73556. */
  73557. minSize: number;
  73558. /**
  73559. * Maximum Size of emitting particles.
  73560. */
  73561. maxSize: number;
  73562. /**
  73563. * Minimum scale of emitting particles on X axis.
  73564. */
  73565. minScaleX: number;
  73566. /**
  73567. * Maximum scale of emitting particles on X axis.
  73568. */
  73569. maxScaleX: number;
  73570. /**
  73571. * Minimum scale of emitting particles on Y axis.
  73572. */
  73573. minScaleY: number;
  73574. /**
  73575. * Maximum scale of emitting particles on Y axis.
  73576. */
  73577. maxScaleY: number;
  73578. /**
  73579. * Gets or sets the minimal initial rotation in radians.
  73580. */
  73581. minInitialRotation: number;
  73582. /**
  73583. * Gets or sets the maximal initial rotation in radians.
  73584. */
  73585. maxInitialRotation: number;
  73586. /**
  73587. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73588. */
  73589. minAngularSpeed: number;
  73590. /**
  73591. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73592. */
  73593. maxAngularSpeed: number;
  73594. /**
  73595. * The texture used to render each particle. (this can be a spritesheet)
  73596. */
  73597. particleTexture: Nullable<Texture>;
  73598. /**
  73599. * The layer mask we are rendering the particles through.
  73600. */
  73601. layerMask: number;
  73602. /**
  73603. * This can help using your own shader to render the particle system.
  73604. * The according effect will be created
  73605. */
  73606. customShader: any;
  73607. /**
  73608. * By default particle system starts as soon as they are created. This prevents the
  73609. * automatic start to happen and let you decide when to start emitting particles.
  73610. */
  73611. preventAutoStart: boolean;
  73612. private _noiseTexture;
  73613. /**
  73614. * Gets or sets a texture used to add random noise to particle positions
  73615. */
  73616. noiseTexture: Nullable<ProceduralTexture>;
  73617. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73618. noiseStrength: Vector3;
  73619. /**
  73620. * Callback triggered when the particle animation is ending.
  73621. */
  73622. onAnimationEnd: Nullable<() => void>;
  73623. /**
  73624. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73625. */
  73626. blendMode: number;
  73627. /**
  73628. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73629. * to override the particles.
  73630. */
  73631. forceDepthWrite: boolean;
  73632. /** 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 */
  73633. preWarmCycles: number;
  73634. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73635. preWarmStepOffset: number;
  73636. /**
  73637. * 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)
  73638. */
  73639. spriteCellChangeSpeed: number;
  73640. /**
  73641. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73642. */
  73643. startSpriteCellID: number;
  73644. /**
  73645. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73646. */
  73647. endSpriteCellID: number;
  73648. /**
  73649. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73650. */
  73651. spriteCellWidth: number;
  73652. /**
  73653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73654. */
  73655. spriteCellHeight: number;
  73656. /**
  73657. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73658. */
  73659. spriteRandomStartCell: boolean;
  73660. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73661. translationPivot: Vector2;
  73662. /** @hidden */
  73663. protected _isAnimationSheetEnabled: boolean;
  73664. /**
  73665. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73666. */
  73667. beginAnimationOnStart: boolean;
  73668. /**
  73669. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73670. */
  73671. beginAnimationFrom: number;
  73672. /**
  73673. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73674. */
  73675. beginAnimationTo: number;
  73676. /**
  73677. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73678. */
  73679. beginAnimationLoop: boolean;
  73680. /**
  73681. * Gets or sets a world offset applied to all particles
  73682. */
  73683. worldOffset: Vector3;
  73684. /**
  73685. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73686. */
  73687. isAnimationSheetEnabled: boolean;
  73688. /**
  73689. * Get hosting scene
  73690. * @returns the scene
  73691. */
  73692. getScene(): Scene;
  73693. /**
  73694. * You can use gravity if you want to give an orientation to your particles.
  73695. */
  73696. gravity: Vector3;
  73697. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73698. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73699. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73700. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73701. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73702. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73703. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73704. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73705. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73706. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73707. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73708. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73709. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73710. /**
  73711. * Defines the delay in milliseconds before starting the system (0 by default)
  73712. */
  73713. startDelay: number;
  73714. /**
  73715. * Gets the current list of drag gradients.
  73716. * You must use addDragGradient and removeDragGradient to udpate this list
  73717. * @returns the list of drag gradients
  73718. */
  73719. getDragGradients(): Nullable<Array<FactorGradient>>;
  73720. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73721. limitVelocityDamping: number;
  73722. /**
  73723. * Gets the current list of limit velocity gradients.
  73724. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73725. * @returns the list of limit velocity gradients
  73726. */
  73727. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73728. /**
  73729. * Gets the current list of color gradients.
  73730. * You must use addColorGradient and removeColorGradient to udpate this list
  73731. * @returns the list of color gradients
  73732. */
  73733. getColorGradients(): Nullable<Array<ColorGradient>>;
  73734. /**
  73735. * Gets the current list of size gradients.
  73736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73737. * @returns the list of size gradients
  73738. */
  73739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73740. /**
  73741. * Gets the current list of color remap gradients.
  73742. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73743. * @returns the list of color remap gradients
  73744. */
  73745. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73746. /**
  73747. * Gets the current list of alpha remap gradients.
  73748. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73749. * @returns the list of alpha remap gradients
  73750. */
  73751. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73752. /**
  73753. * Gets the current list of life time gradients.
  73754. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73755. * @returns the list of life time gradients
  73756. */
  73757. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73758. /**
  73759. * Gets the current list of angular speed gradients.
  73760. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73761. * @returns the list of angular speed gradients
  73762. */
  73763. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73764. /**
  73765. * Gets the current list of velocity gradients.
  73766. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73767. * @returns the list of velocity gradients
  73768. */
  73769. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73770. /**
  73771. * Gets the current list of start size gradients.
  73772. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73773. * @returns the list of start size gradients
  73774. */
  73775. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73776. /**
  73777. * Gets the current list of emit rate gradients.
  73778. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73779. * @returns the list of emit rate gradients
  73780. */
  73781. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73782. /**
  73783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73784. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73785. */
  73786. direction1: Vector3;
  73787. /**
  73788. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73789. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73790. */
  73791. direction2: Vector3;
  73792. /**
  73793. * 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.
  73794. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73795. */
  73796. minEmitBox: Vector3;
  73797. /**
  73798. * 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.
  73799. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73800. */
  73801. maxEmitBox: Vector3;
  73802. /**
  73803. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73804. */
  73805. color1: Color4;
  73806. /**
  73807. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73808. */
  73809. color2: Color4;
  73810. /**
  73811. * Color the particle will have at the end of its lifetime
  73812. */
  73813. colorDead: Color4;
  73814. /**
  73815. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73816. */
  73817. textureMask: Color4;
  73818. /**
  73819. * The particle emitter type defines the emitter used by the particle system.
  73820. * It can be for example box, sphere, or cone...
  73821. */
  73822. particleEmitterType: IParticleEmitterType;
  73823. /** @hidden */
  73824. _isSubEmitter: boolean;
  73825. /**
  73826. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73827. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73828. */
  73829. billboardMode: number;
  73830. protected _isBillboardBased: boolean;
  73831. /**
  73832. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73833. */
  73834. isBillboardBased: boolean;
  73835. /**
  73836. * The scene the particle system belongs to.
  73837. */
  73838. protected _scene: Scene;
  73839. /**
  73840. * Local cache of defines for image processing.
  73841. */
  73842. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73843. /**
  73844. * Default configuration related to image processing available in the standard Material.
  73845. */
  73846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73847. /**
  73848. * Gets the image processing configuration used either in this material.
  73849. */
  73850. /**
  73851. * Sets the Default image processing configuration used either in the this material.
  73852. *
  73853. * If sets to null, the scene one is in use.
  73854. */
  73855. imageProcessingConfiguration: ImageProcessingConfiguration;
  73856. /**
  73857. * Attaches a new image processing configuration to the Standard Material.
  73858. * @param configuration
  73859. */
  73860. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73861. /** @hidden */
  73862. protected _reset(): void;
  73863. /** @hidden */
  73864. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73865. /**
  73866. * Instantiates a particle system.
  73867. * 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.
  73868. * @param name The name of the particle system
  73869. */
  73870. constructor(name: string);
  73871. /**
  73872. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73873. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73874. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73875. * @returns the emitter
  73876. */
  73877. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73878. /**
  73879. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73880. * @param radius The radius of the hemisphere to emit from
  73881. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73882. * @returns the emitter
  73883. */
  73884. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73885. /**
  73886. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73887. * @param radius The radius of the sphere to emit from
  73888. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73889. * @returns the emitter
  73890. */
  73891. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73892. /**
  73893. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73894. * @param radius The radius of the sphere to emit from
  73895. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73896. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73897. * @returns the emitter
  73898. */
  73899. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73900. /**
  73901. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73902. * @param radius The radius of the emission cylinder
  73903. * @param height The height of the emission cylinder
  73904. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73905. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73906. * @returns the emitter
  73907. */
  73908. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73909. /**
  73910. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73911. * @param radius The radius of the cylinder to emit from
  73912. * @param height The height of the emission cylinder
  73913. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73914. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73915. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73916. * @returns the emitter
  73917. */
  73918. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73919. /**
  73920. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73921. * @param radius The radius of the cone to emit from
  73922. * @param angle The base angle of the cone
  73923. * @returns the emitter
  73924. */
  73925. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73926. /**
  73927. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73930. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73931. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73932. * @returns the emitter
  73933. */
  73934. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73935. }
  73936. }
  73937. declare module BABYLON {
  73938. /**
  73939. * Type of sub emitter
  73940. */
  73941. export enum SubEmitterType {
  73942. /**
  73943. * Attached to the particle over it's lifetime
  73944. */
  73945. ATTACHED = 0,
  73946. /**
  73947. * Created when the particle dies
  73948. */
  73949. END = 1
  73950. }
  73951. /**
  73952. * Sub emitter class used to emit particles from an existing particle
  73953. */
  73954. export class SubEmitter {
  73955. /**
  73956. * the particle system to be used by the sub emitter
  73957. */
  73958. particleSystem: ParticleSystem;
  73959. /**
  73960. * Type of the submitter (Default: END)
  73961. */
  73962. type: SubEmitterType;
  73963. /**
  73964. * 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)
  73965. * Note: This only is supported when using an emitter of type Mesh
  73966. */
  73967. inheritDirection: boolean;
  73968. /**
  73969. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73970. */
  73971. inheritedVelocityAmount: number;
  73972. /**
  73973. * Creates a sub emitter
  73974. * @param particleSystem the particle system to be used by the sub emitter
  73975. */
  73976. constructor(
  73977. /**
  73978. * the particle system to be used by the sub emitter
  73979. */
  73980. particleSystem: ParticleSystem);
  73981. /**
  73982. * Clones the sub emitter
  73983. * @returns the cloned sub emitter
  73984. */
  73985. clone(): SubEmitter;
  73986. /**
  73987. * Serialize current object to a JSON object
  73988. * @returns the serialized object
  73989. */
  73990. serialize(): any;
  73991. /** @hidden */
  73992. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73993. /**
  73994. * Creates a new SubEmitter from a serialized JSON version
  73995. * @param serializationObject defines the JSON object to read from
  73996. * @param scene defines the hosting scene
  73997. * @param rootUrl defines the rootUrl for data loading
  73998. * @returns a new SubEmitter
  73999. */
  74000. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74001. /** Release associated resources */
  74002. dispose(): void;
  74003. }
  74004. }
  74005. declare module BABYLON {
  74006. /** @hidden */
  74007. export var clipPlaneFragmentDeclaration: {
  74008. name: string;
  74009. shader: string;
  74010. };
  74011. }
  74012. declare module BABYLON {
  74013. /** @hidden */
  74014. export var imageProcessingDeclaration: {
  74015. name: string;
  74016. shader: string;
  74017. };
  74018. }
  74019. declare module BABYLON {
  74020. /** @hidden */
  74021. export var imageProcessingFunctions: {
  74022. name: string;
  74023. shader: string;
  74024. };
  74025. }
  74026. declare module BABYLON {
  74027. /** @hidden */
  74028. export var clipPlaneFragment: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module BABYLON {
  74034. /** @hidden */
  74035. export var particlesPixelShader: {
  74036. name: string;
  74037. shader: string;
  74038. };
  74039. }
  74040. declare module BABYLON {
  74041. /** @hidden */
  74042. export var clipPlaneVertexDeclaration: {
  74043. name: string;
  74044. shader: string;
  74045. };
  74046. }
  74047. declare module BABYLON {
  74048. /** @hidden */
  74049. export var clipPlaneVertex: {
  74050. name: string;
  74051. shader: string;
  74052. };
  74053. }
  74054. declare module BABYLON {
  74055. /** @hidden */
  74056. export var particlesVertexShader: {
  74057. name: string;
  74058. shader: string;
  74059. };
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * This represents a particle system in Babylon.
  74064. * 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.
  74065. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74066. * @example https://doc.babylonjs.com/babylon101/particles
  74067. */
  74068. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74069. /**
  74070. * Billboard mode will only apply to Y axis
  74071. */
  74072. static readonly BILLBOARDMODE_Y: number;
  74073. /**
  74074. * Billboard mode will apply to all axes
  74075. */
  74076. static readonly BILLBOARDMODE_ALL: number;
  74077. /**
  74078. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74079. */
  74080. static readonly BILLBOARDMODE_STRETCHED: number;
  74081. /**
  74082. * This function can be defined to provide custom update for active particles.
  74083. * This function will be called instead of regular update (age, position, color, etc.).
  74084. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74085. */
  74086. updateFunction: (particles: Particle[]) => void;
  74087. private _emitterWorldMatrix;
  74088. /**
  74089. * This function can be defined to specify initial direction for every new particle.
  74090. * It by default use the emitterType defined function
  74091. */
  74092. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74093. /**
  74094. * This function can be defined to specify initial position for every new particle.
  74095. * It by default use the emitterType defined function
  74096. */
  74097. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74098. /**
  74099. * @hidden
  74100. */
  74101. _inheritedVelocityOffset: Vector3;
  74102. /**
  74103. * An event triggered when the system is disposed
  74104. */
  74105. onDisposeObservable: Observable<ParticleSystem>;
  74106. private _onDisposeObserver;
  74107. /**
  74108. * Sets a callback that will be triggered when the system is disposed
  74109. */
  74110. onDispose: () => void;
  74111. private _particles;
  74112. private _epsilon;
  74113. private _capacity;
  74114. private _stockParticles;
  74115. private _newPartsExcess;
  74116. private _vertexData;
  74117. private _vertexBuffer;
  74118. private _vertexBuffers;
  74119. private _spriteBuffer;
  74120. private _indexBuffer;
  74121. private _effect;
  74122. private _customEffect;
  74123. private _cachedDefines;
  74124. private _scaledColorStep;
  74125. private _colorDiff;
  74126. private _scaledDirection;
  74127. private _scaledGravity;
  74128. private _currentRenderId;
  74129. private _alive;
  74130. private _useInstancing;
  74131. private _started;
  74132. private _stopped;
  74133. private _actualFrame;
  74134. private _scaledUpdateSpeed;
  74135. private _vertexBufferSize;
  74136. /** @hidden */
  74137. _currentEmitRateGradient: Nullable<FactorGradient>;
  74138. /** @hidden */
  74139. _currentEmitRate1: number;
  74140. /** @hidden */
  74141. _currentEmitRate2: number;
  74142. /** @hidden */
  74143. _currentStartSizeGradient: Nullable<FactorGradient>;
  74144. /** @hidden */
  74145. _currentStartSize1: number;
  74146. /** @hidden */
  74147. _currentStartSize2: number;
  74148. private readonly _rawTextureWidth;
  74149. private _rampGradientsTexture;
  74150. private _useRampGradients;
  74151. /** Gets or sets a boolean indicating that ramp gradients must be used
  74152. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74153. */
  74154. useRampGradients: boolean;
  74155. /**
  74156. * 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.
  74157. * 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: [])
  74158. */
  74159. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74160. private _subEmitters;
  74161. /**
  74162. * @hidden
  74163. * If the particle systems emitter should be disposed when the particle system is disposed
  74164. */
  74165. _disposeEmitterOnDispose: boolean;
  74166. /**
  74167. * The current active Sub-systems, this property is used by the root particle system only.
  74168. */
  74169. activeSubSystems: Array<ParticleSystem>;
  74170. private _rootParticleSystem;
  74171. /**
  74172. * Gets the current list of active particles
  74173. */
  74174. readonly particles: Particle[];
  74175. /**
  74176. * Returns the string "ParticleSystem"
  74177. * @returns a string containing the class name
  74178. */
  74179. getClassName(): string;
  74180. /**
  74181. * Instantiates a particle system.
  74182. * 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.
  74183. * @param name The name of the particle system
  74184. * @param capacity The max number of particles alive at the same time
  74185. * @param scene The scene the particle system belongs to
  74186. * @param customEffect a custom effect used to change the way particles are rendered by default
  74187. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74188. * @param epsilon Offset used to render the particles
  74189. */
  74190. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74191. private _addFactorGradient;
  74192. private _removeFactorGradient;
  74193. /**
  74194. * Adds a new life time gradient
  74195. * @param gradient defines the gradient to use (between 0 and 1)
  74196. * @param factor defines the life time factor to affect to the specified gradient
  74197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74198. * @returns the current particle system
  74199. */
  74200. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74201. /**
  74202. * Remove a specific life time gradient
  74203. * @param gradient defines the gradient to remove
  74204. * @returns the current particle system
  74205. */
  74206. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74207. /**
  74208. * Adds a new size gradient
  74209. * @param gradient defines the gradient to use (between 0 and 1)
  74210. * @param factor defines the size factor to affect to the specified gradient
  74211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74212. * @returns the current particle system
  74213. */
  74214. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74215. /**
  74216. * Remove a specific size gradient
  74217. * @param gradient defines the gradient to remove
  74218. * @returns the current particle system
  74219. */
  74220. removeSizeGradient(gradient: number): IParticleSystem;
  74221. /**
  74222. * Adds a new color remap gradient
  74223. * @param gradient defines the gradient to use (between 0 and 1)
  74224. * @param min defines the color remap minimal range
  74225. * @param max defines the color remap maximal range
  74226. * @returns the current particle system
  74227. */
  74228. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74229. /**
  74230. * Remove a specific color remap gradient
  74231. * @param gradient defines the gradient to remove
  74232. * @returns the current particle system
  74233. */
  74234. removeColorRemapGradient(gradient: number): IParticleSystem;
  74235. /**
  74236. * Adds a new alpha remap gradient
  74237. * @param gradient defines the gradient to use (between 0 and 1)
  74238. * @param min defines the alpha remap minimal range
  74239. * @param max defines the alpha remap maximal range
  74240. * @returns the current particle system
  74241. */
  74242. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74243. /**
  74244. * Remove a specific alpha remap gradient
  74245. * @param gradient defines the gradient to remove
  74246. * @returns the current particle system
  74247. */
  74248. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74249. /**
  74250. * Adds a new angular speed gradient
  74251. * @param gradient defines the gradient to use (between 0 and 1)
  74252. * @param factor defines the angular speed to affect to the specified gradient
  74253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74254. * @returns the current particle system
  74255. */
  74256. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74257. /**
  74258. * Remove a specific angular speed gradient
  74259. * @param gradient defines the gradient to remove
  74260. * @returns the current particle system
  74261. */
  74262. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74263. /**
  74264. * Adds a new velocity gradient
  74265. * @param gradient defines the gradient to use (between 0 and 1)
  74266. * @param factor defines the velocity to affect to the specified gradient
  74267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74268. * @returns the current particle system
  74269. */
  74270. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74271. /**
  74272. * Remove a specific velocity gradient
  74273. * @param gradient defines the gradient to remove
  74274. * @returns the current particle system
  74275. */
  74276. removeVelocityGradient(gradient: number): IParticleSystem;
  74277. /**
  74278. * Adds a new limit velocity gradient
  74279. * @param gradient defines the gradient to use (between 0 and 1)
  74280. * @param factor defines the limit velocity value to affect to the specified gradient
  74281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74282. * @returns the current particle system
  74283. */
  74284. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74285. /**
  74286. * Remove a specific limit velocity gradient
  74287. * @param gradient defines the gradient to remove
  74288. * @returns the current particle system
  74289. */
  74290. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74291. /**
  74292. * Adds a new drag gradient
  74293. * @param gradient defines the gradient to use (between 0 and 1)
  74294. * @param factor defines the drag value to affect to the specified gradient
  74295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74296. * @returns the current particle system
  74297. */
  74298. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74299. /**
  74300. * Remove a specific drag gradient
  74301. * @param gradient defines the gradient to remove
  74302. * @returns the current particle system
  74303. */
  74304. removeDragGradient(gradient: number): IParticleSystem;
  74305. /**
  74306. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74307. * @param gradient defines the gradient to use (between 0 and 1)
  74308. * @param factor defines the emit rate value to affect to the specified gradient
  74309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74310. * @returns the current particle system
  74311. */
  74312. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74313. /**
  74314. * Remove a specific emit rate gradient
  74315. * @param gradient defines the gradient to remove
  74316. * @returns the current particle system
  74317. */
  74318. removeEmitRateGradient(gradient: number): IParticleSystem;
  74319. /**
  74320. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74321. * @param gradient defines the gradient to use (between 0 and 1)
  74322. * @param factor defines the start size value to affect to the specified gradient
  74323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74324. * @returns the current particle system
  74325. */
  74326. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74327. /**
  74328. * Remove a specific start size gradient
  74329. * @param gradient defines the gradient to remove
  74330. * @returns the current particle system
  74331. */
  74332. removeStartSizeGradient(gradient: number): IParticleSystem;
  74333. private _createRampGradientTexture;
  74334. /**
  74335. * Gets the current list of ramp gradients.
  74336. * You must use addRampGradient and removeRampGradient to udpate this list
  74337. * @returns the list of ramp gradients
  74338. */
  74339. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74340. /**
  74341. * Adds a new ramp gradient used to remap particle colors
  74342. * @param gradient defines the gradient to use (between 0 and 1)
  74343. * @param color defines the color to affect to the specified gradient
  74344. * @returns the current particle system
  74345. */
  74346. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74347. /**
  74348. * Remove a specific ramp gradient
  74349. * @param gradient defines the gradient to remove
  74350. * @returns the current particle system
  74351. */
  74352. removeRampGradient(gradient: number): ParticleSystem;
  74353. /**
  74354. * Adds a new color gradient
  74355. * @param gradient defines the gradient to use (between 0 and 1)
  74356. * @param color1 defines the color to affect to the specified gradient
  74357. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74358. * @returns this particle system
  74359. */
  74360. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74361. /**
  74362. * Remove a specific color gradient
  74363. * @param gradient defines the gradient to remove
  74364. * @returns this particle system
  74365. */
  74366. removeColorGradient(gradient: number): IParticleSystem;
  74367. private _fetchR;
  74368. protected _reset(): void;
  74369. private _resetEffect;
  74370. private _createVertexBuffers;
  74371. private _createIndexBuffer;
  74372. /**
  74373. * Gets the maximum number of particles active at the same time.
  74374. * @returns The max number of active particles.
  74375. */
  74376. getCapacity(): number;
  74377. /**
  74378. * Gets whether there are still active particles in the system.
  74379. * @returns True if it is alive, otherwise false.
  74380. */
  74381. isAlive(): boolean;
  74382. /**
  74383. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74384. * @returns True if it has been started, otherwise false.
  74385. */
  74386. isStarted(): boolean;
  74387. private _prepareSubEmitterInternalArray;
  74388. /**
  74389. * Starts the particle system and begins to emit
  74390. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74391. */
  74392. start(delay?: number): void;
  74393. /**
  74394. * Stops the particle system.
  74395. * @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.
  74396. */
  74397. stop(stopSubEmitters?: boolean): void;
  74398. /**
  74399. * Remove all active particles
  74400. */
  74401. reset(): void;
  74402. /**
  74403. * @hidden (for internal use only)
  74404. */
  74405. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74406. /**
  74407. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74408. * Its lifetime will start back at 0.
  74409. */
  74410. recycleParticle: (particle: Particle) => void;
  74411. private _stopSubEmitters;
  74412. private _createParticle;
  74413. private _removeFromRoot;
  74414. private _emitFromParticle;
  74415. private _update;
  74416. /** @hidden */
  74417. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74418. /** @hidden */
  74419. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74420. /** @hidden */
  74421. private _getEffect;
  74422. /**
  74423. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74424. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74425. */
  74426. animate(preWarmOnly?: boolean): void;
  74427. private _appendParticleVertices;
  74428. /**
  74429. * Rebuilds the particle system.
  74430. */
  74431. rebuild(): void;
  74432. /**
  74433. * Is this system ready to be used/rendered
  74434. * @return true if the system is ready
  74435. */
  74436. isReady(): boolean;
  74437. private _render;
  74438. /**
  74439. * Renders the particle system in its current state.
  74440. * @returns the current number of particles
  74441. */
  74442. render(): number;
  74443. /**
  74444. * Disposes the particle system and free the associated resources
  74445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74446. */
  74447. dispose(disposeTexture?: boolean): void;
  74448. /**
  74449. * Clones the particle system.
  74450. * @param name The name of the cloned object
  74451. * @param newEmitter The new emitter to use
  74452. * @returns the cloned particle system
  74453. */
  74454. clone(name: string, newEmitter: any): ParticleSystem;
  74455. /**
  74456. * Serializes the particle system to a JSON object.
  74457. * @returns the JSON object
  74458. */
  74459. serialize(): any;
  74460. /** @hidden */
  74461. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74462. /** @hidden */
  74463. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74464. /**
  74465. * Parses a JSON object to create a particle system.
  74466. * @param parsedParticleSystem The JSON object to parse
  74467. * @param scene The scene to create the particle system in
  74468. * @param rootUrl The root url to use to load external dependencies like texture
  74469. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74470. * @returns the Parsed particle system
  74471. */
  74472. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /**
  74477. * A particle represents one of the element emitted by a particle system.
  74478. * This is mainly define by its coordinates, direction, velocity and age.
  74479. */
  74480. export class Particle {
  74481. /**
  74482. * The particle system the particle belongs to.
  74483. */
  74484. particleSystem: ParticleSystem;
  74485. private static _Count;
  74486. /**
  74487. * Unique ID of the particle
  74488. */
  74489. id: number;
  74490. /**
  74491. * The world position of the particle in the scene.
  74492. */
  74493. position: Vector3;
  74494. /**
  74495. * The world direction of the particle in the scene.
  74496. */
  74497. direction: Vector3;
  74498. /**
  74499. * The color of the particle.
  74500. */
  74501. color: Color4;
  74502. /**
  74503. * The color change of the particle per step.
  74504. */
  74505. colorStep: Color4;
  74506. /**
  74507. * Defines how long will the life of the particle be.
  74508. */
  74509. lifeTime: number;
  74510. /**
  74511. * The current age of the particle.
  74512. */
  74513. age: number;
  74514. /**
  74515. * The current size of the particle.
  74516. */
  74517. size: number;
  74518. /**
  74519. * The current scale of the particle.
  74520. */
  74521. scale: Vector2;
  74522. /**
  74523. * The current angle of the particle.
  74524. */
  74525. angle: number;
  74526. /**
  74527. * Defines how fast is the angle changing.
  74528. */
  74529. angularSpeed: number;
  74530. /**
  74531. * Defines the cell index used by the particle to be rendered from a sprite.
  74532. */
  74533. cellIndex: number;
  74534. /**
  74535. * The information required to support color remapping
  74536. */
  74537. remapData: Vector4;
  74538. /** @hidden */
  74539. _randomCellOffset?: number;
  74540. /** @hidden */
  74541. _initialDirection: Nullable<Vector3>;
  74542. /** @hidden */
  74543. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74544. /** @hidden */
  74545. _initialStartSpriteCellID: number;
  74546. /** @hidden */
  74547. _initialEndSpriteCellID: number;
  74548. /** @hidden */
  74549. _currentColorGradient: Nullable<ColorGradient>;
  74550. /** @hidden */
  74551. _currentColor1: Color4;
  74552. /** @hidden */
  74553. _currentColor2: Color4;
  74554. /** @hidden */
  74555. _currentSizeGradient: Nullable<FactorGradient>;
  74556. /** @hidden */
  74557. _currentSize1: number;
  74558. /** @hidden */
  74559. _currentSize2: number;
  74560. /** @hidden */
  74561. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74562. /** @hidden */
  74563. _currentAngularSpeed1: number;
  74564. /** @hidden */
  74565. _currentAngularSpeed2: number;
  74566. /** @hidden */
  74567. _currentVelocityGradient: Nullable<FactorGradient>;
  74568. /** @hidden */
  74569. _currentVelocity1: number;
  74570. /** @hidden */
  74571. _currentVelocity2: number;
  74572. /** @hidden */
  74573. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74574. /** @hidden */
  74575. _currentLimitVelocity1: number;
  74576. /** @hidden */
  74577. _currentLimitVelocity2: number;
  74578. /** @hidden */
  74579. _currentDragGradient: Nullable<FactorGradient>;
  74580. /** @hidden */
  74581. _currentDrag1: number;
  74582. /** @hidden */
  74583. _currentDrag2: number;
  74584. /** @hidden */
  74585. _randomNoiseCoordinates1: Vector3;
  74586. /** @hidden */
  74587. _randomNoiseCoordinates2: Vector3;
  74588. /**
  74589. * Creates a new instance Particle
  74590. * @param particleSystem the particle system the particle belongs to
  74591. */
  74592. constructor(
  74593. /**
  74594. * The particle system the particle belongs to.
  74595. */
  74596. particleSystem: ParticleSystem);
  74597. private updateCellInfoFromSystem;
  74598. /**
  74599. * Defines how the sprite cell index is updated for the particle
  74600. */
  74601. updateCellIndex(): void;
  74602. /** @hidden */
  74603. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74604. /** @hidden */
  74605. _inheritParticleInfoToSubEmitters(): void;
  74606. /** @hidden */
  74607. _reset(): void;
  74608. /**
  74609. * Copy the properties of particle to another one.
  74610. * @param other the particle to copy the information to.
  74611. */
  74612. copyTo(other: Particle): void;
  74613. }
  74614. }
  74615. declare module BABYLON {
  74616. /**
  74617. * Particle emitter represents a volume emitting particles.
  74618. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74619. */
  74620. export interface IParticleEmitterType {
  74621. /**
  74622. * Called by the particle System when the direction is computed for the created particle.
  74623. * @param worldMatrix is the world matrix of the particle system
  74624. * @param directionToUpdate is the direction vector to update with the result
  74625. * @param particle is the particle we are computed the direction for
  74626. */
  74627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74628. /**
  74629. * Called by the particle System when the position is computed for the created particle.
  74630. * @param worldMatrix is the world matrix of the particle system
  74631. * @param positionToUpdate is the position vector to update with the result
  74632. * @param particle is the particle we are computed the position for
  74633. */
  74634. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74635. /**
  74636. * Clones the current emitter and returns a copy of it
  74637. * @returns the new emitter
  74638. */
  74639. clone(): IParticleEmitterType;
  74640. /**
  74641. * Called by the GPUParticleSystem to setup the update shader
  74642. * @param effect defines the update shader
  74643. */
  74644. applyToShader(effect: Effect): void;
  74645. /**
  74646. * Returns a string to use to update the GPU particles update shader
  74647. * @returns the effect defines string
  74648. */
  74649. getEffectDefines(): string;
  74650. /**
  74651. * Returns a string representing the class name
  74652. * @returns a string containing the class name
  74653. */
  74654. getClassName(): string;
  74655. /**
  74656. * Serializes the particle system to a JSON object.
  74657. * @returns the JSON object
  74658. */
  74659. serialize(): any;
  74660. /**
  74661. * Parse properties from a JSON object
  74662. * @param serializationObject defines the JSON object
  74663. */
  74664. parse(serializationObject: any): void;
  74665. }
  74666. }
  74667. declare module BABYLON {
  74668. /**
  74669. * Particle emitter emitting particles from the inside of a box.
  74670. * It emits the particles randomly between 2 given directions.
  74671. */
  74672. export class BoxParticleEmitter implements IParticleEmitterType {
  74673. /**
  74674. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74675. */
  74676. direction1: Vector3;
  74677. /**
  74678. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74679. */
  74680. direction2: Vector3;
  74681. /**
  74682. * 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.
  74683. */
  74684. minEmitBox: Vector3;
  74685. /**
  74686. * 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.
  74687. */
  74688. maxEmitBox: Vector3;
  74689. /**
  74690. * Creates a new instance BoxParticleEmitter
  74691. */
  74692. constructor();
  74693. /**
  74694. * Called by the particle System when the direction is computed for the created particle.
  74695. * @param worldMatrix is the world matrix of the particle system
  74696. * @param directionToUpdate is the direction vector to update with the result
  74697. * @param particle is the particle we are computed the direction for
  74698. */
  74699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74700. /**
  74701. * Called by the particle System when the position is computed for the created particle.
  74702. * @param worldMatrix is the world matrix of the particle system
  74703. * @param positionToUpdate is the position vector to update with the result
  74704. * @param particle is the particle we are computed the position for
  74705. */
  74706. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74707. /**
  74708. * Clones the current emitter and returns a copy of it
  74709. * @returns the new emitter
  74710. */
  74711. clone(): BoxParticleEmitter;
  74712. /**
  74713. * Called by the GPUParticleSystem to setup the update shader
  74714. * @param effect defines the update shader
  74715. */
  74716. applyToShader(effect: Effect): void;
  74717. /**
  74718. * Returns a string to use to update the GPU particles update shader
  74719. * @returns a string containng the defines string
  74720. */
  74721. getEffectDefines(): string;
  74722. /**
  74723. * Returns the string "BoxParticleEmitter"
  74724. * @returns a string containing the class name
  74725. */
  74726. getClassName(): string;
  74727. /**
  74728. * Serializes the particle system to a JSON object.
  74729. * @returns the JSON object
  74730. */
  74731. serialize(): any;
  74732. /**
  74733. * Parse properties from a JSON object
  74734. * @param serializationObject defines the JSON object
  74735. */
  74736. parse(serializationObject: any): void;
  74737. }
  74738. }
  74739. declare module BABYLON {
  74740. /**
  74741. * Particle emitter emitting particles from the inside of a cone.
  74742. * It emits the particles alongside the cone volume from the base to the particle.
  74743. * The emission direction might be randomized.
  74744. */
  74745. export class ConeParticleEmitter implements IParticleEmitterType {
  74746. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74747. directionRandomizer: number;
  74748. private _radius;
  74749. private _angle;
  74750. private _height;
  74751. /**
  74752. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74753. */
  74754. radiusRange: number;
  74755. /**
  74756. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74757. */
  74758. heightRange: number;
  74759. /**
  74760. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74761. */
  74762. emitFromSpawnPointOnly: boolean;
  74763. /**
  74764. * Gets or sets the radius of the emission cone
  74765. */
  74766. radius: number;
  74767. /**
  74768. * Gets or sets the angle of the emission cone
  74769. */
  74770. angle: number;
  74771. private _buildHeight;
  74772. /**
  74773. * Creates a new instance ConeParticleEmitter
  74774. * @param radius the radius of the emission cone (1 by default)
  74775. * @param angle the cone base angle (PI by default)
  74776. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74777. */
  74778. constructor(radius?: number, angle?: number,
  74779. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74780. directionRandomizer?: number);
  74781. /**
  74782. * Called by the particle System when the direction is computed for the created particle.
  74783. * @param worldMatrix is the world matrix of the particle system
  74784. * @param directionToUpdate is the direction vector to update with the result
  74785. * @param particle is the particle we are computed the direction for
  74786. */
  74787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74788. /**
  74789. * Called by the particle System when the position is computed for the created particle.
  74790. * @param worldMatrix is the world matrix of the particle system
  74791. * @param positionToUpdate is the position vector to update with the result
  74792. * @param particle is the particle we are computed the position for
  74793. */
  74794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74795. /**
  74796. * Clones the current emitter and returns a copy of it
  74797. * @returns the new emitter
  74798. */
  74799. clone(): ConeParticleEmitter;
  74800. /**
  74801. * Called by the GPUParticleSystem to setup the update shader
  74802. * @param effect defines the update shader
  74803. */
  74804. applyToShader(effect: Effect): void;
  74805. /**
  74806. * Returns a string to use to update the GPU particles update shader
  74807. * @returns a string containng the defines string
  74808. */
  74809. getEffectDefines(): string;
  74810. /**
  74811. * Returns the string "ConeParticleEmitter"
  74812. * @returns a string containing the class name
  74813. */
  74814. getClassName(): string;
  74815. /**
  74816. * Serializes the particle system to a JSON object.
  74817. * @returns the JSON object
  74818. */
  74819. serialize(): any;
  74820. /**
  74821. * Parse properties from a JSON object
  74822. * @param serializationObject defines the JSON object
  74823. */
  74824. parse(serializationObject: any): void;
  74825. }
  74826. }
  74827. declare module BABYLON {
  74828. /**
  74829. * Particle emitter emitting particles from the inside of a cylinder.
  74830. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74831. */
  74832. export class CylinderParticleEmitter implements IParticleEmitterType {
  74833. /**
  74834. * The radius of the emission cylinder.
  74835. */
  74836. radius: number;
  74837. /**
  74838. * The height of the emission cylinder.
  74839. */
  74840. height: number;
  74841. /**
  74842. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74843. */
  74844. radiusRange: number;
  74845. /**
  74846. * How much to randomize the particle direction [0-1].
  74847. */
  74848. directionRandomizer: number;
  74849. /**
  74850. * Creates a new instance CylinderParticleEmitter
  74851. * @param radius the radius of the emission cylinder (1 by default)
  74852. * @param height the height of the emission cylinder (1 by default)
  74853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74854. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74855. */
  74856. constructor(
  74857. /**
  74858. * The radius of the emission cylinder.
  74859. */
  74860. radius?: number,
  74861. /**
  74862. * The height of the emission cylinder.
  74863. */
  74864. height?: number,
  74865. /**
  74866. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74867. */
  74868. radiusRange?: number,
  74869. /**
  74870. * How much to randomize the particle direction [0-1].
  74871. */
  74872. directionRandomizer?: number);
  74873. /**
  74874. * Called by the particle System when the direction is computed for the created particle.
  74875. * @param worldMatrix is the world matrix of the particle system
  74876. * @param directionToUpdate is the direction vector to update with the result
  74877. * @param particle is the particle we are computed the direction for
  74878. */
  74879. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74880. /**
  74881. * Called by the particle System when the position is computed for the created particle.
  74882. * @param worldMatrix is the world matrix of the particle system
  74883. * @param positionToUpdate is the position vector to update with the result
  74884. * @param particle is the particle we are computed the position for
  74885. */
  74886. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74887. /**
  74888. * Clones the current emitter and returns a copy of it
  74889. * @returns the new emitter
  74890. */
  74891. clone(): CylinderParticleEmitter;
  74892. /**
  74893. * Called by the GPUParticleSystem to setup the update shader
  74894. * @param effect defines the update shader
  74895. */
  74896. applyToShader(effect: Effect): void;
  74897. /**
  74898. * Returns a string to use to update the GPU particles update shader
  74899. * @returns a string containng the defines string
  74900. */
  74901. getEffectDefines(): string;
  74902. /**
  74903. * Returns the string "CylinderParticleEmitter"
  74904. * @returns a string containing the class name
  74905. */
  74906. getClassName(): string;
  74907. /**
  74908. * Serializes the particle system to a JSON object.
  74909. * @returns the JSON object
  74910. */
  74911. serialize(): any;
  74912. /**
  74913. * Parse properties from a JSON object
  74914. * @param serializationObject defines the JSON object
  74915. */
  74916. parse(serializationObject: any): void;
  74917. }
  74918. /**
  74919. * Particle emitter emitting particles from the inside of a cylinder.
  74920. * It emits the particles randomly between two vectors.
  74921. */
  74922. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74923. /**
  74924. * The min limit of the emission direction.
  74925. */
  74926. direction1: Vector3;
  74927. /**
  74928. * The max limit of the emission direction.
  74929. */
  74930. direction2: Vector3;
  74931. /**
  74932. * Creates a new instance CylinderDirectedParticleEmitter
  74933. * @param radius the radius of the emission cylinder (1 by default)
  74934. * @param height the height of the emission cylinder (1 by default)
  74935. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74936. * @param direction1 the min limit of the emission direction (up vector by default)
  74937. * @param direction2 the max limit of the emission direction (up vector by default)
  74938. */
  74939. constructor(radius?: number, height?: number, radiusRange?: number,
  74940. /**
  74941. * The min limit of the emission direction.
  74942. */
  74943. direction1?: Vector3,
  74944. /**
  74945. * The max limit of the emission direction.
  74946. */
  74947. direction2?: Vector3);
  74948. /**
  74949. * Called by the particle System when the direction is computed for the created particle.
  74950. * @param worldMatrix is the world matrix of the particle system
  74951. * @param directionToUpdate is the direction vector to update with the result
  74952. * @param particle is the particle we are computed the direction for
  74953. */
  74954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74955. /**
  74956. * Clones the current emitter and returns a copy of it
  74957. * @returns the new emitter
  74958. */
  74959. clone(): CylinderDirectedParticleEmitter;
  74960. /**
  74961. * Called by the GPUParticleSystem to setup the update shader
  74962. * @param effect defines the update shader
  74963. */
  74964. applyToShader(effect: Effect): void;
  74965. /**
  74966. * Returns a string to use to update the GPU particles update shader
  74967. * @returns a string containng the defines string
  74968. */
  74969. getEffectDefines(): string;
  74970. /**
  74971. * Returns the string "CylinderDirectedParticleEmitter"
  74972. * @returns a string containing the class name
  74973. */
  74974. getClassName(): string;
  74975. /**
  74976. * Serializes the particle system to a JSON object.
  74977. * @returns the JSON object
  74978. */
  74979. serialize(): any;
  74980. /**
  74981. * Parse properties from a JSON object
  74982. * @param serializationObject defines the JSON object
  74983. */
  74984. parse(serializationObject: any): void;
  74985. }
  74986. }
  74987. declare module BABYLON {
  74988. /**
  74989. * Particle emitter emitting particles from the inside of a hemisphere.
  74990. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74991. */
  74992. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74993. /**
  74994. * The radius of the emission hemisphere.
  74995. */
  74996. radius: number;
  74997. /**
  74998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74999. */
  75000. radiusRange: number;
  75001. /**
  75002. * How much to randomize the particle direction [0-1].
  75003. */
  75004. directionRandomizer: number;
  75005. /**
  75006. * Creates a new instance HemisphericParticleEmitter
  75007. * @param radius the radius of the emission hemisphere (1 by default)
  75008. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75009. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75010. */
  75011. constructor(
  75012. /**
  75013. * The radius of the emission hemisphere.
  75014. */
  75015. radius?: number,
  75016. /**
  75017. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75018. */
  75019. radiusRange?: number,
  75020. /**
  75021. * How much to randomize the particle direction [0-1].
  75022. */
  75023. directionRandomizer?: number);
  75024. /**
  75025. * Called by the particle System when the direction is computed for the created particle.
  75026. * @param worldMatrix is the world matrix of the particle system
  75027. * @param directionToUpdate is the direction vector to update with the result
  75028. * @param particle is the particle we are computed the direction for
  75029. */
  75030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75031. /**
  75032. * Called by the particle System when the position is computed for the created particle.
  75033. * @param worldMatrix is the world matrix of the particle system
  75034. * @param positionToUpdate is the position vector to update with the result
  75035. * @param particle is the particle we are computed the position for
  75036. */
  75037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75038. /**
  75039. * Clones the current emitter and returns a copy of it
  75040. * @returns the new emitter
  75041. */
  75042. clone(): HemisphericParticleEmitter;
  75043. /**
  75044. * Called by the GPUParticleSystem to setup the update shader
  75045. * @param effect defines the update shader
  75046. */
  75047. applyToShader(effect: Effect): void;
  75048. /**
  75049. * Returns a string to use to update the GPU particles update shader
  75050. * @returns a string containng the defines string
  75051. */
  75052. getEffectDefines(): string;
  75053. /**
  75054. * Returns the string "HemisphericParticleEmitter"
  75055. * @returns a string containing the class name
  75056. */
  75057. getClassName(): string;
  75058. /**
  75059. * Serializes the particle system to a JSON object.
  75060. * @returns the JSON object
  75061. */
  75062. serialize(): any;
  75063. /**
  75064. * Parse properties from a JSON object
  75065. * @param serializationObject defines the JSON object
  75066. */
  75067. parse(serializationObject: any): void;
  75068. }
  75069. }
  75070. declare module BABYLON {
  75071. /**
  75072. * Particle emitter emitting particles from a point.
  75073. * It emits the particles randomly between 2 given directions.
  75074. */
  75075. export class PointParticleEmitter implements IParticleEmitterType {
  75076. /**
  75077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75078. */
  75079. direction1: Vector3;
  75080. /**
  75081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75082. */
  75083. direction2: Vector3;
  75084. /**
  75085. * Creates a new instance PointParticleEmitter
  75086. */
  75087. constructor();
  75088. /**
  75089. * Called by the particle System when the direction is computed for the created particle.
  75090. * @param worldMatrix is the world matrix of the particle system
  75091. * @param directionToUpdate is the direction vector to update with the result
  75092. * @param particle is the particle we are computed the direction for
  75093. */
  75094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75095. /**
  75096. * Called by the particle System when the position is computed for the created particle.
  75097. * @param worldMatrix is the world matrix of the particle system
  75098. * @param positionToUpdate is the position vector to update with the result
  75099. * @param particle is the particle we are computed the position for
  75100. */
  75101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75102. /**
  75103. * Clones the current emitter and returns a copy of it
  75104. * @returns the new emitter
  75105. */
  75106. clone(): PointParticleEmitter;
  75107. /**
  75108. * Called by the GPUParticleSystem to setup the update shader
  75109. * @param effect defines the update shader
  75110. */
  75111. applyToShader(effect: Effect): void;
  75112. /**
  75113. * Returns a string to use to update the GPU particles update shader
  75114. * @returns a string containng the defines string
  75115. */
  75116. getEffectDefines(): string;
  75117. /**
  75118. * Returns the string "PointParticleEmitter"
  75119. * @returns a string containing the class name
  75120. */
  75121. getClassName(): string;
  75122. /**
  75123. * Serializes the particle system to a JSON object.
  75124. * @returns the JSON object
  75125. */
  75126. serialize(): any;
  75127. /**
  75128. * Parse properties from a JSON object
  75129. * @param serializationObject defines the JSON object
  75130. */
  75131. parse(serializationObject: any): void;
  75132. }
  75133. }
  75134. declare module BABYLON {
  75135. /**
  75136. * Particle emitter emitting particles from the inside of a sphere.
  75137. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75138. */
  75139. export class SphereParticleEmitter implements IParticleEmitterType {
  75140. /**
  75141. * The radius of the emission sphere.
  75142. */
  75143. radius: number;
  75144. /**
  75145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75146. */
  75147. radiusRange: number;
  75148. /**
  75149. * How much to randomize the particle direction [0-1].
  75150. */
  75151. directionRandomizer: number;
  75152. /**
  75153. * Creates a new instance SphereParticleEmitter
  75154. * @param radius the radius of the emission sphere (1 by default)
  75155. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75156. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75157. */
  75158. constructor(
  75159. /**
  75160. * The radius of the emission sphere.
  75161. */
  75162. radius?: number,
  75163. /**
  75164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75165. */
  75166. radiusRange?: number,
  75167. /**
  75168. * How much to randomize the particle direction [0-1].
  75169. */
  75170. directionRandomizer?: number);
  75171. /**
  75172. * Called by the particle System when the direction is computed for the created particle.
  75173. * @param worldMatrix is the world matrix of the particle system
  75174. * @param directionToUpdate is the direction vector to update with the result
  75175. * @param particle is the particle we are computed the direction for
  75176. */
  75177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75178. /**
  75179. * Called by the particle System when the position is computed for the created particle.
  75180. * @param worldMatrix is the world matrix of the particle system
  75181. * @param positionToUpdate is the position vector to update with the result
  75182. * @param particle is the particle we are computed the position for
  75183. */
  75184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75185. /**
  75186. * Clones the current emitter and returns a copy of it
  75187. * @returns the new emitter
  75188. */
  75189. clone(): SphereParticleEmitter;
  75190. /**
  75191. * Called by the GPUParticleSystem to setup the update shader
  75192. * @param effect defines the update shader
  75193. */
  75194. applyToShader(effect: Effect): void;
  75195. /**
  75196. * Returns a string to use to update the GPU particles update shader
  75197. * @returns a string containng the defines string
  75198. */
  75199. getEffectDefines(): string;
  75200. /**
  75201. * Returns the string "SphereParticleEmitter"
  75202. * @returns a string containing the class name
  75203. */
  75204. getClassName(): string;
  75205. /**
  75206. * Serializes the particle system to a JSON object.
  75207. * @returns the JSON object
  75208. */
  75209. serialize(): any;
  75210. /**
  75211. * Parse properties from a JSON object
  75212. * @param serializationObject defines the JSON object
  75213. */
  75214. parse(serializationObject: any): void;
  75215. }
  75216. /**
  75217. * Particle emitter emitting particles from the inside of a sphere.
  75218. * It emits the particles randomly between two vectors.
  75219. */
  75220. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75221. /**
  75222. * The min limit of the emission direction.
  75223. */
  75224. direction1: Vector3;
  75225. /**
  75226. * The max limit of the emission direction.
  75227. */
  75228. direction2: Vector3;
  75229. /**
  75230. * Creates a new instance SphereDirectedParticleEmitter
  75231. * @param radius the radius of the emission sphere (1 by default)
  75232. * @param direction1 the min limit of the emission direction (up vector by default)
  75233. * @param direction2 the max limit of the emission direction (up vector by default)
  75234. */
  75235. constructor(radius?: number,
  75236. /**
  75237. * The min limit of the emission direction.
  75238. */
  75239. direction1?: Vector3,
  75240. /**
  75241. * The max limit of the emission direction.
  75242. */
  75243. direction2?: Vector3);
  75244. /**
  75245. * Called by the particle System when the direction is computed for the created particle.
  75246. * @param worldMatrix is the world matrix of the particle system
  75247. * @param directionToUpdate is the direction vector to update with the result
  75248. * @param particle is the particle we are computed the direction for
  75249. */
  75250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75251. /**
  75252. * Clones the current emitter and returns a copy of it
  75253. * @returns the new emitter
  75254. */
  75255. clone(): SphereDirectedParticleEmitter;
  75256. /**
  75257. * Called by the GPUParticleSystem to setup the update shader
  75258. * @param effect defines the update shader
  75259. */
  75260. applyToShader(effect: Effect): void;
  75261. /**
  75262. * Returns a string to use to update the GPU particles update shader
  75263. * @returns a string containng the defines string
  75264. */
  75265. getEffectDefines(): string;
  75266. /**
  75267. * Returns the string "SphereDirectedParticleEmitter"
  75268. * @returns a string containing the class name
  75269. */
  75270. getClassName(): string;
  75271. /**
  75272. * Serializes the particle system to a JSON object.
  75273. * @returns the JSON object
  75274. */
  75275. serialize(): any;
  75276. /**
  75277. * Parse properties from a JSON object
  75278. * @param serializationObject defines the JSON object
  75279. */
  75280. parse(serializationObject: any): void;
  75281. }
  75282. }
  75283. declare module BABYLON {
  75284. /**
  75285. * Interface representing a particle system in Babylon.js.
  75286. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75287. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75288. */
  75289. export interface IParticleSystem {
  75290. /**
  75291. * List of animations used by the particle system.
  75292. */
  75293. animations: Animation[];
  75294. /**
  75295. * The id of the Particle system.
  75296. */
  75297. id: string;
  75298. /**
  75299. * The name of the Particle system.
  75300. */
  75301. name: string;
  75302. /**
  75303. * The emitter represents the Mesh or position we are attaching the particle system to.
  75304. */
  75305. emitter: Nullable<AbstractMesh | Vector3>;
  75306. /**
  75307. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75308. */
  75309. isBillboardBased: boolean;
  75310. /**
  75311. * The rendering group used by the Particle system to chose when to render.
  75312. */
  75313. renderingGroupId: number;
  75314. /**
  75315. * The layer mask we are rendering the particles through.
  75316. */
  75317. layerMask: number;
  75318. /**
  75319. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75320. */
  75321. updateSpeed: number;
  75322. /**
  75323. * The amount of time the particle system is running (depends of the overall update speed).
  75324. */
  75325. targetStopDuration: number;
  75326. /**
  75327. * The texture used to render each particle. (this can be a spritesheet)
  75328. */
  75329. particleTexture: Nullable<Texture>;
  75330. /**
  75331. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75332. */
  75333. blendMode: number;
  75334. /**
  75335. * Minimum life time of emitting particles.
  75336. */
  75337. minLifeTime: number;
  75338. /**
  75339. * Maximum life time of emitting particles.
  75340. */
  75341. maxLifeTime: number;
  75342. /**
  75343. * Minimum Size of emitting particles.
  75344. */
  75345. minSize: number;
  75346. /**
  75347. * Maximum Size of emitting particles.
  75348. */
  75349. maxSize: number;
  75350. /**
  75351. * Minimum scale of emitting particles on X axis.
  75352. */
  75353. minScaleX: number;
  75354. /**
  75355. * Maximum scale of emitting particles on X axis.
  75356. */
  75357. maxScaleX: number;
  75358. /**
  75359. * Minimum scale of emitting particles on Y axis.
  75360. */
  75361. minScaleY: number;
  75362. /**
  75363. * Maximum scale of emitting particles on Y axis.
  75364. */
  75365. maxScaleY: number;
  75366. /**
  75367. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75368. */
  75369. color1: Color4;
  75370. /**
  75371. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75372. */
  75373. color2: Color4;
  75374. /**
  75375. * Color the particle will have at the end of its lifetime.
  75376. */
  75377. colorDead: Color4;
  75378. /**
  75379. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75380. */
  75381. emitRate: number;
  75382. /**
  75383. * You can use gravity if you want to give an orientation to your particles.
  75384. */
  75385. gravity: Vector3;
  75386. /**
  75387. * Minimum power of emitting particles.
  75388. */
  75389. minEmitPower: number;
  75390. /**
  75391. * Maximum power of emitting particles.
  75392. */
  75393. maxEmitPower: number;
  75394. /**
  75395. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75396. */
  75397. minAngularSpeed: number;
  75398. /**
  75399. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75400. */
  75401. maxAngularSpeed: number;
  75402. /**
  75403. * Gets or sets the minimal initial rotation in radians.
  75404. */
  75405. minInitialRotation: number;
  75406. /**
  75407. * Gets or sets the maximal initial rotation in radians.
  75408. */
  75409. maxInitialRotation: number;
  75410. /**
  75411. * The particle emitter type defines the emitter used by the particle system.
  75412. * It can be for example box, sphere, or cone...
  75413. */
  75414. particleEmitterType: Nullable<IParticleEmitterType>;
  75415. /**
  75416. * Defines the delay in milliseconds before starting the system (0 by default)
  75417. */
  75418. startDelay: number;
  75419. /**
  75420. * 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
  75421. */
  75422. preWarmCycles: number;
  75423. /**
  75424. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75425. */
  75426. preWarmStepOffset: number;
  75427. /**
  75428. * 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)
  75429. */
  75430. spriteCellChangeSpeed: number;
  75431. /**
  75432. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75433. */
  75434. startSpriteCellID: number;
  75435. /**
  75436. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75437. */
  75438. endSpriteCellID: number;
  75439. /**
  75440. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75441. */
  75442. spriteCellWidth: number;
  75443. /**
  75444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75445. */
  75446. spriteCellHeight: number;
  75447. /**
  75448. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75449. */
  75450. spriteRandomStartCell: boolean;
  75451. /**
  75452. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75453. */
  75454. isAnimationSheetEnabled: boolean;
  75455. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75456. translationPivot: Vector2;
  75457. /**
  75458. * Gets or sets a texture used to add random noise to particle positions
  75459. */
  75460. noiseTexture: Nullable<BaseTexture>;
  75461. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75462. noiseStrength: Vector3;
  75463. /**
  75464. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75465. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75466. */
  75467. billboardMode: number;
  75468. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75469. limitVelocityDamping: number;
  75470. /**
  75471. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75472. */
  75473. beginAnimationOnStart: boolean;
  75474. /**
  75475. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75476. */
  75477. beginAnimationFrom: number;
  75478. /**
  75479. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75480. */
  75481. beginAnimationTo: number;
  75482. /**
  75483. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75484. */
  75485. beginAnimationLoop: boolean;
  75486. /**
  75487. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75488. */
  75489. disposeOnStop: boolean;
  75490. /**
  75491. * Gets the maximum number of particles active at the same time.
  75492. * @returns The max number of active particles.
  75493. */
  75494. getCapacity(): number;
  75495. /**
  75496. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75497. * @returns True if it has been started, otherwise false.
  75498. */
  75499. isStarted(): boolean;
  75500. /**
  75501. * Animates the particle system for this frame.
  75502. */
  75503. animate(): void;
  75504. /**
  75505. * Renders the particle system in its current state.
  75506. * @returns the current number of particles
  75507. */
  75508. render(): number;
  75509. /**
  75510. * Dispose the particle system and frees its associated resources.
  75511. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75512. */
  75513. dispose(disposeTexture?: boolean): void;
  75514. /**
  75515. * Clones the particle system.
  75516. * @param name The name of the cloned object
  75517. * @param newEmitter The new emitter to use
  75518. * @returns the cloned particle system
  75519. */
  75520. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75521. /**
  75522. * Serializes the particle system to a JSON object.
  75523. * @returns the JSON object
  75524. */
  75525. serialize(): any;
  75526. /**
  75527. * Rebuild the particle system
  75528. */
  75529. rebuild(): void;
  75530. /**
  75531. * Starts the particle system and begins to emit
  75532. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75533. */
  75534. start(delay?: number): void;
  75535. /**
  75536. * Stops the particle system.
  75537. */
  75538. stop(): void;
  75539. /**
  75540. * Remove all active particles
  75541. */
  75542. reset(): void;
  75543. /**
  75544. * Is this system ready to be used/rendered
  75545. * @return true if the system is ready
  75546. */
  75547. isReady(): boolean;
  75548. /**
  75549. * Adds a new color gradient
  75550. * @param gradient defines the gradient to use (between 0 and 1)
  75551. * @param color1 defines the color to affect to the specified gradient
  75552. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75553. * @returns the current particle system
  75554. */
  75555. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75556. /**
  75557. * Remove a specific color gradient
  75558. * @param gradient defines the gradient to remove
  75559. * @returns the current particle system
  75560. */
  75561. removeColorGradient(gradient: number): IParticleSystem;
  75562. /**
  75563. * Adds a new size gradient
  75564. * @param gradient defines the gradient to use (between 0 and 1)
  75565. * @param factor defines the size factor to affect to the specified gradient
  75566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75567. * @returns the current particle system
  75568. */
  75569. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75570. /**
  75571. * Remove a specific size gradient
  75572. * @param gradient defines the gradient to remove
  75573. * @returns the current particle system
  75574. */
  75575. removeSizeGradient(gradient: number): IParticleSystem;
  75576. /**
  75577. * Gets the current list of color gradients.
  75578. * You must use addColorGradient and removeColorGradient to udpate this list
  75579. * @returns the list of color gradients
  75580. */
  75581. getColorGradients(): Nullable<Array<ColorGradient>>;
  75582. /**
  75583. * Gets the current list of size gradients.
  75584. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75585. * @returns the list of size gradients
  75586. */
  75587. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75588. /**
  75589. * Gets the current list of angular speed gradients.
  75590. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75591. * @returns the list of angular speed gradients
  75592. */
  75593. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75594. /**
  75595. * Adds a new angular speed gradient
  75596. * @param gradient defines the gradient to use (between 0 and 1)
  75597. * @param factor defines the angular speed to affect to the specified gradient
  75598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75599. * @returns the current particle system
  75600. */
  75601. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75602. /**
  75603. * Remove a specific angular speed gradient
  75604. * @param gradient defines the gradient to remove
  75605. * @returns the current particle system
  75606. */
  75607. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75608. /**
  75609. * Gets the current list of velocity gradients.
  75610. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75611. * @returns the list of velocity gradients
  75612. */
  75613. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75614. /**
  75615. * Adds a new velocity gradient
  75616. * @param gradient defines the gradient to use (between 0 and 1)
  75617. * @param factor defines the velocity to affect to the specified gradient
  75618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75619. * @returns the current particle system
  75620. */
  75621. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75622. /**
  75623. * Remove a specific velocity gradient
  75624. * @param gradient defines the gradient to remove
  75625. * @returns the current particle system
  75626. */
  75627. removeVelocityGradient(gradient: number): IParticleSystem;
  75628. /**
  75629. * Gets the current list of limit velocity gradients.
  75630. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75631. * @returns the list of limit velocity gradients
  75632. */
  75633. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75634. /**
  75635. * Adds a new limit velocity gradient
  75636. * @param gradient defines the gradient to use (between 0 and 1)
  75637. * @param factor defines the limit velocity to affect to the specified gradient
  75638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75639. * @returns the current particle system
  75640. */
  75641. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75642. /**
  75643. * Remove a specific limit velocity gradient
  75644. * @param gradient defines the gradient to remove
  75645. * @returns the current particle system
  75646. */
  75647. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75648. /**
  75649. * Adds a new drag gradient
  75650. * @param gradient defines the gradient to use (between 0 and 1)
  75651. * @param factor defines the drag to affect to the specified gradient
  75652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75653. * @returns the current particle system
  75654. */
  75655. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75656. /**
  75657. * Remove a specific drag gradient
  75658. * @param gradient defines the gradient to remove
  75659. * @returns the current particle system
  75660. */
  75661. removeDragGradient(gradient: number): IParticleSystem;
  75662. /**
  75663. * Gets the current list of drag gradients.
  75664. * You must use addDragGradient and removeDragGradient to udpate this list
  75665. * @returns the list of drag gradients
  75666. */
  75667. getDragGradients(): Nullable<Array<FactorGradient>>;
  75668. /**
  75669. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75670. * @param gradient defines the gradient to use (between 0 and 1)
  75671. * @param factor defines the emit rate to affect to the specified gradient
  75672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75673. * @returns the current particle system
  75674. */
  75675. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75676. /**
  75677. * Remove a specific emit rate gradient
  75678. * @param gradient defines the gradient to remove
  75679. * @returns the current particle system
  75680. */
  75681. removeEmitRateGradient(gradient: number): IParticleSystem;
  75682. /**
  75683. * Gets the current list of emit rate gradients.
  75684. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75685. * @returns the list of emit rate gradients
  75686. */
  75687. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75688. /**
  75689. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75690. * @param gradient defines the gradient to use (between 0 and 1)
  75691. * @param factor defines the start size to affect to the specified gradient
  75692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75693. * @returns the current particle system
  75694. */
  75695. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75696. /**
  75697. * Remove a specific start size gradient
  75698. * @param gradient defines the gradient to remove
  75699. * @returns the current particle system
  75700. */
  75701. removeStartSizeGradient(gradient: number): IParticleSystem;
  75702. /**
  75703. * Gets the current list of start size gradients.
  75704. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75705. * @returns the list of start size gradients
  75706. */
  75707. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75708. /**
  75709. * Adds a new life time gradient
  75710. * @param gradient defines the gradient to use (between 0 and 1)
  75711. * @param factor defines the life time factor to affect to the specified gradient
  75712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75713. * @returns the current particle system
  75714. */
  75715. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75716. /**
  75717. * Remove a specific life time gradient
  75718. * @param gradient defines the gradient to remove
  75719. * @returns the current particle system
  75720. */
  75721. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75722. /**
  75723. * Gets the current list of life time gradients.
  75724. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75725. * @returns the list of life time gradients
  75726. */
  75727. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75728. /**
  75729. * Gets the current list of color gradients.
  75730. * You must use addColorGradient and removeColorGradient to udpate this list
  75731. * @returns the list of color gradients
  75732. */
  75733. getColorGradients(): Nullable<Array<ColorGradient>>;
  75734. /**
  75735. * Adds a new ramp gradient used to remap particle colors
  75736. * @param gradient defines the gradient to use (between 0 and 1)
  75737. * @param color defines the color to affect to the specified gradient
  75738. * @returns the current particle system
  75739. */
  75740. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75741. /**
  75742. * Gets the current list of ramp gradients.
  75743. * You must use addRampGradient and removeRampGradient to udpate this list
  75744. * @returns the list of ramp gradients
  75745. */
  75746. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75747. /** Gets or sets a boolean indicating that ramp gradients must be used
  75748. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75749. */
  75750. useRampGradients: boolean;
  75751. /**
  75752. * Adds a new color remap gradient
  75753. * @param gradient defines the gradient to use (between 0 and 1)
  75754. * @param min defines the color remap minimal range
  75755. * @param max defines the color remap maximal range
  75756. * @returns the current particle system
  75757. */
  75758. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75759. /**
  75760. * Gets the current list of color remap gradients.
  75761. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75762. * @returns the list of color remap gradients
  75763. */
  75764. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75765. /**
  75766. * Adds a new alpha remap gradient
  75767. * @param gradient defines the gradient to use (between 0 and 1)
  75768. * @param min defines the alpha remap minimal range
  75769. * @param max defines the alpha remap maximal range
  75770. * @returns the current particle system
  75771. */
  75772. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75773. /**
  75774. * Gets the current list of alpha remap gradients.
  75775. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75776. * @returns the list of alpha remap gradients
  75777. */
  75778. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75779. /**
  75780. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75783. * @returns the emitter
  75784. */
  75785. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75786. /**
  75787. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75788. * @param radius The radius of the hemisphere to emit from
  75789. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75790. * @returns the emitter
  75791. */
  75792. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75793. /**
  75794. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75795. * @param radius The radius of the sphere to emit from
  75796. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75797. * @returns the emitter
  75798. */
  75799. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75800. /**
  75801. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75802. * @param radius The radius of the sphere to emit from
  75803. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75804. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75805. * @returns the emitter
  75806. */
  75807. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75808. /**
  75809. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75810. * @param radius The radius of the emission cylinder
  75811. * @param height The height of the emission cylinder
  75812. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75813. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75814. * @returns the emitter
  75815. */
  75816. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75817. /**
  75818. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75819. * @param radius The radius of the cylinder to emit from
  75820. * @param height The height of the emission cylinder
  75821. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75824. * @returns the emitter
  75825. */
  75826. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75827. /**
  75828. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75829. * @param radius The radius of the cone to emit from
  75830. * @param angle The base angle of the cone
  75831. * @returns the emitter
  75832. */
  75833. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75834. /**
  75835. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75838. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75839. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75840. * @returns the emitter
  75841. */
  75842. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75843. /**
  75844. * Get hosting scene
  75845. * @returns the scene
  75846. */
  75847. getScene(): Scene;
  75848. }
  75849. }
  75850. declare module BABYLON {
  75851. /**
  75852. * Creates an instance based on a source mesh.
  75853. */
  75854. export class InstancedMesh extends AbstractMesh {
  75855. private _sourceMesh;
  75856. private _currentLOD;
  75857. /** @hidden */
  75858. _indexInSourceMeshInstanceArray: number;
  75859. constructor(name: string, source: Mesh);
  75860. /**
  75861. * Returns the string "InstancedMesh".
  75862. */
  75863. getClassName(): string;
  75864. /**
  75865. * If the source mesh receives shadows
  75866. */
  75867. readonly receiveShadows: boolean;
  75868. /**
  75869. * The material of the source mesh
  75870. */
  75871. readonly material: Nullable<Material>;
  75872. /**
  75873. * Visibility of the source mesh
  75874. */
  75875. readonly visibility: number;
  75876. /**
  75877. * Skeleton of the source mesh
  75878. */
  75879. readonly skeleton: Nullable<Skeleton>;
  75880. /**
  75881. * Rendering ground id of the source mesh
  75882. */
  75883. renderingGroupId: number;
  75884. /**
  75885. * Returns the total number of vertices (integer).
  75886. */
  75887. getTotalVertices(): number;
  75888. /**
  75889. * Returns a positive integer : the total number of indices in this mesh geometry.
  75890. * @returns the numner of indices or zero if the mesh has no geometry.
  75891. */
  75892. getTotalIndices(): number;
  75893. /**
  75894. * The source mesh of the instance
  75895. */
  75896. readonly sourceMesh: Mesh;
  75897. /**
  75898. * Is this node ready to be used/rendered
  75899. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75900. * @return {boolean} is it ready
  75901. */
  75902. isReady(completeCheck?: boolean): boolean;
  75903. /**
  75904. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75905. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75906. * @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.
  75907. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75908. */
  75909. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75910. /**
  75911. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75912. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75913. * The `data` are either a numeric array either a Float32Array.
  75914. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75915. * 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).
  75916. * Note that a new underlying VertexBuffer object is created each call.
  75917. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75918. *
  75919. * Possible `kind` values :
  75920. * - VertexBuffer.PositionKind
  75921. * - VertexBuffer.UVKind
  75922. * - VertexBuffer.UV2Kind
  75923. * - VertexBuffer.UV3Kind
  75924. * - VertexBuffer.UV4Kind
  75925. * - VertexBuffer.UV5Kind
  75926. * - VertexBuffer.UV6Kind
  75927. * - VertexBuffer.ColorKind
  75928. * - VertexBuffer.MatricesIndicesKind
  75929. * - VertexBuffer.MatricesIndicesExtraKind
  75930. * - VertexBuffer.MatricesWeightsKind
  75931. * - VertexBuffer.MatricesWeightsExtraKind
  75932. *
  75933. * Returns the Mesh.
  75934. */
  75935. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75936. /**
  75937. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75938. * If the mesh has no geometry, it is simply returned as it is.
  75939. * The `data` are either a numeric array either a Float32Array.
  75940. * No new underlying VertexBuffer object is created.
  75941. * 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.
  75942. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75943. *
  75944. * Possible `kind` values :
  75945. * - VertexBuffer.PositionKind
  75946. * - VertexBuffer.UVKind
  75947. * - VertexBuffer.UV2Kind
  75948. * - VertexBuffer.UV3Kind
  75949. * - VertexBuffer.UV4Kind
  75950. * - VertexBuffer.UV5Kind
  75951. * - VertexBuffer.UV6Kind
  75952. * - VertexBuffer.ColorKind
  75953. * - VertexBuffer.MatricesIndicesKind
  75954. * - VertexBuffer.MatricesIndicesExtraKind
  75955. * - VertexBuffer.MatricesWeightsKind
  75956. * - VertexBuffer.MatricesWeightsExtraKind
  75957. *
  75958. * Returns the Mesh.
  75959. */
  75960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75961. /**
  75962. * Sets the mesh indices.
  75963. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75964. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75965. * This method creates a new index buffer each call.
  75966. * Returns the Mesh.
  75967. */
  75968. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75969. /**
  75970. * Boolean : True if the mesh owns the requested kind of data.
  75971. */
  75972. isVerticesDataPresent(kind: string): boolean;
  75973. /**
  75974. * Returns an array of indices (IndicesArray).
  75975. */
  75976. getIndices(): Nullable<IndicesArray>;
  75977. readonly _positions: Nullable<Vector3[]>;
  75978. /**
  75979. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75980. * This means the mesh underlying bounding box and sphere are recomputed.
  75981. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75982. * @returns the current mesh
  75983. */
  75984. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75985. /** @hidden */
  75986. _preActivate(): InstancedMesh;
  75987. /** @hidden */
  75988. _activate(renderId: number): InstancedMesh;
  75989. /**
  75990. * Returns the current associated LOD AbstractMesh.
  75991. */
  75992. getLOD(camera: Camera): AbstractMesh;
  75993. /** @hidden */
  75994. _syncSubMeshes(): InstancedMesh;
  75995. /** @hidden */
  75996. _generatePointsArray(): boolean;
  75997. /**
  75998. * Creates a new InstancedMesh from the current mesh.
  75999. * - name (string) : the cloned mesh name
  76000. * - newParent (optional Node) : the optional Node to parent the clone to.
  76001. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76002. *
  76003. * Returns the clone.
  76004. */
  76005. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76006. /**
  76007. * Disposes the InstancedMesh.
  76008. * Returns nothing.
  76009. */
  76010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76011. }
  76012. }
  76013. declare module BABYLON {
  76014. /**
  76015. * Defines the options associated with the creation of a shader material.
  76016. */
  76017. export interface IShaderMaterialOptions {
  76018. /**
  76019. * Does the material work in alpha blend mode
  76020. */
  76021. needAlphaBlending: boolean;
  76022. /**
  76023. * Does the material work in alpha test mode
  76024. */
  76025. needAlphaTesting: boolean;
  76026. /**
  76027. * The list of attribute names used in the shader
  76028. */
  76029. attributes: string[];
  76030. /**
  76031. * The list of unifrom names used in the shader
  76032. */
  76033. uniforms: string[];
  76034. /**
  76035. * The list of UBO names used in the shader
  76036. */
  76037. uniformBuffers: string[];
  76038. /**
  76039. * The list of sampler names used in the shader
  76040. */
  76041. samplers: string[];
  76042. /**
  76043. * The list of defines used in the shader
  76044. */
  76045. defines: string[];
  76046. }
  76047. /**
  76048. * 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.
  76049. *
  76050. * This returned material effects how the mesh will look based on the code in the shaders.
  76051. *
  76052. * @see http://doc.babylonjs.com/how_to/shader_material
  76053. */
  76054. export class ShaderMaterial extends Material {
  76055. private _shaderPath;
  76056. private _options;
  76057. private _textures;
  76058. private _textureArrays;
  76059. private _floats;
  76060. private _ints;
  76061. private _floatsArrays;
  76062. private _colors3;
  76063. private _colors3Arrays;
  76064. private _colors4;
  76065. private _vectors2;
  76066. private _vectors3;
  76067. private _vectors4;
  76068. private _matrices;
  76069. private _matrices3x3;
  76070. private _matrices2x2;
  76071. private _vectors2Arrays;
  76072. private _vectors3Arrays;
  76073. private _cachedWorldViewMatrix;
  76074. private _renderId;
  76075. /**
  76076. * Instantiate a new shader material.
  76077. * 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.
  76078. * This returned material effects how the mesh will look based on the code in the shaders.
  76079. * @see http://doc.babylonjs.com/how_to/shader_material
  76080. * @param name Define the name of the material in the scene
  76081. * @param scene Define the scene the material belongs to
  76082. * @param shaderPath Defines the route to the shader code in one of three ways:
  76083. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76084. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76085. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76086. * @param options Define the options used to create the shader
  76087. */
  76088. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76089. /**
  76090. * Gets the options used to compile the shader.
  76091. * They can be modified to trigger a new compilation
  76092. */
  76093. readonly options: IShaderMaterialOptions;
  76094. /**
  76095. * Gets the current class name of the material e.g. "ShaderMaterial"
  76096. * Mainly use in serialization.
  76097. * @returns the class name
  76098. */
  76099. getClassName(): string;
  76100. /**
  76101. * Specifies if the material will require alpha blending
  76102. * @returns a boolean specifying if alpha blending is needed
  76103. */
  76104. needAlphaBlending(): boolean;
  76105. /**
  76106. * Specifies if this material should be rendered in alpha test mode
  76107. * @returns a boolean specifying if an alpha test is needed.
  76108. */
  76109. needAlphaTesting(): boolean;
  76110. private _checkUniform;
  76111. /**
  76112. * Set a texture in the shader.
  76113. * @param name Define the name of the uniform samplers as defined in the shader
  76114. * @param texture Define the texture to bind to this sampler
  76115. * @return the material itself allowing "fluent" like uniform updates
  76116. */
  76117. setTexture(name: string, texture: Texture): ShaderMaterial;
  76118. /**
  76119. * Set a texture array in the shader.
  76120. * @param name Define the name of the uniform sampler array as defined in the shader
  76121. * @param textures Define the list of textures to bind to this sampler
  76122. * @return the material itself allowing "fluent" like uniform updates
  76123. */
  76124. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76125. /**
  76126. * Set a float in the shader.
  76127. * @param name Define the name of the uniform as defined in the shader
  76128. * @param value Define the value to give to the uniform
  76129. * @return the material itself allowing "fluent" like uniform updates
  76130. */
  76131. setFloat(name: string, value: number): ShaderMaterial;
  76132. /**
  76133. * Set a int in the shader.
  76134. * @param name Define the name of the uniform as defined in the shader
  76135. * @param value Define the value to give to the uniform
  76136. * @return the material itself allowing "fluent" like uniform updates
  76137. */
  76138. setInt(name: string, value: number): ShaderMaterial;
  76139. /**
  76140. * Set an array of floats in the shader.
  76141. * @param name Define the name of the uniform as defined in the shader
  76142. * @param value Define the value to give to the uniform
  76143. * @return the material itself allowing "fluent" like uniform updates
  76144. */
  76145. setFloats(name: string, value: number[]): ShaderMaterial;
  76146. /**
  76147. * Set a vec3 in the shader from a Color3.
  76148. * @param name Define the name of the uniform as defined in the shader
  76149. * @param value Define the value to give to the uniform
  76150. * @return the material itself allowing "fluent" like uniform updates
  76151. */
  76152. setColor3(name: string, value: Color3): ShaderMaterial;
  76153. /**
  76154. * Set a vec3 array in the shader from a Color3 array.
  76155. * @param name Define the name of the uniform as defined in the shader
  76156. * @param value Define the value to give to the uniform
  76157. * @return the material itself allowing "fluent" like uniform updates
  76158. */
  76159. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76160. /**
  76161. * Set a vec4 in the shader from a Color4.
  76162. * @param name Define the name of the uniform as defined in the shader
  76163. * @param value Define the value to give to the uniform
  76164. * @return the material itself allowing "fluent" like uniform updates
  76165. */
  76166. setColor4(name: string, value: Color4): ShaderMaterial;
  76167. /**
  76168. * Set a vec2 in the shader from a Vector2.
  76169. * @param name Define the name of the uniform as defined in the shader
  76170. * @param value Define the value to give to the uniform
  76171. * @return the material itself allowing "fluent" like uniform updates
  76172. */
  76173. setVector2(name: string, value: Vector2): ShaderMaterial;
  76174. /**
  76175. * Set a vec3 in the shader from a Vector3.
  76176. * @param name Define the name of the uniform as defined in the shader
  76177. * @param value Define the value to give to the uniform
  76178. * @return the material itself allowing "fluent" like uniform updates
  76179. */
  76180. setVector3(name: string, value: Vector3): ShaderMaterial;
  76181. /**
  76182. * Set a vec4 in the shader from a Vector4.
  76183. * @param name Define the name of the uniform as defined in the shader
  76184. * @param value Define the value to give to the uniform
  76185. * @return the material itself allowing "fluent" like uniform updates
  76186. */
  76187. setVector4(name: string, value: Vector4): ShaderMaterial;
  76188. /**
  76189. * Set a mat4 in the shader from a Matrix.
  76190. * @param name Define the name of the uniform as defined in the shader
  76191. * @param value Define the value to give to the uniform
  76192. * @return the material itself allowing "fluent" like uniform updates
  76193. */
  76194. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76195. /**
  76196. * Set a mat3 in the shader from a Float32Array.
  76197. * @param name Define the name of the uniform as defined in the shader
  76198. * @param value Define the value to give to the uniform
  76199. * @return the material itself allowing "fluent" like uniform updates
  76200. */
  76201. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76202. /**
  76203. * Set a mat2 in the shader from a Float32Array.
  76204. * @param name Define the name of the uniform as defined in the shader
  76205. * @param value Define the value to give to the uniform
  76206. * @return the material itself allowing "fluent" like uniform updates
  76207. */
  76208. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76209. /**
  76210. * Set a vec2 array in the shader from a number array.
  76211. * @param name Define the name of the uniform as defined in the shader
  76212. * @param value Define the value to give to the uniform
  76213. * @return the material itself allowing "fluent" like uniform updates
  76214. */
  76215. setArray2(name: string, value: number[]): ShaderMaterial;
  76216. /**
  76217. * Set a vec3 array in the shader from a number array.
  76218. * @param name Define the name of the uniform as defined in the shader
  76219. * @param value Define the value to give to the uniform
  76220. * @return the material itself allowing "fluent" like uniform updates
  76221. */
  76222. setArray3(name: string, value: number[]): ShaderMaterial;
  76223. private _checkCache;
  76224. /**
  76225. * Specifies that the submesh is ready to be used
  76226. * @param mesh defines the mesh to check
  76227. * @param subMesh defines which submesh to check
  76228. * @param useInstances specifies that instances should be used
  76229. * @returns a boolean indicating that the submesh is ready or not
  76230. */
  76231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76232. /**
  76233. * Checks if the material is ready to render the requested mesh
  76234. * @param mesh Define the mesh to render
  76235. * @param useInstances Define whether or not the material is used with instances
  76236. * @returns true if ready, otherwise false
  76237. */
  76238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76239. /**
  76240. * Binds the world matrix to the material
  76241. * @param world defines the world transformation matrix
  76242. */
  76243. bindOnlyWorldMatrix(world: Matrix): void;
  76244. /**
  76245. * Binds the material to the mesh
  76246. * @param world defines the world transformation matrix
  76247. * @param mesh defines the mesh to bind the material to
  76248. */
  76249. bind(world: Matrix, mesh?: Mesh): void;
  76250. /**
  76251. * Gets the active textures from the material
  76252. * @returns an array of textures
  76253. */
  76254. getActiveTextures(): BaseTexture[];
  76255. /**
  76256. * Specifies if the material uses a texture
  76257. * @param texture defines the texture to check against the material
  76258. * @returns a boolean specifying if the material uses the texture
  76259. */
  76260. hasTexture(texture: BaseTexture): boolean;
  76261. /**
  76262. * Makes a duplicate of the material, and gives it a new name
  76263. * @param name defines the new name for the duplicated material
  76264. * @returns the cloned material
  76265. */
  76266. clone(name: string): ShaderMaterial;
  76267. /**
  76268. * Disposes the material
  76269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76271. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76272. */
  76273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76274. /**
  76275. * Serializes this material in a JSON representation
  76276. * @returns the serialized material object
  76277. */
  76278. serialize(): any;
  76279. /**
  76280. * Creates a shader material from parsed shader material data
  76281. * @param source defines the JSON represnetation of the material
  76282. * @param scene defines the hosting scene
  76283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76284. * @returns a new material
  76285. */
  76286. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76287. }
  76288. }
  76289. declare module BABYLON {
  76290. /** @hidden */
  76291. export var colorPixelShader: {
  76292. name: string;
  76293. shader: string;
  76294. };
  76295. }
  76296. declare module BABYLON {
  76297. /** @hidden */
  76298. export var colorVertexShader: {
  76299. name: string;
  76300. shader: string;
  76301. };
  76302. }
  76303. declare module BABYLON {
  76304. /**
  76305. * Line mesh
  76306. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76307. */
  76308. export class LinesMesh extends Mesh {
  76309. /**
  76310. * If vertex color should be applied to the mesh
  76311. */
  76312. useVertexColor?: boolean | undefined;
  76313. /**
  76314. * If vertex alpha should be applied to the mesh
  76315. */
  76316. useVertexAlpha?: boolean | undefined;
  76317. /**
  76318. * Color of the line (Default: White)
  76319. */
  76320. color: Color3;
  76321. /**
  76322. * Alpha of the line (Default: 1)
  76323. */
  76324. alpha: number;
  76325. /**
  76326. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76327. * This margin is expressed in world space coordinates, so its value may vary.
  76328. * Default value is 0.1
  76329. */
  76330. intersectionThreshold: number;
  76331. private _colorShader;
  76332. /**
  76333. * Creates a new LinesMesh
  76334. * @param name defines the name
  76335. * @param scene defines the hosting scene
  76336. * @param parent defines the parent mesh if any
  76337. * @param source defines the optional source LinesMesh used to clone data from
  76338. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76339. * When false, achieved by calling a clone(), also passing False.
  76340. * This will make creation of children, recursive.
  76341. * @param useVertexColor defines if this LinesMesh supports vertex color
  76342. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76343. */
  76344. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76345. /**
  76346. * If vertex color should be applied to the mesh
  76347. */
  76348. useVertexColor?: boolean | undefined,
  76349. /**
  76350. * If vertex alpha should be applied to the mesh
  76351. */
  76352. useVertexAlpha?: boolean | undefined);
  76353. private _addClipPlaneDefine;
  76354. private _removeClipPlaneDefine;
  76355. isReady(): boolean;
  76356. /**
  76357. * Returns the string "LineMesh"
  76358. */
  76359. getClassName(): string;
  76360. /**
  76361. * @hidden
  76362. */
  76363. /**
  76364. * @hidden
  76365. */
  76366. material: Material;
  76367. /**
  76368. * @hidden
  76369. */
  76370. readonly checkCollisions: boolean;
  76371. /** @hidden */
  76372. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76373. /** @hidden */
  76374. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76375. /**
  76376. * Disposes of the line mesh
  76377. * @param doNotRecurse If children should be disposed
  76378. */
  76379. dispose(doNotRecurse?: boolean): void;
  76380. /**
  76381. * Returns a new LineMesh object cloned from the current one.
  76382. */
  76383. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76384. /**
  76385. * Creates a new InstancedLinesMesh object from the mesh model.
  76386. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76387. * @param name defines the name of the new instance
  76388. * @returns a new InstancedLinesMesh
  76389. */
  76390. createInstance(name: string): InstancedLinesMesh;
  76391. }
  76392. /**
  76393. * Creates an instance based on a source LinesMesh
  76394. */
  76395. export class InstancedLinesMesh extends InstancedMesh {
  76396. /**
  76397. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76398. * This margin is expressed in world space coordinates, so its value may vary.
  76399. * Initilized with the intersectionThreshold value of the source LinesMesh
  76400. */
  76401. intersectionThreshold: number;
  76402. constructor(name: string, source: LinesMesh);
  76403. /**
  76404. * Returns the string "InstancedLinesMesh".
  76405. */
  76406. getClassName(): string;
  76407. }
  76408. }
  76409. declare module BABYLON {
  76410. /** @hidden */
  76411. export var linePixelShader: {
  76412. name: string;
  76413. shader: string;
  76414. };
  76415. }
  76416. declare module BABYLON {
  76417. /** @hidden */
  76418. export var lineVertexShader: {
  76419. name: string;
  76420. shader: string;
  76421. };
  76422. }
  76423. declare module BABYLON {
  76424. interface AbstractMesh {
  76425. /**
  76426. * Disables the mesh edge rendering mode
  76427. * @returns the currentAbstractMesh
  76428. */
  76429. disableEdgesRendering(): AbstractMesh;
  76430. /**
  76431. * Enables the edge rendering mode on the mesh.
  76432. * This mode makes the mesh edges visible
  76433. * @param epsilon defines the maximal distance between two angles to detect a face
  76434. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76435. * @returns the currentAbstractMesh
  76436. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76437. */
  76438. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76439. /**
  76440. * Gets the edgesRenderer associated with the mesh
  76441. */
  76442. edgesRenderer: Nullable<EdgesRenderer>;
  76443. }
  76444. interface LinesMesh {
  76445. /**
  76446. * Enables the edge rendering mode on the mesh.
  76447. * This mode makes the mesh edges visible
  76448. * @param epsilon defines the maximal distance between two angles to detect a face
  76449. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76450. * @returns the currentAbstractMesh
  76451. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76452. */
  76453. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76454. }
  76455. interface InstancedLinesMesh {
  76456. /**
  76457. * Enables the edge rendering mode on the mesh.
  76458. * This mode makes the mesh edges visible
  76459. * @param epsilon defines the maximal distance between two angles to detect a face
  76460. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76461. * @returns the current InstancedLinesMesh
  76462. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76463. */
  76464. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76465. }
  76466. /**
  76467. * Defines the minimum contract an Edges renderer should follow.
  76468. */
  76469. export interface IEdgesRenderer extends IDisposable {
  76470. /**
  76471. * Gets or sets a boolean indicating if the edgesRenderer is active
  76472. */
  76473. isEnabled: boolean;
  76474. /**
  76475. * Renders the edges of the attached mesh,
  76476. */
  76477. render(): void;
  76478. /**
  76479. * Checks wether or not the edges renderer is ready to render.
  76480. * @return true if ready, otherwise false.
  76481. */
  76482. isReady(): boolean;
  76483. }
  76484. /**
  76485. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76486. */
  76487. export class EdgesRenderer implements IEdgesRenderer {
  76488. /**
  76489. * Define the size of the edges with an orthographic camera
  76490. */
  76491. edgesWidthScalerForOrthographic: number;
  76492. /**
  76493. * Define the size of the edges with a perspective camera
  76494. */
  76495. edgesWidthScalerForPerspective: number;
  76496. protected _source: AbstractMesh;
  76497. protected _linesPositions: number[];
  76498. protected _linesNormals: number[];
  76499. protected _linesIndices: number[];
  76500. protected _epsilon: number;
  76501. protected _indicesCount: number;
  76502. protected _lineShader: ShaderMaterial;
  76503. protected _ib: WebGLBuffer;
  76504. protected _buffers: {
  76505. [key: string]: Nullable<VertexBuffer>;
  76506. };
  76507. protected _checkVerticesInsteadOfIndices: boolean;
  76508. private _meshRebuildObserver;
  76509. private _meshDisposeObserver;
  76510. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76511. isEnabled: boolean;
  76512. /**
  76513. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76514. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76515. * @param source Mesh used to create edges
  76516. * @param epsilon sum of angles in adjacency to check for edge
  76517. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76518. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76519. */
  76520. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76521. protected _prepareRessources(): void;
  76522. /** @hidden */
  76523. _rebuild(): void;
  76524. /**
  76525. * Releases the required resources for the edges renderer
  76526. */
  76527. dispose(): void;
  76528. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76529. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76530. /**
  76531. * Checks if the pair of p0 and p1 is en edge
  76532. * @param faceIndex
  76533. * @param edge
  76534. * @param faceNormals
  76535. * @param p0
  76536. * @param p1
  76537. * @private
  76538. */
  76539. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76540. /**
  76541. * push line into the position, normal and index buffer
  76542. * @protected
  76543. */
  76544. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76545. /**
  76546. * Generates lines edges from adjacencjes
  76547. * @private
  76548. */
  76549. _generateEdgesLines(): void;
  76550. /**
  76551. * Checks wether or not the edges renderer is ready to render.
  76552. * @return true if ready, otherwise false.
  76553. */
  76554. isReady(): boolean;
  76555. /**
  76556. * Renders the edges of the attached mesh,
  76557. */
  76558. render(): void;
  76559. }
  76560. /**
  76561. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76562. */
  76563. export class LineEdgesRenderer extends EdgesRenderer {
  76564. /**
  76565. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76566. * @param source LineMesh used to generate edges
  76567. * @param epsilon not important (specified angle for edge detection)
  76568. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76569. */
  76570. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76571. /**
  76572. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76573. */
  76574. _generateEdgesLines(): void;
  76575. }
  76576. }
  76577. declare module BABYLON {
  76578. /**
  76579. * This represents the object necessary to create a rendering group.
  76580. * This is exclusively used and created by the rendering manager.
  76581. * To modify the behavior, you use the available helpers in your scene or meshes.
  76582. * @hidden
  76583. */
  76584. export class RenderingGroup {
  76585. index: number;
  76586. private _scene;
  76587. private _opaqueSubMeshes;
  76588. private _transparentSubMeshes;
  76589. private _alphaTestSubMeshes;
  76590. private _depthOnlySubMeshes;
  76591. private _particleSystems;
  76592. private _spriteManagers;
  76593. private _opaqueSortCompareFn;
  76594. private _alphaTestSortCompareFn;
  76595. private _transparentSortCompareFn;
  76596. private _renderOpaque;
  76597. private _renderAlphaTest;
  76598. private _renderTransparent;
  76599. private _edgesRenderers;
  76600. onBeforeTransparentRendering: () => void;
  76601. /**
  76602. * Set the opaque sort comparison function.
  76603. * If null the sub meshes will be render in the order they were created
  76604. */
  76605. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76606. /**
  76607. * Set the alpha test sort comparison function.
  76608. * If null the sub meshes will be render in the order they were created
  76609. */
  76610. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76611. /**
  76612. * Set the transparent sort comparison function.
  76613. * If null the sub meshes will be render in the order they were created
  76614. */
  76615. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76616. /**
  76617. * Creates a new rendering group.
  76618. * @param index The rendering group index
  76619. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76620. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76621. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76622. */
  76623. 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>);
  76624. /**
  76625. * Render all the sub meshes contained in the group.
  76626. * @param customRenderFunction Used to override the default render behaviour of the group.
  76627. * @returns true if rendered some submeshes.
  76628. */
  76629. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76630. /**
  76631. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76632. * @param subMeshes The submeshes to render
  76633. */
  76634. private renderOpaqueSorted;
  76635. /**
  76636. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76637. * @param subMeshes The submeshes to render
  76638. */
  76639. private renderAlphaTestSorted;
  76640. /**
  76641. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76642. * @param subMeshes The submeshes to render
  76643. */
  76644. private renderTransparentSorted;
  76645. /**
  76646. * Renders the submeshes in a specified order.
  76647. * @param subMeshes The submeshes to sort before render
  76648. * @param sortCompareFn The comparison function use to sort
  76649. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76650. * @param transparent Specifies to activate blending if true
  76651. */
  76652. private static renderSorted;
  76653. /**
  76654. * Renders the submeshes in the order they were dispatched (no sort applied).
  76655. * @param subMeshes The submeshes to render
  76656. */
  76657. private static renderUnsorted;
  76658. /**
  76659. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76660. * are rendered back to front if in the same alpha index.
  76661. *
  76662. * @param a The first submesh
  76663. * @param b The second submesh
  76664. * @returns The result of the comparison
  76665. */
  76666. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76667. /**
  76668. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76669. * are rendered back to front.
  76670. *
  76671. * @param a The first submesh
  76672. * @param b The second submesh
  76673. * @returns The result of the comparison
  76674. */
  76675. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76676. /**
  76677. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76678. * are rendered front to back (prevent overdraw).
  76679. *
  76680. * @param a The first submesh
  76681. * @param b The second submesh
  76682. * @returns The result of the comparison
  76683. */
  76684. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76685. /**
  76686. * Resets the different lists of submeshes to prepare a new frame.
  76687. */
  76688. prepare(): void;
  76689. dispose(): void;
  76690. /**
  76691. * Inserts the submesh in its correct queue depending on its material.
  76692. * @param subMesh The submesh to dispatch
  76693. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76694. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76695. */
  76696. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76697. dispatchSprites(spriteManager: ISpriteManager): void;
  76698. dispatchParticles(particleSystem: IParticleSystem): void;
  76699. private _renderParticles;
  76700. private _renderSprites;
  76701. }
  76702. }
  76703. declare module BABYLON {
  76704. /**
  76705. * Interface describing the different options available in the rendering manager
  76706. * regarding Auto Clear between groups.
  76707. */
  76708. export interface IRenderingManagerAutoClearSetup {
  76709. /**
  76710. * Defines whether or not autoclear is enable.
  76711. */
  76712. autoClear: boolean;
  76713. /**
  76714. * Defines whether or not to autoclear the depth buffer.
  76715. */
  76716. depth: boolean;
  76717. /**
  76718. * Defines whether or not to autoclear the stencil buffer.
  76719. */
  76720. stencil: boolean;
  76721. }
  76722. /**
  76723. * This class is used by the onRenderingGroupObservable
  76724. */
  76725. export class RenderingGroupInfo {
  76726. /**
  76727. * The Scene that being rendered
  76728. */
  76729. scene: Scene;
  76730. /**
  76731. * The camera currently used for the rendering pass
  76732. */
  76733. camera: Nullable<Camera>;
  76734. /**
  76735. * The ID of the renderingGroup being processed
  76736. */
  76737. renderingGroupId: number;
  76738. }
  76739. /**
  76740. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76741. * It is enable to manage the different groups as well as the different necessary sort functions.
  76742. * This should not be used directly aside of the few static configurations
  76743. */
  76744. export class RenderingManager {
  76745. /**
  76746. * The max id used for rendering groups (not included)
  76747. */
  76748. static MAX_RENDERINGGROUPS: number;
  76749. /**
  76750. * The min id used for rendering groups (included)
  76751. */
  76752. static MIN_RENDERINGGROUPS: number;
  76753. /**
  76754. * Used to globally prevent autoclearing scenes.
  76755. */
  76756. static AUTOCLEAR: boolean;
  76757. /**
  76758. * @hidden
  76759. */
  76760. _useSceneAutoClearSetup: boolean;
  76761. private _scene;
  76762. private _renderingGroups;
  76763. private _depthStencilBufferAlreadyCleaned;
  76764. private _autoClearDepthStencil;
  76765. private _customOpaqueSortCompareFn;
  76766. private _customAlphaTestSortCompareFn;
  76767. private _customTransparentSortCompareFn;
  76768. private _renderingGroupInfo;
  76769. /**
  76770. * Instantiates a new rendering group for a particular scene
  76771. * @param scene Defines the scene the groups belongs to
  76772. */
  76773. constructor(scene: Scene);
  76774. private _clearDepthStencilBuffer;
  76775. /**
  76776. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76777. * @hidden
  76778. */
  76779. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76780. /**
  76781. * Resets the different information of the group to prepare a new frame
  76782. * @hidden
  76783. */
  76784. reset(): void;
  76785. /**
  76786. * Dispose and release the group and its associated resources.
  76787. * @hidden
  76788. */
  76789. dispose(): void;
  76790. /**
  76791. * Clear the info related to rendering groups preventing retention points during dispose.
  76792. */
  76793. freeRenderingGroups(): void;
  76794. private _prepareRenderingGroup;
  76795. /**
  76796. * Add a sprite manager to the rendering manager in order to render it this frame.
  76797. * @param spriteManager Define the sprite manager to render
  76798. */
  76799. dispatchSprites(spriteManager: ISpriteManager): void;
  76800. /**
  76801. * Add a particle system to the rendering manager in order to render it this frame.
  76802. * @param particleSystem Define the particle system to render
  76803. */
  76804. dispatchParticles(particleSystem: IParticleSystem): void;
  76805. /**
  76806. * Add a submesh to the manager in order to render it this frame
  76807. * @param subMesh The submesh to dispatch
  76808. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76809. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76810. */
  76811. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76812. /**
  76813. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76814. * This allowed control for front to back rendering or reversly depending of the special needs.
  76815. *
  76816. * @param renderingGroupId The rendering group id corresponding to its index
  76817. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76818. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76819. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76820. */
  76821. 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;
  76822. /**
  76823. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76824. *
  76825. * @param renderingGroupId The rendering group id corresponding to its index
  76826. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76827. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76828. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76829. */
  76830. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76831. /**
  76832. * Gets the current auto clear configuration for one rendering group of the rendering
  76833. * manager.
  76834. * @param index the rendering group index to get the information for
  76835. * @returns The auto clear setup for the requested rendering group
  76836. */
  76837. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76838. }
  76839. }
  76840. declare module BABYLON {
  76841. /**
  76842. * This Helps creating a texture that will be created from a camera in your scene.
  76843. * It is basically a dynamic texture that could be used to create special effects for instance.
  76844. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76845. */
  76846. export class RenderTargetTexture extends Texture {
  76847. isCube: boolean;
  76848. /**
  76849. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76850. */
  76851. static readonly REFRESHRATE_RENDER_ONCE: number;
  76852. /**
  76853. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76854. */
  76855. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76856. /**
  76857. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76858. * the central point of your effect and can save a lot of performances.
  76859. */
  76860. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76861. /**
  76862. * Use this predicate to dynamically define the list of mesh you want to render.
  76863. * If set, the renderList property will be overwritten.
  76864. */
  76865. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76866. private _renderList;
  76867. /**
  76868. * Use this list to define the list of mesh you want to render.
  76869. */
  76870. renderList: Nullable<Array<AbstractMesh>>;
  76871. private _hookArray;
  76872. /**
  76873. * Define if particles should be rendered in your texture.
  76874. */
  76875. renderParticles: boolean;
  76876. /**
  76877. * Define if sprites should be rendered in your texture.
  76878. */
  76879. renderSprites: boolean;
  76880. /**
  76881. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76882. */
  76883. coordinatesMode: number;
  76884. /**
  76885. * Define the camera used to render the texture.
  76886. */
  76887. activeCamera: Nullable<Camera>;
  76888. /**
  76889. * Override the render function of the texture with your own one.
  76890. */
  76891. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76892. /**
  76893. * Define if camera post processes should be use while rendering the texture.
  76894. */
  76895. useCameraPostProcesses: boolean;
  76896. /**
  76897. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76898. */
  76899. ignoreCameraViewport: boolean;
  76900. private _postProcessManager;
  76901. private _postProcesses;
  76902. private _resizeObserver;
  76903. /**
  76904. * An event triggered when the texture is unbind.
  76905. */
  76906. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76907. /**
  76908. * An event triggered when the texture is unbind.
  76909. */
  76910. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76911. private _onAfterUnbindObserver;
  76912. /**
  76913. * Set a after unbind callback in the texture.
  76914. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76915. */
  76916. onAfterUnbind: () => void;
  76917. /**
  76918. * An event triggered before rendering the texture
  76919. */
  76920. onBeforeRenderObservable: Observable<number>;
  76921. private _onBeforeRenderObserver;
  76922. /**
  76923. * Set a before render callback in the texture.
  76924. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76925. */
  76926. onBeforeRender: (faceIndex: number) => void;
  76927. /**
  76928. * An event triggered after rendering the texture
  76929. */
  76930. onAfterRenderObservable: Observable<number>;
  76931. private _onAfterRenderObserver;
  76932. /**
  76933. * Set a after render callback in the texture.
  76934. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76935. */
  76936. onAfterRender: (faceIndex: number) => void;
  76937. /**
  76938. * An event triggered after the texture clear
  76939. */
  76940. onClearObservable: Observable<Engine>;
  76941. private _onClearObserver;
  76942. /**
  76943. * Set a clear callback in the texture.
  76944. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76945. */
  76946. onClear: (Engine: Engine) => void;
  76947. /**
  76948. * Define the clear color of the Render Target if it should be different from the scene.
  76949. */
  76950. clearColor: Color4;
  76951. protected _size: number | {
  76952. width: number;
  76953. height: number;
  76954. };
  76955. protected _initialSizeParameter: number | {
  76956. width: number;
  76957. height: number;
  76958. } | {
  76959. ratio: number;
  76960. };
  76961. protected _sizeRatio: Nullable<number>;
  76962. /** @hidden */
  76963. _generateMipMaps: boolean;
  76964. protected _renderingManager: RenderingManager;
  76965. /** @hidden */
  76966. _waitingRenderList: string[];
  76967. protected _doNotChangeAspectRatio: boolean;
  76968. protected _currentRefreshId: number;
  76969. protected _refreshRate: number;
  76970. protected _textureMatrix: Matrix;
  76971. protected _samples: number;
  76972. protected _renderTargetOptions: RenderTargetCreationOptions;
  76973. /**
  76974. * Gets render target creation options that were used.
  76975. */
  76976. readonly renderTargetOptions: RenderTargetCreationOptions;
  76977. protected _engine: Engine;
  76978. protected _onRatioRescale(): void;
  76979. /**
  76980. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76981. * It must define where the camera used to render the texture is set
  76982. */
  76983. boundingBoxPosition: Vector3;
  76984. private _boundingBoxSize;
  76985. /**
  76986. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76987. * When defined, the cubemap will switch to local mode
  76988. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76989. * @example https://www.babylonjs-playground.com/#RNASML
  76990. */
  76991. boundingBoxSize: Vector3;
  76992. /**
  76993. * In case the RTT has been created with a depth texture, get the associated
  76994. * depth texture.
  76995. * Otherwise, return null.
  76996. */
  76997. depthStencilTexture: Nullable<InternalTexture>;
  76998. /**
  76999. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77000. * or used a shadow, depth texture...
  77001. * @param name The friendly name of the texture
  77002. * @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)
  77003. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77004. * @param generateMipMaps True if mip maps need to be generated after render.
  77005. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77006. * @param type The type of the buffer in the RTT (int, half float, float...)
  77007. * @param isCube True if a cube texture needs to be created
  77008. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77009. * @param generateDepthBuffer True to generate a depth buffer
  77010. * @param generateStencilBuffer True to generate a stencil buffer
  77011. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77012. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77013. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77014. */
  77015. constructor(name: string, size: number | {
  77016. width: number;
  77017. height: number;
  77018. } | {
  77019. ratio: number;
  77020. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77021. /**
  77022. * Creates a depth stencil texture.
  77023. * This is only available in WebGL 2 or with the depth texture extension available.
  77024. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77025. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77026. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77027. */
  77028. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77029. private _processSizeParameter;
  77030. /**
  77031. * Define the number of samples to use in case of MSAA.
  77032. * It defaults to one meaning no MSAA has been enabled.
  77033. */
  77034. samples: number;
  77035. /**
  77036. * Resets the refresh counter of the texture and start bak from scratch.
  77037. * Could be useful to regenerate the texture if it is setup to render only once.
  77038. */
  77039. resetRefreshCounter(): void;
  77040. /**
  77041. * Define the refresh rate of the texture or the rendering frequency.
  77042. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77043. */
  77044. refreshRate: number;
  77045. /**
  77046. * Adds a post process to the render target rendering passes.
  77047. * @param postProcess define the post process to add
  77048. */
  77049. addPostProcess(postProcess: PostProcess): void;
  77050. /**
  77051. * Clear all the post processes attached to the render target
  77052. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77053. */
  77054. clearPostProcesses(dispose?: boolean): void;
  77055. /**
  77056. * Remove one of the post process from the list of attached post processes to the texture
  77057. * @param postProcess define the post process to remove from the list
  77058. */
  77059. removePostProcess(postProcess: PostProcess): void;
  77060. /** @hidden */
  77061. _shouldRender(): boolean;
  77062. /**
  77063. * Gets the actual render size of the texture.
  77064. * @returns the width of the render size
  77065. */
  77066. getRenderSize(): number;
  77067. /**
  77068. * Gets the actual render width of the texture.
  77069. * @returns the width of the render size
  77070. */
  77071. getRenderWidth(): number;
  77072. /**
  77073. * Gets the actual render height of the texture.
  77074. * @returns the height of the render size
  77075. */
  77076. getRenderHeight(): number;
  77077. /**
  77078. * Get if the texture can be rescaled or not.
  77079. */
  77080. readonly canRescale: boolean;
  77081. /**
  77082. * Resize the texture using a ratio.
  77083. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77084. */
  77085. scale(ratio: number): void;
  77086. /**
  77087. * Get the texture reflection matrix used to rotate/transform the reflection.
  77088. * @returns the reflection matrix
  77089. */
  77090. getReflectionTextureMatrix(): Matrix;
  77091. /**
  77092. * Resize the texture to a new desired size.
  77093. * Be carrefull as it will recreate all the data in the new texture.
  77094. * @param size Define the new size. It can be:
  77095. * - a number for squared texture,
  77096. * - an object containing { width: number, height: number }
  77097. * - or an object containing a ratio { ratio: number }
  77098. */
  77099. resize(size: number | {
  77100. width: number;
  77101. height: number;
  77102. } | {
  77103. ratio: number;
  77104. }): void;
  77105. /**
  77106. * Renders all the objects from the render list into the texture.
  77107. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77108. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77109. */
  77110. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77111. private _bestReflectionRenderTargetDimension;
  77112. /**
  77113. * @hidden
  77114. * @param faceIndex face index to bind to if this is a cubetexture
  77115. */
  77116. _bindFrameBuffer(faceIndex?: number): void;
  77117. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77118. private renderToTarget;
  77119. /**
  77120. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77121. * This allowed control for front to back rendering or reversly depending of the special needs.
  77122. *
  77123. * @param renderingGroupId The rendering group id corresponding to its index
  77124. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77125. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77126. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77127. */
  77128. 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;
  77129. /**
  77130. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77131. *
  77132. * @param renderingGroupId The rendering group id corresponding to its index
  77133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77134. */
  77135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77136. /**
  77137. * Clones the texture.
  77138. * @returns the cloned texture
  77139. */
  77140. clone(): RenderTargetTexture;
  77141. /**
  77142. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77143. * @returns The JSON representation of the texture
  77144. */
  77145. serialize(): any;
  77146. /**
  77147. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77148. */
  77149. disposeFramebufferObjects(): void;
  77150. /**
  77151. * Dispose the texture and release its associated resources.
  77152. */
  77153. dispose(): void;
  77154. /** @hidden */
  77155. _rebuild(): void;
  77156. /**
  77157. * Clear the info related to rendering groups preventing retention point in material dispose.
  77158. */
  77159. freeRenderingGroups(): void;
  77160. /**
  77161. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77162. * @returns the view count
  77163. */
  77164. getViewCount(): number;
  77165. }
  77166. }
  77167. declare module BABYLON {
  77168. /**
  77169. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77170. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77171. * You can then easily use it as a reflectionTexture on a flat surface.
  77172. * In case the surface is not a plane, please consider relying on reflection probes.
  77173. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77174. */
  77175. export class MirrorTexture extends RenderTargetTexture {
  77176. private scene;
  77177. /**
  77178. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77179. * 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.
  77180. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77181. */
  77182. mirrorPlane: Plane;
  77183. /**
  77184. * Define the blur ratio used to blur the reflection if needed.
  77185. */
  77186. blurRatio: number;
  77187. /**
  77188. * Define the adaptive blur kernel used to blur the reflection if needed.
  77189. * This will autocompute the closest best match for the `blurKernel`
  77190. */
  77191. adaptiveBlurKernel: number;
  77192. /**
  77193. * Define the blur kernel used to blur the reflection if needed.
  77194. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77195. */
  77196. blurKernel: number;
  77197. /**
  77198. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77199. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77200. */
  77201. blurKernelX: number;
  77202. /**
  77203. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77204. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77205. */
  77206. blurKernelY: number;
  77207. private _autoComputeBlurKernel;
  77208. protected _onRatioRescale(): void;
  77209. private _updateGammaSpace;
  77210. private _imageProcessingConfigChangeObserver;
  77211. private _transformMatrix;
  77212. private _mirrorMatrix;
  77213. private _savedViewMatrix;
  77214. private _blurX;
  77215. private _blurY;
  77216. private _adaptiveBlurKernel;
  77217. private _blurKernelX;
  77218. private _blurKernelY;
  77219. private _blurRatio;
  77220. /**
  77221. * Instantiates a Mirror Texture.
  77222. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77223. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77224. * You can then easily use it as a reflectionTexture on a flat surface.
  77225. * In case the surface is not a plane, please consider relying on reflection probes.
  77226. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77227. * @param name
  77228. * @param size
  77229. * @param scene
  77230. * @param generateMipMaps
  77231. * @param type
  77232. * @param samplingMode
  77233. * @param generateDepthBuffer
  77234. */
  77235. constructor(name: string, size: number | {
  77236. width: number;
  77237. height: number;
  77238. } | {
  77239. ratio: number;
  77240. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77241. private _preparePostProcesses;
  77242. /**
  77243. * Clone the mirror texture.
  77244. * @returns the cloned texture
  77245. */
  77246. clone(): MirrorTexture;
  77247. /**
  77248. * Serialize the texture to a JSON representation you could use in Parse later on
  77249. * @returns the serialized JSON representation
  77250. */
  77251. serialize(): any;
  77252. /**
  77253. * Dispose the texture and release its associated resources.
  77254. */
  77255. dispose(): void;
  77256. }
  77257. }
  77258. declare module BABYLON {
  77259. /**
  77260. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77261. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77262. */
  77263. export class Texture extends BaseTexture {
  77264. /** @hidden */
  77265. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77266. /** @hidden */
  77267. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77268. /** @hidden */
  77269. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77270. /** nearest is mag = nearest and min = nearest and mip = linear */
  77271. static readonly NEAREST_SAMPLINGMODE: number;
  77272. /** nearest is mag = nearest and min = nearest and mip = linear */
  77273. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77274. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77275. static readonly BILINEAR_SAMPLINGMODE: number;
  77276. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77277. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77278. /** Trilinear is mag = linear and min = linear and mip = linear */
  77279. static readonly TRILINEAR_SAMPLINGMODE: number;
  77280. /** Trilinear is mag = linear and min = linear and mip = linear */
  77281. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77282. /** mag = nearest and min = nearest and mip = nearest */
  77283. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77284. /** mag = nearest and min = linear and mip = nearest */
  77285. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77286. /** mag = nearest and min = linear and mip = linear */
  77287. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77288. /** mag = nearest and min = linear and mip = none */
  77289. static readonly NEAREST_LINEAR: number;
  77290. /** mag = nearest and min = nearest and mip = none */
  77291. static readonly NEAREST_NEAREST: number;
  77292. /** mag = linear and min = nearest and mip = nearest */
  77293. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77294. /** mag = linear and min = nearest and mip = linear */
  77295. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77296. /** mag = linear and min = linear and mip = none */
  77297. static readonly LINEAR_LINEAR: number;
  77298. /** mag = linear and min = nearest and mip = none */
  77299. static readonly LINEAR_NEAREST: number;
  77300. /** Explicit coordinates mode */
  77301. static readonly EXPLICIT_MODE: number;
  77302. /** Spherical coordinates mode */
  77303. static readonly SPHERICAL_MODE: number;
  77304. /** Planar coordinates mode */
  77305. static readonly PLANAR_MODE: number;
  77306. /** Cubic coordinates mode */
  77307. static readonly CUBIC_MODE: number;
  77308. /** Projection coordinates mode */
  77309. static readonly PROJECTION_MODE: number;
  77310. /** Inverse Cubic coordinates mode */
  77311. static readonly SKYBOX_MODE: number;
  77312. /** Inverse Cubic coordinates mode */
  77313. static readonly INVCUBIC_MODE: number;
  77314. /** Equirectangular coordinates mode */
  77315. static readonly EQUIRECTANGULAR_MODE: number;
  77316. /** Equirectangular Fixed coordinates mode */
  77317. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77318. /** Equirectangular Fixed Mirrored coordinates mode */
  77319. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77320. /** Texture is not repeating outside of 0..1 UVs */
  77321. static readonly CLAMP_ADDRESSMODE: number;
  77322. /** Texture is repeating outside of 0..1 UVs */
  77323. static readonly WRAP_ADDRESSMODE: number;
  77324. /** Texture is repeating and mirrored */
  77325. static readonly MIRROR_ADDRESSMODE: number;
  77326. /**
  77327. * 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
  77328. */
  77329. static UseSerializedUrlIfAny: boolean;
  77330. /**
  77331. * Define the url of the texture.
  77332. */
  77333. url: Nullable<string>;
  77334. /**
  77335. * Define an offset on the texture to offset the u coordinates of the UVs
  77336. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77337. */
  77338. uOffset: number;
  77339. /**
  77340. * Define an offset on the texture to offset the v coordinates of the UVs
  77341. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77342. */
  77343. vOffset: number;
  77344. /**
  77345. * Define an offset on the texture to scale the u coordinates of the UVs
  77346. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77347. */
  77348. uScale: number;
  77349. /**
  77350. * Define an offset on the texture to scale the v coordinates of the UVs
  77351. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77352. */
  77353. vScale: number;
  77354. /**
  77355. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77356. * @see http://doc.babylonjs.com/how_to/more_materials
  77357. */
  77358. uAng: number;
  77359. /**
  77360. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77361. * @see http://doc.babylonjs.com/how_to/more_materials
  77362. */
  77363. vAng: number;
  77364. /**
  77365. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77366. * @see http://doc.babylonjs.com/how_to/more_materials
  77367. */
  77368. wAng: number;
  77369. /**
  77370. * Defines the center of rotation (U)
  77371. */
  77372. uRotationCenter: number;
  77373. /**
  77374. * Defines the center of rotation (V)
  77375. */
  77376. vRotationCenter: number;
  77377. /**
  77378. * Defines the center of rotation (W)
  77379. */
  77380. wRotationCenter: number;
  77381. /**
  77382. * Are mip maps generated for this texture or not.
  77383. */
  77384. readonly noMipmap: boolean;
  77385. /**
  77386. * List of inspectable custom properties (used by the Inspector)
  77387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77388. */
  77389. inspectableCustomProperties: IInspectable[];
  77390. private _noMipmap;
  77391. /** @hidden */
  77392. _invertY: boolean;
  77393. private _rowGenerationMatrix;
  77394. private _cachedTextureMatrix;
  77395. private _projectionModeMatrix;
  77396. private _t0;
  77397. private _t1;
  77398. private _t2;
  77399. private _cachedUOffset;
  77400. private _cachedVOffset;
  77401. private _cachedUScale;
  77402. private _cachedVScale;
  77403. private _cachedUAng;
  77404. private _cachedVAng;
  77405. private _cachedWAng;
  77406. private _cachedProjectionMatrixId;
  77407. private _cachedCoordinatesMode;
  77408. /** @hidden */
  77409. protected _initialSamplingMode: number;
  77410. /** @hidden */
  77411. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77412. private _deleteBuffer;
  77413. protected _format: Nullable<number>;
  77414. private _delayedOnLoad;
  77415. private _delayedOnError;
  77416. /**
  77417. * Observable triggered once the texture has been loaded.
  77418. */
  77419. onLoadObservable: Observable<Texture>;
  77420. protected _isBlocking: boolean;
  77421. /**
  77422. * Is the texture preventing material to render while loading.
  77423. * If false, a default texture will be used instead of the loading one during the preparation step.
  77424. */
  77425. isBlocking: boolean;
  77426. /**
  77427. * Get the current sampling mode associated with the texture.
  77428. */
  77429. readonly samplingMode: number;
  77430. /**
  77431. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77432. */
  77433. readonly invertY: boolean;
  77434. /**
  77435. * Instantiates a new texture.
  77436. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77437. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77438. * @param url define the url of the picture to load as a texture
  77439. * @param scene define the scene the texture will belong to
  77440. * @param noMipmap define if the texture will require mip maps or not
  77441. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77442. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77443. * @param onLoad define a callback triggered when the texture has been loaded
  77444. * @param onError define a callback triggered when an error occurred during the loading session
  77445. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77446. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77447. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77448. */
  77449. 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);
  77450. /**
  77451. * Update the url (and optional buffer) of this texture if url was null during construction.
  77452. * @param url the url of the texture
  77453. * @param buffer the buffer of the texture (defaults to null)
  77454. * @param onLoad callback called when the texture is loaded (defaults to null)
  77455. */
  77456. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77457. /**
  77458. * Finish the loading sequence of a texture flagged as delayed load.
  77459. * @hidden
  77460. */
  77461. delayLoad(): void;
  77462. private _prepareRowForTextureGeneration;
  77463. /**
  77464. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77465. * @returns the transform matrix of the texture.
  77466. */
  77467. getTextureMatrix(): Matrix;
  77468. /**
  77469. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77470. * @returns The reflection texture transform
  77471. */
  77472. getReflectionTextureMatrix(): Matrix;
  77473. /**
  77474. * Clones the texture.
  77475. * @returns the cloned texture
  77476. */
  77477. clone(): Texture;
  77478. /**
  77479. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77480. * @returns The JSON representation of the texture
  77481. */
  77482. serialize(): any;
  77483. /**
  77484. * Get the current class name of the texture useful for serialization or dynamic coding.
  77485. * @returns "Texture"
  77486. */
  77487. getClassName(): string;
  77488. /**
  77489. * Dispose the texture and release its associated resources.
  77490. */
  77491. dispose(): void;
  77492. /**
  77493. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77494. * @param parsedTexture Define the JSON representation of the texture
  77495. * @param scene Define the scene the parsed texture should be instantiated in
  77496. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77497. * @returns The parsed texture if successful
  77498. */
  77499. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77500. /**
  77501. * Creates a texture from its base 64 representation.
  77502. * @param data Define the base64 payload without the data: prefix
  77503. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77504. * @param scene Define the scene the texture should belong to
  77505. * @param noMipmap Forces the texture to not create mip map information if true
  77506. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77507. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77508. * @param onLoad define a callback triggered when the texture has been loaded
  77509. * @param onError define a callback triggered when an error occurred during the loading session
  77510. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77511. * @returns the created texture
  77512. */
  77513. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77514. /**
  77515. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77516. * @param data Define the base64 payload without the data: prefix
  77517. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77518. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77519. * @param scene Define the scene the texture should belong to
  77520. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77521. * @param noMipmap Forces the texture to not create mip map information if true
  77522. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77523. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77524. * @param onLoad define a callback triggered when the texture has been loaded
  77525. * @param onError define a callback triggered when an error occurred during the loading session
  77526. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77527. * @returns the created texture
  77528. */
  77529. 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;
  77530. }
  77531. }
  77532. declare module BABYLON {
  77533. /**
  77534. * Raw texture can help creating a texture directly from an array of data.
  77535. * This can be super useful if you either get the data from an uncompressed source or
  77536. * if you wish to create your texture pixel by pixel.
  77537. */
  77538. export class RawTexture extends Texture {
  77539. /**
  77540. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77541. */
  77542. format: number;
  77543. private _engine;
  77544. /**
  77545. * Instantiates a new RawTexture.
  77546. * Raw texture can help creating a texture directly from an array of data.
  77547. * This can be super useful if you either get the data from an uncompressed source or
  77548. * if you wish to create your texture pixel by pixel.
  77549. * @param data define the array of data to use to create the texture
  77550. * @param width define the width of the texture
  77551. * @param height define the height of the texture
  77552. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77553. * @param scene define the scene the texture belongs to
  77554. * @param generateMipMaps define whether mip maps should be generated or not
  77555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77557. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77558. */
  77559. constructor(data: ArrayBufferView, width: number, height: number,
  77560. /**
  77561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77562. */
  77563. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77564. /**
  77565. * Updates the texture underlying data.
  77566. * @param data Define the new data of the texture
  77567. */
  77568. update(data: ArrayBufferView): void;
  77569. /**
  77570. * Creates a luminance texture from some data.
  77571. * @param data Define the texture data
  77572. * @param width Define the width of the texture
  77573. * @param height Define the height of the texture
  77574. * @param scene Define the scene the texture belongs to
  77575. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77578. * @returns the luminance texture
  77579. */
  77580. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77581. /**
  77582. * Creates a luminance alpha texture from some data.
  77583. * @param data Define the texture data
  77584. * @param width Define the width of the texture
  77585. * @param height Define the height of the texture
  77586. * @param scene Define the scene the texture belongs to
  77587. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77590. * @returns the luminance alpha texture
  77591. */
  77592. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77593. /**
  77594. * Creates an alpha texture from some data.
  77595. * @param data Define the texture data
  77596. * @param width Define the width of the texture
  77597. * @param height Define the height of the texture
  77598. * @param scene Define the scene the texture belongs to
  77599. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77602. * @returns the alpha texture
  77603. */
  77604. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77605. /**
  77606. * Creates a RGB texture from some data.
  77607. * @param data Define the texture data
  77608. * @param width Define the width of the texture
  77609. * @param height Define the height of the texture
  77610. * @param scene Define the scene the texture belongs to
  77611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77614. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77615. * @returns the RGB alpha texture
  77616. */
  77617. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77618. /**
  77619. * Creates a RGBA texture from some data.
  77620. * @param data Define the texture data
  77621. * @param width Define the width of the texture
  77622. * @param height Define the height of the texture
  77623. * @param scene Define the scene the texture belongs to
  77624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77627. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77628. * @returns the RGBA texture
  77629. */
  77630. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77631. /**
  77632. * Creates a R texture from some data.
  77633. * @param data Define the texture data
  77634. * @param width Define the width of the texture
  77635. * @param height Define the height of the texture
  77636. * @param scene Define the scene the texture belongs to
  77637. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77638. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77639. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77640. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77641. * @returns the R texture
  77642. */
  77643. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77644. }
  77645. }
  77646. declare module BABYLON {
  77647. /**
  77648. * Defines a runtime animation
  77649. */
  77650. export class RuntimeAnimation {
  77651. private _events;
  77652. /**
  77653. * The current frame of the runtime animation
  77654. */
  77655. private _currentFrame;
  77656. /**
  77657. * The animation used by the runtime animation
  77658. */
  77659. private _animation;
  77660. /**
  77661. * The target of the runtime animation
  77662. */
  77663. private _target;
  77664. /**
  77665. * The initiating animatable
  77666. */
  77667. private _host;
  77668. /**
  77669. * The original value of the runtime animation
  77670. */
  77671. private _originalValue;
  77672. /**
  77673. * The original blend value of the runtime animation
  77674. */
  77675. private _originalBlendValue;
  77676. /**
  77677. * The offsets cache of the runtime animation
  77678. */
  77679. private _offsetsCache;
  77680. /**
  77681. * The high limits cache of the runtime animation
  77682. */
  77683. private _highLimitsCache;
  77684. /**
  77685. * Specifies if the runtime animation has been stopped
  77686. */
  77687. private _stopped;
  77688. /**
  77689. * The blending factor of the runtime animation
  77690. */
  77691. private _blendingFactor;
  77692. /**
  77693. * The BabylonJS scene
  77694. */
  77695. private _scene;
  77696. /**
  77697. * The current value of the runtime animation
  77698. */
  77699. private _currentValue;
  77700. /** @hidden */
  77701. _workValue: any;
  77702. /**
  77703. * The active target of the runtime animation
  77704. */
  77705. private _activeTarget;
  77706. /**
  77707. * The target path of the runtime animation
  77708. */
  77709. private _targetPath;
  77710. /**
  77711. * The weight of the runtime animation
  77712. */
  77713. private _weight;
  77714. /**
  77715. * The ratio offset of the runtime animation
  77716. */
  77717. private _ratioOffset;
  77718. /**
  77719. * The previous delay of the runtime animation
  77720. */
  77721. private _previousDelay;
  77722. /**
  77723. * The previous ratio of the runtime animation
  77724. */
  77725. private _previousRatio;
  77726. /**
  77727. * Gets the current frame of the runtime animation
  77728. */
  77729. readonly currentFrame: number;
  77730. /**
  77731. * Gets the weight of the runtime animation
  77732. */
  77733. readonly weight: number;
  77734. /**
  77735. * Gets the current value of the runtime animation
  77736. */
  77737. readonly currentValue: any;
  77738. /**
  77739. * Gets the target path of the runtime animation
  77740. */
  77741. readonly targetPath: string;
  77742. /**
  77743. * Gets the actual target of the runtime animation
  77744. */
  77745. readonly target: any;
  77746. /**
  77747. * Create a new RuntimeAnimation object
  77748. * @param target defines the target of the animation
  77749. * @param animation defines the source animation object
  77750. * @param scene defines the hosting scene
  77751. * @param host defines the initiating Animatable
  77752. */
  77753. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77754. /**
  77755. * Gets the animation from the runtime animation
  77756. */
  77757. readonly animation: Animation;
  77758. /**
  77759. * Resets the runtime animation to the beginning
  77760. * @param restoreOriginal defines whether to restore the target property to the original value
  77761. */
  77762. reset(restoreOriginal?: boolean): void;
  77763. /**
  77764. * Specifies if the runtime animation is stopped
  77765. * @returns Boolean specifying if the runtime animation is stopped
  77766. */
  77767. isStopped(): boolean;
  77768. /**
  77769. * Disposes of the runtime animation
  77770. */
  77771. dispose(): void;
  77772. /**
  77773. * Interpolates the animation from the current frame
  77774. * @param currentFrame The frame to interpolate the animation to
  77775. * @param repeatCount The number of times that the animation should loop
  77776. * @param loopMode The type of looping mode to use
  77777. * @param offsetValue Animation offset value
  77778. * @param highLimitValue The high limit value
  77779. * @returns The interpolated value
  77780. */
  77781. private _interpolate;
  77782. /**
  77783. * Apply the interpolated value to the target
  77784. * @param currentValue defines the value computed by the animation
  77785. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77786. */
  77787. setValue(currentValue: any, weight?: number): void;
  77788. private _setValue;
  77789. /**
  77790. * Gets the loop pmode of the runtime animation
  77791. * @returns Loop Mode
  77792. */
  77793. private _getCorrectLoopMode;
  77794. /**
  77795. * Move the current animation to a given frame
  77796. * @param frame defines the frame to move to
  77797. */
  77798. goToFrame(frame: number): void;
  77799. /**
  77800. * @hidden Internal use only
  77801. */
  77802. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77803. /**
  77804. * Execute the current animation
  77805. * @param delay defines the delay to add to the current frame
  77806. * @param from defines the lower bound of the animation range
  77807. * @param to defines the upper bound of the animation range
  77808. * @param loop defines if the current animation must loop
  77809. * @param speedRatio defines the current speed ratio
  77810. * @param weight defines the weight of the animation (default is -1 so no weight)
  77811. * @param onLoop optional callback called when animation loops
  77812. * @returns a boolean indicating if the animation is running
  77813. */
  77814. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77815. }
  77816. }
  77817. declare module BABYLON {
  77818. /**
  77819. * Class used to store an actual running animation
  77820. */
  77821. export class Animatable {
  77822. /** defines the target object */
  77823. target: any;
  77824. /** defines the starting frame number (default is 0) */
  77825. fromFrame: number;
  77826. /** defines the ending frame number (default is 100) */
  77827. toFrame: number;
  77828. /** defines if the animation must loop (default is false) */
  77829. loopAnimation: boolean;
  77830. /** defines a callback to call when animation ends if it is not looping */
  77831. onAnimationEnd?: (() => void) | null | undefined;
  77832. /** defines a callback to call when animation loops */
  77833. onAnimationLoop?: (() => void) | null | undefined;
  77834. private _localDelayOffset;
  77835. private _pausedDelay;
  77836. private _runtimeAnimations;
  77837. private _paused;
  77838. private _scene;
  77839. private _speedRatio;
  77840. private _weight;
  77841. private _syncRoot;
  77842. /**
  77843. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77844. * This will only apply for non looping animation (default is true)
  77845. */
  77846. disposeOnEnd: boolean;
  77847. /**
  77848. * Gets a boolean indicating if the animation has started
  77849. */
  77850. animationStarted: boolean;
  77851. /**
  77852. * Observer raised when the animation ends
  77853. */
  77854. onAnimationEndObservable: Observable<Animatable>;
  77855. /**
  77856. * Observer raised when the animation loops
  77857. */
  77858. onAnimationLoopObservable: Observable<Animatable>;
  77859. /**
  77860. * Gets the root Animatable used to synchronize and normalize animations
  77861. */
  77862. readonly syncRoot: Animatable;
  77863. /**
  77864. * Gets the current frame of the first RuntimeAnimation
  77865. * Used to synchronize Animatables
  77866. */
  77867. readonly masterFrame: number;
  77868. /**
  77869. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77870. */
  77871. weight: number;
  77872. /**
  77873. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77874. */
  77875. speedRatio: number;
  77876. /**
  77877. * Creates a new Animatable
  77878. * @param scene defines the hosting scene
  77879. * @param target defines the target object
  77880. * @param fromFrame defines the starting frame number (default is 0)
  77881. * @param toFrame defines the ending frame number (default is 100)
  77882. * @param loopAnimation defines if the animation must loop (default is false)
  77883. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77884. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77885. * @param animations defines a group of animation to add to the new Animatable
  77886. * @param onAnimationLoop defines a callback to call when animation loops
  77887. */
  77888. constructor(scene: Scene,
  77889. /** defines the target object */
  77890. target: any,
  77891. /** defines the starting frame number (default is 0) */
  77892. fromFrame?: number,
  77893. /** defines the ending frame number (default is 100) */
  77894. toFrame?: number,
  77895. /** defines if the animation must loop (default is false) */
  77896. loopAnimation?: boolean, speedRatio?: number,
  77897. /** defines a callback to call when animation ends if it is not looping */
  77898. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77899. /** defines a callback to call when animation loops */
  77900. onAnimationLoop?: (() => void) | null | undefined);
  77901. /**
  77902. * Synchronize and normalize current Animatable with a source Animatable
  77903. * This is useful when using animation weights and when animations are not of the same length
  77904. * @param root defines the root Animatable to synchronize with
  77905. * @returns the current Animatable
  77906. */
  77907. syncWith(root: Animatable): Animatable;
  77908. /**
  77909. * Gets the list of runtime animations
  77910. * @returns an array of RuntimeAnimation
  77911. */
  77912. getAnimations(): RuntimeAnimation[];
  77913. /**
  77914. * Adds more animations to the current animatable
  77915. * @param target defines the target of the animations
  77916. * @param animations defines the new animations to add
  77917. */
  77918. appendAnimations(target: any, animations: Animation[]): void;
  77919. /**
  77920. * Gets the source animation for a specific property
  77921. * @param property defines the propertyu to look for
  77922. * @returns null or the source animation for the given property
  77923. */
  77924. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77925. /**
  77926. * Gets the runtime animation for a specific property
  77927. * @param property defines the propertyu to look for
  77928. * @returns null or the runtime animation for the given property
  77929. */
  77930. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77931. /**
  77932. * Resets the animatable to its original state
  77933. */
  77934. reset(): void;
  77935. /**
  77936. * Allows the animatable to blend with current running animations
  77937. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77938. * @param blendingSpeed defines the blending speed to use
  77939. */
  77940. enableBlending(blendingSpeed: number): void;
  77941. /**
  77942. * Disable animation blending
  77943. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77944. */
  77945. disableBlending(): void;
  77946. /**
  77947. * Jump directly to a given frame
  77948. * @param frame defines the frame to jump to
  77949. */
  77950. goToFrame(frame: number): void;
  77951. /**
  77952. * Pause the animation
  77953. */
  77954. pause(): void;
  77955. /**
  77956. * Restart the animation
  77957. */
  77958. restart(): void;
  77959. private _raiseOnAnimationEnd;
  77960. /**
  77961. * Stop and delete the current animation
  77962. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77963. * @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)
  77964. */
  77965. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77966. /**
  77967. * Wait asynchronously for the animation to end
  77968. * @returns a promise which will be fullfilled when the animation ends
  77969. */
  77970. waitAsync(): Promise<Animatable>;
  77971. /** @hidden */
  77972. _animate(delay: number): boolean;
  77973. }
  77974. interface Scene {
  77975. /** @hidden */
  77976. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77977. /** @hidden */
  77978. _processLateAnimationBindingsForMatrices(holder: {
  77979. totalWeight: number;
  77980. animations: RuntimeAnimation[];
  77981. originalValue: Matrix;
  77982. }): any;
  77983. /** @hidden */
  77984. _processLateAnimationBindingsForQuaternions(holder: {
  77985. totalWeight: number;
  77986. animations: RuntimeAnimation[];
  77987. originalValue: Quaternion;
  77988. }, refQuaternion: Quaternion): Quaternion;
  77989. /** @hidden */
  77990. _processLateAnimationBindings(): void;
  77991. /**
  77992. * Will start the animation sequence of a given target
  77993. * @param target defines the target
  77994. * @param from defines from which frame should animation start
  77995. * @param to defines until which frame should animation run.
  77996. * @param weight defines the weight to apply to the animation (1.0 by default)
  77997. * @param loop defines if the animation loops
  77998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77999. * @param onAnimationEnd defines the function to be executed when the animation ends
  78000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78001. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78002. * @param onAnimationLoop defines the callback to call when an animation loops
  78003. * @returns the animatable object created for this animation
  78004. */
  78005. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78006. /**
  78007. * Will start the animation sequence of a given target
  78008. * @param target defines the target
  78009. * @param from defines from which frame should animation start
  78010. * @param to defines until which frame should animation run.
  78011. * @param loop defines if the animation loops
  78012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78013. * @param onAnimationEnd defines the function to be executed when the animation ends
  78014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78016. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78017. * @param onAnimationLoop defines the callback to call when an animation loops
  78018. * @returns the animatable object created for this animation
  78019. */
  78020. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78021. /**
  78022. * Will start the animation sequence of a given target and its hierarchy
  78023. * @param target defines the target
  78024. * @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.
  78025. * @param from defines from which frame should animation start
  78026. * @param to defines until which frame should animation run.
  78027. * @param loop defines if the animation loops
  78028. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78029. * @param onAnimationEnd defines the function to be executed when the animation ends
  78030. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78031. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78033. * @param onAnimationLoop defines the callback to call when an animation loops
  78034. * @returns the list of created animatables
  78035. */
  78036. 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[];
  78037. /**
  78038. * Begin a new animation on a given node
  78039. * @param target defines the target where the animation will take place
  78040. * @param animations defines the list of animations to start
  78041. * @param from defines the initial value
  78042. * @param to defines the final value
  78043. * @param loop defines if you want animation to loop (off by default)
  78044. * @param speedRatio defines the speed ratio to apply to all animations
  78045. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78046. * @param onAnimationLoop defines the callback to call when an animation loops
  78047. * @returns the list of created animatables
  78048. */
  78049. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78050. /**
  78051. * Begin a new animation on a given node and its hierarchy
  78052. * @param target defines the root node where the animation will take place
  78053. * @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.
  78054. * @param animations defines the list of animations to start
  78055. * @param from defines the initial value
  78056. * @param to defines the final value
  78057. * @param loop defines if you want animation to loop (off by default)
  78058. * @param speedRatio defines the speed ratio to apply to all animations
  78059. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78060. * @param onAnimationLoop defines the callback to call when an animation loops
  78061. * @returns the list of animatables created for all nodes
  78062. */
  78063. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78064. /**
  78065. * Gets the animatable associated with a specific target
  78066. * @param target defines the target of the animatable
  78067. * @returns the required animatable if found
  78068. */
  78069. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78070. /**
  78071. * Gets all animatables associated with a given target
  78072. * @param target defines the target to look animatables for
  78073. * @returns an array of Animatables
  78074. */
  78075. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78076. /**
  78077. * Will stop the animation of the given target
  78078. * @param target - the target
  78079. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78080. * @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)
  78081. */
  78082. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78083. /**
  78084. * Stops and removes all animations that have been applied to the scene
  78085. */
  78086. stopAllAnimations(): void;
  78087. }
  78088. interface Bone {
  78089. /**
  78090. * Copy an animation range from another bone
  78091. * @param source defines the source bone
  78092. * @param rangeName defines the range name to copy
  78093. * @param frameOffset defines the frame offset
  78094. * @param rescaleAsRequired defines if rescaling must be applied if required
  78095. * @param skelDimensionsRatio defines the scaling ratio
  78096. * @returns true if operation was successful
  78097. */
  78098. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78099. }
  78100. }
  78101. declare module BABYLON {
  78102. /**
  78103. * Class used to handle skinning animations
  78104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78105. */
  78106. export class Skeleton implements IAnimatable {
  78107. /** defines the skeleton name */
  78108. name: string;
  78109. /** defines the skeleton Id */
  78110. id: string;
  78111. /**
  78112. * Defines the list of child bones
  78113. */
  78114. bones: Bone[];
  78115. /**
  78116. * Defines an estimate of the dimension of the skeleton at rest
  78117. */
  78118. dimensionsAtRest: Vector3;
  78119. /**
  78120. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78121. */
  78122. needInitialSkinMatrix: boolean;
  78123. /**
  78124. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78125. */
  78126. overrideMesh: Nullable<AbstractMesh>;
  78127. /**
  78128. * Gets the list of animations attached to this skeleton
  78129. */
  78130. animations: Array<Animation>;
  78131. private _scene;
  78132. private _isDirty;
  78133. private _transformMatrices;
  78134. private _transformMatrixTexture;
  78135. private _meshesWithPoseMatrix;
  78136. private _animatables;
  78137. private _identity;
  78138. private _synchronizedWithMesh;
  78139. private _ranges;
  78140. private _lastAbsoluteTransformsUpdateId;
  78141. private _canUseTextureForBones;
  78142. private _uniqueId;
  78143. /** @hidden */
  78144. _numBonesWithLinkedTransformNode: number;
  78145. /**
  78146. * Specifies if the skeleton should be serialized
  78147. */
  78148. doNotSerialize: boolean;
  78149. private _useTextureToStoreBoneMatrices;
  78150. /**
  78151. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78152. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78153. */
  78154. useTextureToStoreBoneMatrices: boolean;
  78155. private _animationPropertiesOverride;
  78156. /**
  78157. * Gets or sets the animation properties override
  78158. */
  78159. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78160. /**
  78161. * List of inspectable custom properties (used by the Inspector)
  78162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78163. */
  78164. inspectableCustomProperties: IInspectable[];
  78165. /**
  78166. * An observable triggered before computing the skeleton's matrices
  78167. */
  78168. onBeforeComputeObservable: Observable<Skeleton>;
  78169. /**
  78170. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78171. */
  78172. readonly isUsingTextureForMatrices: boolean;
  78173. /**
  78174. * Gets the unique ID of this skeleton
  78175. */
  78176. readonly uniqueId: number;
  78177. /**
  78178. * Creates a new skeleton
  78179. * @param name defines the skeleton name
  78180. * @param id defines the skeleton Id
  78181. * @param scene defines the hosting scene
  78182. */
  78183. constructor(
  78184. /** defines the skeleton name */
  78185. name: string,
  78186. /** defines the skeleton Id */
  78187. id: string, scene: Scene);
  78188. /**
  78189. * Gets the current object class name.
  78190. * @return the class name
  78191. */
  78192. getClassName(): string;
  78193. /**
  78194. * Returns an array containing the root bones
  78195. * @returns an array containing the root bones
  78196. */
  78197. getChildren(): Array<Bone>;
  78198. /**
  78199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78201. * @returns a Float32Array containing matrices data
  78202. */
  78203. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78204. /**
  78205. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78206. * @returns a raw texture containing the data
  78207. */
  78208. getTransformMatrixTexture(): Nullable<RawTexture>;
  78209. /**
  78210. * Gets the current hosting scene
  78211. * @returns a scene object
  78212. */
  78213. getScene(): Scene;
  78214. /**
  78215. * Gets a string representing the current skeleton data
  78216. * @param fullDetails defines a boolean indicating if we want a verbose version
  78217. * @returns a string representing the current skeleton data
  78218. */
  78219. toString(fullDetails?: boolean): string;
  78220. /**
  78221. * Get bone's index searching by name
  78222. * @param name defines bone's name to search for
  78223. * @return the indice of the bone. Returns -1 if not found
  78224. */
  78225. getBoneIndexByName(name: string): number;
  78226. /**
  78227. * Creater a new animation range
  78228. * @param name defines the name of the range
  78229. * @param from defines the start key
  78230. * @param to defines the end key
  78231. */
  78232. createAnimationRange(name: string, from: number, to: number): void;
  78233. /**
  78234. * Delete a specific animation range
  78235. * @param name defines the name of the range
  78236. * @param deleteFrames defines if frames must be removed as well
  78237. */
  78238. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78239. /**
  78240. * Gets a specific animation range
  78241. * @param name defines the name of the range to look for
  78242. * @returns the requested animation range or null if not found
  78243. */
  78244. getAnimationRange(name: string): Nullable<AnimationRange>;
  78245. /**
  78246. * Gets the list of all animation ranges defined on this skeleton
  78247. * @returns an array
  78248. */
  78249. getAnimationRanges(): Nullable<AnimationRange>[];
  78250. /**
  78251. * Copy animation range from a source skeleton.
  78252. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78253. * @param source defines the source skeleton
  78254. * @param name defines the name of the range to copy
  78255. * @param rescaleAsRequired defines if rescaling must be applied if required
  78256. * @returns true if operation was successful
  78257. */
  78258. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78259. /**
  78260. * Forces the skeleton to go to rest pose
  78261. */
  78262. returnToRest(): void;
  78263. private _getHighestAnimationFrame;
  78264. /**
  78265. * Begin a specific animation range
  78266. * @param name defines the name of the range to start
  78267. * @param loop defines if looping must be turned on (false by default)
  78268. * @param speedRatio defines the speed ratio to apply (1 by default)
  78269. * @param onAnimationEnd defines a callback which will be called when animation will end
  78270. * @returns a new animatable
  78271. */
  78272. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78273. /** @hidden */
  78274. _markAsDirty(): void;
  78275. /** @hidden */
  78276. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78277. /** @hidden */
  78278. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78279. private _computeTransformMatrices;
  78280. /**
  78281. * Build all resources required to render a skeleton
  78282. */
  78283. prepare(): void;
  78284. /**
  78285. * Gets the list of animatables currently running for this skeleton
  78286. * @returns an array of animatables
  78287. */
  78288. getAnimatables(): IAnimatable[];
  78289. /**
  78290. * Clone the current skeleton
  78291. * @param name defines the name of the new skeleton
  78292. * @param id defines the id of the enw skeleton
  78293. * @returns the new skeleton
  78294. */
  78295. clone(name: string, id: string): Skeleton;
  78296. /**
  78297. * Enable animation blending for this skeleton
  78298. * @param blendingSpeed defines the blending speed to apply
  78299. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78300. */
  78301. enableBlending(blendingSpeed?: number): void;
  78302. /**
  78303. * Releases all resources associated with the current skeleton
  78304. */
  78305. dispose(): void;
  78306. /**
  78307. * Serialize the skeleton in a JSON object
  78308. * @returns a JSON object
  78309. */
  78310. serialize(): any;
  78311. /**
  78312. * Creates a new skeleton from serialized data
  78313. * @param parsedSkeleton defines the serialized data
  78314. * @param scene defines the hosting scene
  78315. * @returns a new skeleton
  78316. */
  78317. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78318. /**
  78319. * Compute all node absolute transforms
  78320. * @param forceUpdate defines if computation must be done even if cache is up to date
  78321. */
  78322. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78323. /**
  78324. * Gets the root pose matrix
  78325. * @returns a matrix
  78326. */
  78327. getPoseMatrix(): Nullable<Matrix>;
  78328. /**
  78329. * Sorts bones per internal index
  78330. */
  78331. sortBones(): void;
  78332. private _sortBones;
  78333. }
  78334. }
  78335. declare module BABYLON {
  78336. /**
  78337. * Defines a target to use with MorphTargetManager
  78338. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78339. */
  78340. export class MorphTarget implements IAnimatable {
  78341. /** defines the name of the target */
  78342. name: string;
  78343. /**
  78344. * Gets or sets the list of animations
  78345. */
  78346. animations: Animation[];
  78347. private _scene;
  78348. private _positions;
  78349. private _normals;
  78350. private _tangents;
  78351. private _influence;
  78352. /**
  78353. * Observable raised when the influence changes
  78354. */
  78355. onInfluenceChanged: Observable<boolean>;
  78356. /** @hidden */
  78357. _onDataLayoutChanged: Observable<void>;
  78358. /**
  78359. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78360. */
  78361. influence: number;
  78362. /**
  78363. * Gets or sets the id of the morph Target
  78364. */
  78365. id: string;
  78366. private _animationPropertiesOverride;
  78367. /**
  78368. * Gets or sets the animation properties override
  78369. */
  78370. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78371. /**
  78372. * Creates a new MorphTarget
  78373. * @param name defines the name of the target
  78374. * @param influence defines the influence to use
  78375. * @param scene defines the scene the morphtarget belongs to
  78376. */
  78377. constructor(
  78378. /** defines the name of the target */
  78379. name: string, influence?: number, scene?: Nullable<Scene>);
  78380. /**
  78381. * Gets a boolean defining if the target contains position data
  78382. */
  78383. readonly hasPositions: boolean;
  78384. /**
  78385. * Gets a boolean defining if the target contains normal data
  78386. */
  78387. readonly hasNormals: boolean;
  78388. /**
  78389. * Gets a boolean defining if the target contains tangent data
  78390. */
  78391. readonly hasTangents: boolean;
  78392. /**
  78393. * Affects position data to this target
  78394. * @param data defines the position data to use
  78395. */
  78396. setPositions(data: Nullable<FloatArray>): void;
  78397. /**
  78398. * Gets the position data stored in this target
  78399. * @returns a FloatArray containing the position data (or null if not present)
  78400. */
  78401. getPositions(): Nullable<FloatArray>;
  78402. /**
  78403. * Affects normal data to this target
  78404. * @param data defines the normal data to use
  78405. */
  78406. setNormals(data: Nullable<FloatArray>): void;
  78407. /**
  78408. * Gets the normal data stored in this target
  78409. * @returns a FloatArray containing the normal data (or null if not present)
  78410. */
  78411. getNormals(): Nullable<FloatArray>;
  78412. /**
  78413. * Affects tangent data to this target
  78414. * @param data defines the tangent data to use
  78415. */
  78416. setTangents(data: Nullable<FloatArray>): void;
  78417. /**
  78418. * Gets the tangent data stored in this target
  78419. * @returns a FloatArray containing the tangent data (or null if not present)
  78420. */
  78421. getTangents(): Nullable<FloatArray>;
  78422. /**
  78423. * Serializes the current target into a Serialization object
  78424. * @returns the serialized object
  78425. */
  78426. serialize(): any;
  78427. /**
  78428. * Returns the string "MorphTarget"
  78429. * @returns "MorphTarget"
  78430. */
  78431. getClassName(): string;
  78432. /**
  78433. * Creates a new target from serialized data
  78434. * @param serializationObject defines the serialized data to use
  78435. * @returns a new MorphTarget
  78436. */
  78437. static Parse(serializationObject: any): MorphTarget;
  78438. /**
  78439. * Creates a MorphTarget from mesh data
  78440. * @param mesh defines the source mesh
  78441. * @param name defines the name to use for the new target
  78442. * @param influence defines the influence to attach to the target
  78443. * @returns a new MorphTarget
  78444. */
  78445. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78446. }
  78447. }
  78448. declare module BABYLON {
  78449. /**
  78450. * This class is used to deform meshes using morphing between different targets
  78451. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78452. */
  78453. export class MorphTargetManager {
  78454. private _targets;
  78455. private _targetInfluenceChangedObservers;
  78456. private _targetDataLayoutChangedObservers;
  78457. private _activeTargets;
  78458. private _scene;
  78459. private _influences;
  78460. private _supportsNormals;
  78461. private _supportsTangents;
  78462. private _vertexCount;
  78463. private _uniqueId;
  78464. private _tempInfluences;
  78465. /**
  78466. * Creates a new MorphTargetManager
  78467. * @param scene defines the current scene
  78468. */
  78469. constructor(scene?: Nullable<Scene>);
  78470. /**
  78471. * Gets the unique ID of this manager
  78472. */
  78473. readonly uniqueId: number;
  78474. /**
  78475. * Gets the number of vertices handled by this manager
  78476. */
  78477. readonly vertexCount: number;
  78478. /**
  78479. * Gets a boolean indicating if this manager supports morphing of normals
  78480. */
  78481. readonly supportsNormals: boolean;
  78482. /**
  78483. * Gets a boolean indicating if this manager supports morphing of tangents
  78484. */
  78485. readonly supportsTangents: boolean;
  78486. /**
  78487. * Gets the number of targets stored in this manager
  78488. */
  78489. readonly numTargets: number;
  78490. /**
  78491. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78492. */
  78493. readonly numInfluencers: number;
  78494. /**
  78495. * Gets the list of influences (one per target)
  78496. */
  78497. readonly influences: Float32Array;
  78498. /**
  78499. * Gets the active target at specified index. An active target is a target with an influence > 0
  78500. * @param index defines the index to check
  78501. * @returns the requested target
  78502. */
  78503. getActiveTarget(index: number): MorphTarget;
  78504. /**
  78505. * Gets the target at specified index
  78506. * @param index defines the index to check
  78507. * @returns the requested target
  78508. */
  78509. getTarget(index: number): MorphTarget;
  78510. /**
  78511. * Add a new target to this manager
  78512. * @param target defines the target to add
  78513. */
  78514. addTarget(target: MorphTarget): void;
  78515. /**
  78516. * Removes a target from the manager
  78517. * @param target defines the target to remove
  78518. */
  78519. removeTarget(target: MorphTarget): void;
  78520. /**
  78521. * Serializes the current manager into a Serialization object
  78522. * @returns the serialized object
  78523. */
  78524. serialize(): any;
  78525. private _syncActiveTargets;
  78526. /**
  78527. * Syncrhonize the targets with all the meshes using this morph target manager
  78528. */
  78529. synchronize(): void;
  78530. /**
  78531. * Creates a new MorphTargetManager from serialized data
  78532. * @param serializationObject defines the serialized data
  78533. * @param scene defines the hosting scene
  78534. * @returns the new MorphTargetManager
  78535. */
  78536. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78537. }
  78538. }
  78539. declare module BABYLON {
  78540. /**
  78541. * Mesh representing the gorund
  78542. */
  78543. export class GroundMesh extends Mesh {
  78544. /** If octree should be generated */
  78545. generateOctree: boolean;
  78546. private _heightQuads;
  78547. /** @hidden */
  78548. _subdivisionsX: number;
  78549. /** @hidden */
  78550. _subdivisionsY: number;
  78551. /** @hidden */
  78552. _width: number;
  78553. /** @hidden */
  78554. _height: number;
  78555. /** @hidden */
  78556. _minX: number;
  78557. /** @hidden */
  78558. _maxX: number;
  78559. /** @hidden */
  78560. _minZ: number;
  78561. /** @hidden */
  78562. _maxZ: number;
  78563. constructor(name: string, scene: Scene);
  78564. /**
  78565. * "GroundMesh"
  78566. * @returns "GroundMesh"
  78567. */
  78568. getClassName(): string;
  78569. /**
  78570. * The minimum of x and y subdivisions
  78571. */
  78572. readonly subdivisions: number;
  78573. /**
  78574. * X subdivisions
  78575. */
  78576. readonly subdivisionsX: number;
  78577. /**
  78578. * Y subdivisions
  78579. */
  78580. readonly subdivisionsY: number;
  78581. /**
  78582. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78583. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78584. * @param chunksCount the number of subdivisions for x and y
  78585. * @param octreeBlocksSize (Default: 32)
  78586. */
  78587. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78588. /**
  78589. * Returns a height (y) value in the Worl system :
  78590. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78591. * @param x x coordinate
  78592. * @param z z coordinate
  78593. * @returns the ground y position if (x, z) are outside the ground surface.
  78594. */
  78595. getHeightAtCoordinates(x: number, z: number): number;
  78596. /**
  78597. * Returns a normalized vector (Vector3) orthogonal to the ground
  78598. * at the ground coordinates (x, z) expressed in the World system.
  78599. * @param x x coordinate
  78600. * @param z z coordinate
  78601. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78602. */
  78603. getNormalAtCoordinates(x: number, z: number): Vector3;
  78604. /**
  78605. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78606. * at the ground coordinates (x, z) expressed in the World system.
  78607. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78608. * @param x x coordinate
  78609. * @param z z coordinate
  78610. * @param ref vector to store the result
  78611. * @returns the GroundMesh.
  78612. */
  78613. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78614. /**
  78615. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78616. * if the ground has been updated.
  78617. * This can be used in the render loop.
  78618. * @returns the GroundMesh.
  78619. */
  78620. updateCoordinateHeights(): GroundMesh;
  78621. private _getFacetAt;
  78622. private _initHeightQuads;
  78623. private _computeHeightQuads;
  78624. /**
  78625. * Serializes this ground mesh
  78626. * @param serializationObject object to write serialization to
  78627. */
  78628. serialize(serializationObject: any): void;
  78629. /**
  78630. * Parses a serialized ground mesh
  78631. * @param parsedMesh the serialized mesh
  78632. * @param scene the scene to create the ground mesh in
  78633. * @returns the created ground mesh
  78634. */
  78635. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78636. }
  78637. }
  78638. declare module BABYLON {
  78639. /**
  78640. * Interface for Physics-Joint data
  78641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78642. */
  78643. export interface PhysicsJointData {
  78644. /**
  78645. * The main pivot of the joint
  78646. */
  78647. mainPivot?: Vector3;
  78648. /**
  78649. * The connected pivot of the joint
  78650. */
  78651. connectedPivot?: Vector3;
  78652. /**
  78653. * The main axis of the joint
  78654. */
  78655. mainAxis?: Vector3;
  78656. /**
  78657. * The connected axis of the joint
  78658. */
  78659. connectedAxis?: Vector3;
  78660. /**
  78661. * The collision of the joint
  78662. */
  78663. collision?: boolean;
  78664. /**
  78665. * Native Oimo/Cannon/Energy data
  78666. */
  78667. nativeParams?: any;
  78668. }
  78669. /**
  78670. * This is a holder class for the physics joint created by the physics plugin
  78671. * It holds a set of functions to control the underlying joint
  78672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78673. */
  78674. export class PhysicsJoint {
  78675. /**
  78676. * The type of the physics joint
  78677. */
  78678. type: number;
  78679. /**
  78680. * The data for the physics joint
  78681. */
  78682. jointData: PhysicsJointData;
  78683. private _physicsJoint;
  78684. protected _physicsPlugin: IPhysicsEnginePlugin;
  78685. /**
  78686. * Initializes the physics joint
  78687. * @param type The type of the physics joint
  78688. * @param jointData The data for the physics joint
  78689. */
  78690. constructor(
  78691. /**
  78692. * The type of the physics joint
  78693. */
  78694. type: number,
  78695. /**
  78696. * The data for the physics joint
  78697. */
  78698. jointData: PhysicsJointData);
  78699. /**
  78700. * Gets the physics joint
  78701. */
  78702. /**
  78703. * Sets the physics joint
  78704. */
  78705. physicsJoint: any;
  78706. /**
  78707. * Sets the physics plugin
  78708. */
  78709. physicsPlugin: IPhysicsEnginePlugin;
  78710. /**
  78711. * Execute a function that is physics-plugin specific.
  78712. * @param {Function} func the function that will be executed.
  78713. * It accepts two parameters: the physics world and the physics joint
  78714. */
  78715. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78716. /**
  78717. * Distance-Joint type
  78718. */
  78719. static DistanceJoint: number;
  78720. /**
  78721. * Hinge-Joint type
  78722. */
  78723. static HingeJoint: number;
  78724. /**
  78725. * Ball-and-Socket joint type
  78726. */
  78727. static BallAndSocketJoint: number;
  78728. /**
  78729. * Wheel-Joint type
  78730. */
  78731. static WheelJoint: number;
  78732. /**
  78733. * Slider-Joint type
  78734. */
  78735. static SliderJoint: number;
  78736. /**
  78737. * Prismatic-Joint type
  78738. */
  78739. static PrismaticJoint: number;
  78740. /**
  78741. * Universal-Joint type
  78742. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78743. */
  78744. static UniversalJoint: number;
  78745. /**
  78746. * Hinge-Joint 2 type
  78747. */
  78748. static Hinge2Joint: number;
  78749. /**
  78750. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78751. */
  78752. static PointToPointJoint: number;
  78753. /**
  78754. * Spring-Joint type
  78755. */
  78756. static SpringJoint: number;
  78757. /**
  78758. * Lock-Joint type
  78759. */
  78760. static LockJoint: number;
  78761. }
  78762. /**
  78763. * A class representing a physics distance joint
  78764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78765. */
  78766. export class DistanceJoint extends PhysicsJoint {
  78767. /**
  78768. *
  78769. * @param jointData The data for the Distance-Joint
  78770. */
  78771. constructor(jointData: DistanceJointData);
  78772. /**
  78773. * Update the predefined distance.
  78774. * @param maxDistance The maximum preferred distance
  78775. * @param minDistance The minimum preferred distance
  78776. */
  78777. updateDistance(maxDistance: number, minDistance?: number): void;
  78778. }
  78779. /**
  78780. * Represents a Motor-Enabled Joint
  78781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78782. */
  78783. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78784. /**
  78785. * Initializes the Motor-Enabled Joint
  78786. * @param type The type of the joint
  78787. * @param jointData The physica joint data for the joint
  78788. */
  78789. constructor(type: number, jointData: PhysicsJointData);
  78790. /**
  78791. * Set the motor values.
  78792. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78793. * @param force the force to apply
  78794. * @param maxForce max force for this motor.
  78795. */
  78796. setMotor(force?: number, maxForce?: number): void;
  78797. /**
  78798. * Set the motor's limits.
  78799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78800. * @param upperLimit The upper limit of the motor
  78801. * @param lowerLimit The lower limit of the motor
  78802. */
  78803. setLimit(upperLimit: number, lowerLimit?: number): void;
  78804. }
  78805. /**
  78806. * This class represents a single physics Hinge-Joint
  78807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78808. */
  78809. export class HingeJoint extends MotorEnabledJoint {
  78810. /**
  78811. * Initializes the Hinge-Joint
  78812. * @param jointData The joint data for the Hinge-Joint
  78813. */
  78814. constructor(jointData: PhysicsJointData);
  78815. /**
  78816. * Set the motor values.
  78817. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78818. * @param {number} force the force to apply
  78819. * @param {number} maxForce max force for this motor.
  78820. */
  78821. setMotor(force?: number, maxForce?: number): void;
  78822. /**
  78823. * Set the motor's limits.
  78824. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78825. * @param upperLimit The upper limit of the motor
  78826. * @param lowerLimit The lower limit of the motor
  78827. */
  78828. setLimit(upperLimit: number, lowerLimit?: number): void;
  78829. }
  78830. /**
  78831. * This class represents a dual hinge physics joint (same as wheel joint)
  78832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78833. */
  78834. export class Hinge2Joint extends MotorEnabledJoint {
  78835. /**
  78836. * Initializes the Hinge2-Joint
  78837. * @param jointData The joint data for the Hinge2-Joint
  78838. */
  78839. constructor(jointData: PhysicsJointData);
  78840. /**
  78841. * Set the motor values.
  78842. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78843. * @param {number} targetSpeed the speed the motor is to reach
  78844. * @param {number} maxForce max force for this motor.
  78845. * @param {motorIndex} the motor's index, 0 or 1.
  78846. */
  78847. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78848. /**
  78849. * Set the motor limits.
  78850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78851. * @param {number} upperLimit the upper limit
  78852. * @param {number} lowerLimit lower limit
  78853. * @param {motorIndex} the motor's index, 0 or 1.
  78854. */
  78855. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78856. }
  78857. /**
  78858. * Interface for a motor enabled joint
  78859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78860. */
  78861. export interface IMotorEnabledJoint {
  78862. /**
  78863. * Physics joint
  78864. */
  78865. physicsJoint: any;
  78866. /**
  78867. * Sets the motor of the motor-enabled joint
  78868. * @param force The force of the motor
  78869. * @param maxForce The maximum force of the motor
  78870. * @param motorIndex The index of the motor
  78871. */
  78872. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78873. /**
  78874. * Sets the limit of the motor
  78875. * @param upperLimit The upper limit of the motor
  78876. * @param lowerLimit The lower limit of the motor
  78877. * @param motorIndex The index of the motor
  78878. */
  78879. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78880. }
  78881. /**
  78882. * Joint data for a Distance-Joint
  78883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78884. */
  78885. export interface DistanceJointData extends PhysicsJointData {
  78886. /**
  78887. * Max distance the 2 joint objects can be apart
  78888. */
  78889. maxDistance: number;
  78890. }
  78891. /**
  78892. * Joint data from a spring joint
  78893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78894. */
  78895. export interface SpringJointData extends PhysicsJointData {
  78896. /**
  78897. * Length of the spring
  78898. */
  78899. length: number;
  78900. /**
  78901. * Stiffness of the spring
  78902. */
  78903. stiffness: number;
  78904. /**
  78905. * Damping of the spring
  78906. */
  78907. damping: number;
  78908. /** this callback will be called when applying the force to the impostors. */
  78909. forceApplicationCallback: () => void;
  78910. }
  78911. }
  78912. declare module BABYLON {
  78913. /**
  78914. * Holds the data for the raycast result
  78915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78916. */
  78917. export class PhysicsRaycastResult {
  78918. private _hasHit;
  78919. private _hitDistance;
  78920. private _hitNormalWorld;
  78921. private _hitPointWorld;
  78922. private _rayFromWorld;
  78923. private _rayToWorld;
  78924. /**
  78925. * Gets if there was a hit
  78926. */
  78927. readonly hasHit: boolean;
  78928. /**
  78929. * Gets the distance from the hit
  78930. */
  78931. readonly hitDistance: number;
  78932. /**
  78933. * Gets the hit normal/direction in the world
  78934. */
  78935. readonly hitNormalWorld: Vector3;
  78936. /**
  78937. * Gets the hit point in the world
  78938. */
  78939. readonly hitPointWorld: Vector3;
  78940. /**
  78941. * Gets the ray "start point" of the ray in the world
  78942. */
  78943. readonly rayFromWorld: Vector3;
  78944. /**
  78945. * Gets the ray "end point" of the ray in the world
  78946. */
  78947. readonly rayToWorld: Vector3;
  78948. /**
  78949. * Sets the hit data (normal & point in world space)
  78950. * @param hitNormalWorld defines the normal in world space
  78951. * @param hitPointWorld defines the point in world space
  78952. */
  78953. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78954. /**
  78955. * Sets the distance from the start point to the hit point
  78956. * @param distance
  78957. */
  78958. setHitDistance(distance: number): void;
  78959. /**
  78960. * Calculates the distance manually
  78961. */
  78962. calculateHitDistance(): void;
  78963. /**
  78964. * Resets all the values to default
  78965. * @param from The from point on world space
  78966. * @param to The to point on world space
  78967. */
  78968. reset(from?: Vector3, to?: Vector3): void;
  78969. }
  78970. /**
  78971. * Interface for the size containing width and height
  78972. */
  78973. interface IXYZ {
  78974. /**
  78975. * X
  78976. */
  78977. x: number;
  78978. /**
  78979. * Y
  78980. */
  78981. y: number;
  78982. /**
  78983. * Z
  78984. */
  78985. z: number;
  78986. }
  78987. }
  78988. declare module BABYLON {
  78989. /**
  78990. * Interface used to describe a physics joint
  78991. */
  78992. export interface PhysicsImpostorJoint {
  78993. /** Defines the main impostor to which the joint is linked */
  78994. mainImpostor: PhysicsImpostor;
  78995. /** Defines the impostor that is connected to the main impostor using this joint */
  78996. connectedImpostor: PhysicsImpostor;
  78997. /** Defines the joint itself */
  78998. joint: PhysicsJoint;
  78999. }
  79000. /** @hidden */
  79001. export interface IPhysicsEnginePlugin {
  79002. world: any;
  79003. name: string;
  79004. setGravity(gravity: Vector3): void;
  79005. setTimeStep(timeStep: number): void;
  79006. getTimeStep(): number;
  79007. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79008. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79009. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79010. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79011. removePhysicsBody(impostor: PhysicsImpostor): void;
  79012. generateJoint(joint: PhysicsImpostorJoint): void;
  79013. removeJoint(joint: PhysicsImpostorJoint): void;
  79014. isSupported(): boolean;
  79015. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79016. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79017. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79018. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79019. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79020. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79021. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79022. getBodyMass(impostor: PhysicsImpostor): number;
  79023. getBodyFriction(impostor: PhysicsImpostor): number;
  79024. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79025. getBodyRestitution(impostor: PhysicsImpostor): number;
  79026. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79027. getBodyPressure?(impostor: PhysicsImpostor): number;
  79028. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79029. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79030. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79031. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79032. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79033. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79034. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79035. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79036. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79037. sleepBody(impostor: PhysicsImpostor): void;
  79038. wakeUpBody(impostor: PhysicsImpostor): void;
  79039. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79040. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79041. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79042. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79043. getRadius(impostor: PhysicsImpostor): number;
  79044. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79045. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79046. dispose(): void;
  79047. }
  79048. /**
  79049. * Interface used to define a physics engine
  79050. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79051. */
  79052. export interface IPhysicsEngine {
  79053. /**
  79054. * Gets the gravity vector used by the simulation
  79055. */
  79056. gravity: Vector3;
  79057. /**
  79058. * Sets the gravity vector used by the simulation
  79059. * @param gravity defines the gravity vector to use
  79060. */
  79061. setGravity(gravity: Vector3): void;
  79062. /**
  79063. * Set the time step of the physics engine.
  79064. * Default is 1/60.
  79065. * To slow it down, enter 1/600 for example.
  79066. * To speed it up, 1/30
  79067. * @param newTimeStep the new timestep to apply to this world.
  79068. */
  79069. setTimeStep(newTimeStep: number): void;
  79070. /**
  79071. * Get the time step of the physics engine.
  79072. * @returns the current time step
  79073. */
  79074. getTimeStep(): number;
  79075. /**
  79076. * Release all resources
  79077. */
  79078. dispose(): void;
  79079. /**
  79080. * Gets the name of the current physics plugin
  79081. * @returns the name of the plugin
  79082. */
  79083. getPhysicsPluginName(): string;
  79084. /**
  79085. * Adding a new impostor for the impostor tracking.
  79086. * This will be done by the impostor itself.
  79087. * @param impostor the impostor to add
  79088. */
  79089. addImpostor(impostor: PhysicsImpostor): void;
  79090. /**
  79091. * Remove an impostor from the engine.
  79092. * This impostor and its mesh will not longer be updated by the physics engine.
  79093. * @param impostor the impostor to remove
  79094. */
  79095. removeImpostor(impostor: PhysicsImpostor): void;
  79096. /**
  79097. * Add a joint to the physics engine
  79098. * @param mainImpostor defines the main impostor to which the joint is added.
  79099. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79100. * @param joint defines the joint that will connect both impostors.
  79101. */
  79102. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79103. /**
  79104. * Removes a joint from the simulation
  79105. * @param mainImpostor defines the impostor used with the joint
  79106. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79107. * @param joint defines the joint to remove
  79108. */
  79109. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79110. /**
  79111. * Gets the current plugin used to run the simulation
  79112. * @returns current plugin
  79113. */
  79114. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79115. /**
  79116. * Gets the list of physic impostors
  79117. * @returns an array of PhysicsImpostor
  79118. */
  79119. getImpostors(): Array<PhysicsImpostor>;
  79120. /**
  79121. * Gets the impostor for a physics enabled object
  79122. * @param object defines the object impersonated by the impostor
  79123. * @returns the PhysicsImpostor or null if not found
  79124. */
  79125. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79126. /**
  79127. * Gets the impostor for a physics body object
  79128. * @param body defines physics body used by the impostor
  79129. * @returns the PhysicsImpostor or null if not found
  79130. */
  79131. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79132. /**
  79133. * Does a raycast in the physics world
  79134. * @param from when should the ray start?
  79135. * @param to when should the ray end?
  79136. * @returns PhysicsRaycastResult
  79137. */
  79138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79139. /**
  79140. * Called by the scene. No need to call it.
  79141. * @param delta defines the timespam between frames
  79142. */
  79143. _step(delta: number): void;
  79144. }
  79145. }
  79146. declare module BABYLON {
  79147. /**
  79148. * The interface for the physics imposter parameters
  79149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79150. */
  79151. export interface PhysicsImpostorParameters {
  79152. /**
  79153. * The mass of the physics imposter
  79154. */
  79155. mass: number;
  79156. /**
  79157. * The friction of the physics imposter
  79158. */
  79159. friction?: number;
  79160. /**
  79161. * The coefficient of restitution of the physics imposter
  79162. */
  79163. restitution?: number;
  79164. /**
  79165. * The native options of the physics imposter
  79166. */
  79167. nativeOptions?: any;
  79168. /**
  79169. * Specifies if the parent should be ignored
  79170. */
  79171. ignoreParent?: boolean;
  79172. /**
  79173. * Specifies if bi-directional transformations should be disabled
  79174. */
  79175. disableBidirectionalTransformation?: boolean;
  79176. /**
  79177. * The pressure inside the physics imposter, soft object only
  79178. */
  79179. pressure?: number;
  79180. /**
  79181. * The stiffness the physics imposter, soft object only
  79182. */
  79183. stiffness?: number;
  79184. /**
  79185. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79186. */
  79187. velocityIterations?: number;
  79188. /**
  79189. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79190. */
  79191. positionIterations?: number;
  79192. /**
  79193. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79194. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79195. * Add to fix multiple points
  79196. */
  79197. fixedPoints?: number;
  79198. /**
  79199. * The collision margin around a soft object
  79200. */
  79201. margin?: number;
  79202. /**
  79203. * The collision margin around a soft object
  79204. */
  79205. damping?: number;
  79206. /**
  79207. * The path for a rope based on an extrusion
  79208. */
  79209. path?: any;
  79210. /**
  79211. * The shape of an extrusion used for a rope based on an extrusion
  79212. */
  79213. shape?: any;
  79214. }
  79215. /**
  79216. * Interface for a physics-enabled object
  79217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79218. */
  79219. export interface IPhysicsEnabledObject {
  79220. /**
  79221. * The position of the physics-enabled object
  79222. */
  79223. position: Vector3;
  79224. /**
  79225. * The rotation of the physics-enabled object
  79226. */
  79227. rotationQuaternion: Nullable<Quaternion>;
  79228. /**
  79229. * The scale of the physics-enabled object
  79230. */
  79231. scaling: Vector3;
  79232. /**
  79233. * The rotation of the physics-enabled object
  79234. */
  79235. rotation?: Vector3;
  79236. /**
  79237. * The parent of the physics-enabled object
  79238. */
  79239. parent?: any;
  79240. /**
  79241. * The bounding info of the physics-enabled object
  79242. * @returns The bounding info of the physics-enabled object
  79243. */
  79244. getBoundingInfo(): BoundingInfo;
  79245. /**
  79246. * Computes the world matrix
  79247. * @param force Specifies if the world matrix should be computed by force
  79248. * @returns A world matrix
  79249. */
  79250. computeWorldMatrix(force: boolean): Matrix;
  79251. /**
  79252. * Gets the world matrix
  79253. * @returns A world matrix
  79254. */
  79255. getWorldMatrix?(): Matrix;
  79256. /**
  79257. * Gets the child meshes
  79258. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79259. * @returns An array of abstract meshes
  79260. */
  79261. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79262. /**
  79263. * Gets the vertex data
  79264. * @param kind The type of vertex data
  79265. * @returns A nullable array of numbers, or a float32 array
  79266. */
  79267. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79268. /**
  79269. * Gets the indices from the mesh
  79270. * @returns A nullable array of index arrays
  79271. */
  79272. getIndices?(): Nullable<IndicesArray>;
  79273. /**
  79274. * Gets the scene from the mesh
  79275. * @returns the indices array or null
  79276. */
  79277. getScene?(): Scene;
  79278. /**
  79279. * Gets the absolute position from the mesh
  79280. * @returns the absolute position
  79281. */
  79282. getAbsolutePosition(): Vector3;
  79283. /**
  79284. * Gets the absolute pivot point from the mesh
  79285. * @returns the absolute pivot point
  79286. */
  79287. getAbsolutePivotPoint(): Vector3;
  79288. /**
  79289. * Rotates the mesh
  79290. * @param axis The axis of rotation
  79291. * @param amount The amount of rotation
  79292. * @param space The space of the rotation
  79293. * @returns The rotation transform node
  79294. */
  79295. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79296. /**
  79297. * Translates the mesh
  79298. * @param axis The axis of translation
  79299. * @param distance The distance of translation
  79300. * @param space The space of the translation
  79301. * @returns The transform node
  79302. */
  79303. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79304. /**
  79305. * Sets the absolute position of the mesh
  79306. * @param absolutePosition The absolute position of the mesh
  79307. * @returns The transform node
  79308. */
  79309. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79310. /**
  79311. * Gets the class name of the mesh
  79312. * @returns The class name
  79313. */
  79314. getClassName(): string;
  79315. }
  79316. /**
  79317. * Represents a physics imposter
  79318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79319. */
  79320. export class PhysicsImpostor {
  79321. /**
  79322. * The physics-enabled object used as the physics imposter
  79323. */
  79324. object: IPhysicsEnabledObject;
  79325. /**
  79326. * The type of the physics imposter
  79327. */
  79328. type: number;
  79329. private _options;
  79330. private _scene?;
  79331. /**
  79332. * The default object size of the imposter
  79333. */
  79334. static DEFAULT_OBJECT_SIZE: Vector3;
  79335. /**
  79336. * The identity quaternion of the imposter
  79337. */
  79338. static IDENTITY_QUATERNION: Quaternion;
  79339. /** @hidden */
  79340. _pluginData: any;
  79341. private _physicsEngine;
  79342. private _physicsBody;
  79343. private _bodyUpdateRequired;
  79344. private _onBeforePhysicsStepCallbacks;
  79345. private _onAfterPhysicsStepCallbacks;
  79346. /** @hidden */
  79347. _onPhysicsCollideCallbacks: Array<{
  79348. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79349. otherImpostors: Array<PhysicsImpostor>;
  79350. }>;
  79351. private _deltaPosition;
  79352. private _deltaRotation;
  79353. private _deltaRotationConjugated;
  79354. /** hidden */
  79355. _isFromLine: boolean;
  79356. private _parent;
  79357. private _isDisposed;
  79358. private static _tmpVecs;
  79359. private static _tmpQuat;
  79360. /**
  79361. * Specifies if the physics imposter is disposed
  79362. */
  79363. readonly isDisposed: boolean;
  79364. /**
  79365. * Gets the mass of the physics imposter
  79366. */
  79367. mass: number;
  79368. /**
  79369. * Gets the coefficient of friction
  79370. */
  79371. /**
  79372. * Sets the coefficient of friction
  79373. */
  79374. friction: number;
  79375. /**
  79376. * Gets the coefficient of restitution
  79377. */
  79378. /**
  79379. * Sets the coefficient of restitution
  79380. */
  79381. restitution: number;
  79382. /**
  79383. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79384. */
  79385. /**
  79386. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79387. */
  79388. pressure: number;
  79389. /**
  79390. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79391. */
  79392. /**
  79393. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79394. */
  79395. stiffness: number;
  79396. /**
  79397. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79398. */
  79399. /**
  79400. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79401. */
  79402. velocityIterations: number;
  79403. /**
  79404. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79405. */
  79406. /**
  79407. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79408. */
  79409. positionIterations: number;
  79410. /**
  79411. * The unique id of the physics imposter
  79412. * set by the physics engine when adding this impostor to the array
  79413. */
  79414. uniqueId: number;
  79415. /**
  79416. * @hidden
  79417. */
  79418. soft: boolean;
  79419. /**
  79420. * @hidden
  79421. */
  79422. segments: number;
  79423. private _joints;
  79424. /**
  79425. * Initializes the physics imposter
  79426. * @param object The physics-enabled object used as the physics imposter
  79427. * @param type The type of the physics imposter
  79428. * @param _options The options for the physics imposter
  79429. * @param _scene The Babylon scene
  79430. */
  79431. constructor(
  79432. /**
  79433. * The physics-enabled object used as the physics imposter
  79434. */
  79435. object: IPhysicsEnabledObject,
  79436. /**
  79437. * The type of the physics imposter
  79438. */
  79439. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79440. /**
  79441. * This function will completly initialize this impostor.
  79442. * It will create a new body - but only if this mesh has no parent.
  79443. * If it has, this impostor will not be used other than to define the impostor
  79444. * of the child mesh.
  79445. * @hidden
  79446. */
  79447. _init(): void;
  79448. private _getPhysicsParent;
  79449. /**
  79450. * Should a new body be generated.
  79451. * @returns boolean specifying if body initialization is required
  79452. */
  79453. isBodyInitRequired(): boolean;
  79454. /**
  79455. * Sets the updated scaling
  79456. * @param updated Specifies if the scaling is updated
  79457. */
  79458. setScalingUpdated(): void;
  79459. /**
  79460. * Force a regeneration of this or the parent's impostor's body.
  79461. * Use under cautious - This will remove all joints already implemented.
  79462. */
  79463. forceUpdate(): void;
  79464. /**
  79465. * Gets the body that holds this impostor. Either its own, or its parent.
  79466. */
  79467. /**
  79468. * Set the physics body. Used mainly by the physics engine/plugin
  79469. */
  79470. physicsBody: any;
  79471. /**
  79472. * Get the parent of the physics imposter
  79473. * @returns Physics imposter or null
  79474. */
  79475. /**
  79476. * Sets the parent of the physics imposter
  79477. */
  79478. parent: Nullable<PhysicsImpostor>;
  79479. /**
  79480. * Resets the update flags
  79481. */
  79482. resetUpdateFlags(): void;
  79483. /**
  79484. * Gets the object extend size
  79485. * @returns the object extend size
  79486. */
  79487. getObjectExtendSize(): Vector3;
  79488. /**
  79489. * Gets the object center
  79490. * @returns The object center
  79491. */
  79492. getObjectCenter(): Vector3;
  79493. /**
  79494. * Get a specific parametes from the options parameter
  79495. * @param paramName The object parameter name
  79496. * @returns The object parameter
  79497. */
  79498. getParam(paramName: string): any;
  79499. /**
  79500. * Sets a specific parameter in the options given to the physics plugin
  79501. * @param paramName The parameter name
  79502. * @param value The value of the parameter
  79503. */
  79504. setParam(paramName: string, value: number): void;
  79505. /**
  79506. * Specifically change the body's mass option. Won't recreate the physics body object
  79507. * @param mass The mass of the physics imposter
  79508. */
  79509. setMass(mass: number): void;
  79510. /**
  79511. * Gets the linear velocity
  79512. * @returns linear velocity or null
  79513. */
  79514. getLinearVelocity(): Nullable<Vector3>;
  79515. /**
  79516. * Sets the linear velocity
  79517. * @param velocity linear velocity or null
  79518. */
  79519. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79520. /**
  79521. * Gets the angular velocity
  79522. * @returns angular velocity or null
  79523. */
  79524. getAngularVelocity(): Nullable<Vector3>;
  79525. /**
  79526. * Sets the angular velocity
  79527. * @param velocity The velocity or null
  79528. */
  79529. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79530. /**
  79531. * Execute a function with the physics plugin native code
  79532. * Provide a function the will have two variables - the world object and the physics body object
  79533. * @param func The function to execute with the physics plugin native code
  79534. */
  79535. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79536. /**
  79537. * Register a function that will be executed before the physics world is stepping forward
  79538. * @param func The function to execute before the physics world is stepped forward
  79539. */
  79540. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79541. /**
  79542. * Unregister a function that will be executed before the physics world is stepping forward
  79543. * @param func The function to execute before the physics world is stepped forward
  79544. */
  79545. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79546. /**
  79547. * Register a function that will be executed after the physics step
  79548. * @param func The function to execute after physics step
  79549. */
  79550. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79551. /**
  79552. * Unregisters a function that will be executed after the physics step
  79553. * @param func The function to execute after physics step
  79554. */
  79555. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79556. /**
  79557. * register a function that will be executed when this impostor collides against a different body
  79558. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79559. * @param func Callback that is executed on collision
  79560. */
  79561. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79562. /**
  79563. * Unregisters the physics imposter on contact
  79564. * @param collideAgainst The physics object to collide against
  79565. * @param func Callback to execute on collision
  79566. */
  79567. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79568. private _tmpQuat;
  79569. private _tmpQuat2;
  79570. /**
  79571. * Get the parent rotation
  79572. * @returns The parent rotation
  79573. */
  79574. getParentsRotation(): Quaternion;
  79575. /**
  79576. * this function is executed by the physics engine.
  79577. */
  79578. beforeStep: () => void;
  79579. /**
  79580. * this function is executed by the physics engine
  79581. */
  79582. afterStep: () => void;
  79583. /**
  79584. * Legacy collision detection event support
  79585. */
  79586. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79587. /**
  79588. * event and body object due to cannon's event-based architecture.
  79589. */
  79590. onCollide: (e: {
  79591. body: any;
  79592. }) => void;
  79593. /**
  79594. * Apply a force
  79595. * @param force The force to apply
  79596. * @param contactPoint The contact point for the force
  79597. * @returns The physics imposter
  79598. */
  79599. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79600. /**
  79601. * Apply an impulse
  79602. * @param force The impulse force
  79603. * @param contactPoint The contact point for the impulse force
  79604. * @returns The physics imposter
  79605. */
  79606. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79607. /**
  79608. * A help function to create a joint
  79609. * @param otherImpostor A physics imposter used to create a joint
  79610. * @param jointType The type of joint
  79611. * @param jointData The data for the joint
  79612. * @returns The physics imposter
  79613. */
  79614. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79615. /**
  79616. * Add a joint to this impostor with a different impostor
  79617. * @param otherImpostor A physics imposter used to add a joint
  79618. * @param joint The joint to add
  79619. * @returns The physics imposter
  79620. */
  79621. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79622. /**
  79623. * Add an anchor to a cloth impostor
  79624. * @param otherImpostor rigid impostor to anchor to
  79625. * @param width ratio across width from 0 to 1
  79626. * @param height ratio up height from 0 to 1
  79627. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79628. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79629. * @returns impostor the soft imposter
  79630. */
  79631. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79632. /**
  79633. * Add a hook to a rope impostor
  79634. * @param otherImpostor rigid impostor to anchor to
  79635. * @param length ratio across rope from 0 to 1
  79636. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79637. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79638. * @returns impostor the rope imposter
  79639. */
  79640. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79641. /**
  79642. * Will keep this body still, in a sleep mode.
  79643. * @returns the physics imposter
  79644. */
  79645. sleep(): PhysicsImpostor;
  79646. /**
  79647. * Wake the body up.
  79648. * @returns The physics imposter
  79649. */
  79650. wakeUp(): PhysicsImpostor;
  79651. /**
  79652. * Clones the physics imposter
  79653. * @param newObject The physics imposter clones to this physics-enabled object
  79654. * @returns A nullable physics imposter
  79655. */
  79656. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79657. /**
  79658. * Disposes the physics imposter
  79659. */
  79660. dispose(): void;
  79661. /**
  79662. * Sets the delta position
  79663. * @param position The delta position amount
  79664. */
  79665. setDeltaPosition(position: Vector3): void;
  79666. /**
  79667. * Sets the delta rotation
  79668. * @param rotation The delta rotation amount
  79669. */
  79670. setDeltaRotation(rotation: Quaternion): void;
  79671. /**
  79672. * Gets the box size of the physics imposter and stores the result in the input parameter
  79673. * @param result Stores the box size
  79674. * @returns The physics imposter
  79675. */
  79676. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79677. /**
  79678. * Gets the radius of the physics imposter
  79679. * @returns Radius of the physics imposter
  79680. */
  79681. getRadius(): number;
  79682. /**
  79683. * Sync a bone with this impostor
  79684. * @param bone The bone to sync to the impostor.
  79685. * @param boneMesh The mesh that the bone is influencing.
  79686. * @param jointPivot The pivot of the joint / bone in local space.
  79687. * @param distToJoint Optional distance from the impostor to the joint.
  79688. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79689. */
  79690. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79691. /**
  79692. * Sync impostor to a bone
  79693. * @param bone The bone that the impostor will be synced to.
  79694. * @param boneMesh The mesh that the bone is influencing.
  79695. * @param jointPivot The pivot of the joint / bone in local space.
  79696. * @param distToJoint Optional distance from the impostor to the joint.
  79697. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79698. * @param boneAxis Optional vector3 axis the bone is aligned with
  79699. */
  79700. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79701. /**
  79702. * No-Imposter type
  79703. */
  79704. static NoImpostor: number;
  79705. /**
  79706. * Sphere-Imposter type
  79707. */
  79708. static SphereImpostor: number;
  79709. /**
  79710. * Box-Imposter type
  79711. */
  79712. static BoxImpostor: number;
  79713. /**
  79714. * Plane-Imposter type
  79715. */
  79716. static PlaneImpostor: number;
  79717. /**
  79718. * Mesh-imposter type
  79719. */
  79720. static MeshImpostor: number;
  79721. /**
  79722. * Cylinder-Imposter type
  79723. */
  79724. static CylinderImpostor: number;
  79725. /**
  79726. * Particle-Imposter type
  79727. */
  79728. static ParticleImpostor: number;
  79729. /**
  79730. * Heightmap-Imposter type
  79731. */
  79732. static HeightmapImpostor: number;
  79733. /**
  79734. * ConvexHull-Impostor type (Ammo.js plugin only)
  79735. */
  79736. static ConvexHullImpostor: number;
  79737. /**
  79738. * Rope-Imposter type
  79739. */
  79740. static RopeImpostor: number;
  79741. /**
  79742. * Cloth-Imposter type
  79743. */
  79744. static ClothImpostor: number;
  79745. /**
  79746. * Softbody-Imposter type
  79747. */
  79748. static SoftbodyImpostor: number;
  79749. }
  79750. }
  79751. declare module BABYLON {
  79752. /**
  79753. * Class used to represent a specific level of detail of a mesh
  79754. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79755. */
  79756. export class MeshLODLevel {
  79757. /** Defines the distance where this level should star being displayed */
  79758. distance: number;
  79759. /** Defines the mesh to use to render this level */
  79760. mesh: Nullable<Mesh>;
  79761. /**
  79762. * Creates a new LOD level
  79763. * @param distance defines the distance where this level should star being displayed
  79764. * @param mesh defines the mesh to use to render this level
  79765. */
  79766. constructor(
  79767. /** Defines the distance where this level should star being displayed */
  79768. distance: number,
  79769. /** Defines the mesh to use to render this level */
  79770. mesh: Nullable<Mesh>);
  79771. }
  79772. /**
  79773. * @hidden
  79774. **/
  79775. export class _CreationDataStorage {
  79776. closePath?: boolean;
  79777. closeArray?: boolean;
  79778. idx: number[];
  79779. dashSize: number;
  79780. gapSize: number;
  79781. path3D: Path3D;
  79782. pathArray: Vector3[][];
  79783. arc: number;
  79784. radius: number;
  79785. cap: number;
  79786. tessellation: number;
  79787. }
  79788. /**
  79789. * @hidden
  79790. **/
  79791. class _InstanceDataStorage {
  79792. visibleInstances: any;
  79793. renderIdForInstances: number[];
  79794. batchCache: _InstancesBatch;
  79795. instancesBufferSize: number;
  79796. instancesBuffer: Nullable<Buffer>;
  79797. instancesData: Float32Array;
  79798. overridenInstanceCount: number;
  79799. }
  79800. /**
  79801. * @hidden
  79802. **/
  79803. export class _InstancesBatch {
  79804. mustReturn: boolean;
  79805. visibleInstances: Nullable<InstancedMesh[]>[];
  79806. renderSelf: boolean[];
  79807. }
  79808. /**
  79809. * Class used to represent renderable models
  79810. */
  79811. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79812. /**
  79813. * Mesh side orientation : usually the external or front surface
  79814. */
  79815. static readonly FRONTSIDE: number;
  79816. /**
  79817. * Mesh side orientation : usually the internal or back surface
  79818. */
  79819. static readonly BACKSIDE: number;
  79820. /**
  79821. * Mesh side orientation : both internal and external or front and back surfaces
  79822. */
  79823. static readonly DOUBLESIDE: number;
  79824. /**
  79825. * Mesh side orientation : by default, `FRONTSIDE`
  79826. */
  79827. static readonly DEFAULTSIDE: number;
  79828. /**
  79829. * Mesh cap setting : no cap
  79830. */
  79831. static readonly NO_CAP: number;
  79832. /**
  79833. * Mesh cap setting : one cap at the beginning of the mesh
  79834. */
  79835. static readonly CAP_START: number;
  79836. /**
  79837. * Mesh cap setting : one cap at the end of the mesh
  79838. */
  79839. static readonly CAP_END: number;
  79840. /**
  79841. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79842. */
  79843. static readonly CAP_ALL: number;
  79844. /**
  79845. * Gets the default side orientation.
  79846. * @param orientation the orientation to value to attempt to get
  79847. * @returns the default orientation
  79848. * @hidden
  79849. */
  79850. static _GetDefaultSideOrientation(orientation?: number): number;
  79851. private _onBeforeRenderObservable;
  79852. private _onBeforeBindObservable;
  79853. private _onAfterRenderObservable;
  79854. private _onBeforeDrawObservable;
  79855. /**
  79856. * An event triggered before rendering the mesh
  79857. */
  79858. readonly onBeforeRenderObservable: Observable<Mesh>;
  79859. /**
  79860. * An event triggered before binding the mesh
  79861. */
  79862. readonly onBeforeBindObservable: Observable<Mesh>;
  79863. /**
  79864. * An event triggered after rendering the mesh
  79865. */
  79866. readonly onAfterRenderObservable: Observable<Mesh>;
  79867. /**
  79868. * An event triggered before drawing the mesh
  79869. */
  79870. readonly onBeforeDrawObservable: Observable<Mesh>;
  79871. private _onBeforeDrawObserver;
  79872. /**
  79873. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79874. */
  79875. onBeforeDraw: () => void;
  79876. /**
  79877. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79878. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79879. */
  79880. delayLoadState: number;
  79881. /**
  79882. * Gets the list of instances created from this mesh
  79883. * it is not supposed to be modified manually.
  79884. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79885. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79886. */
  79887. instances: InstancedMesh[];
  79888. /**
  79889. * Gets the file containing delay loading data for this mesh
  79890. */
  79891. delayLoadingFile: string;
  79892. /** @hidden */
  79893. _binaryInfo: any;
  79894. private _LODLevels;
  79895. /**
  79896. * User defined function used to change how LOD level selection is done
  79897. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79898. */
  79899. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79900. private _morphTargetManager;
  79901. /**
  79902. * Gets or sets the morph target manager
  79903. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79904. */
  79905. morphTargetManager: Nullable<MorphTargetManager>;
  79906. /** @hidden */
  79907. _creationDataStorage: Nullable<_CreationDataStorage>;
  79908. /** @hidden */
  79909. _geometry: Nullable<Geometry>;
  79910. /** @hidden */
  79911. _delayInfo: Array<string>;
  79912. /** @hidden */
  79913. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79914. /** @hidden */
  79915. _instanceDataStorage: _InstanceDataStorage;
  79916. private _effectiveMaterial;
  79917. /** @hidden */
  79918. _shouldGenerateFlatShading: boolean;
  79919. private _preActivateId;
  79920. /** @hidden */
  79921. _originalBuilderSideOrientation: number;
  79922. /**
  79923. * Use this property to change the original side orientation defined at construction time
  79924. */
  79925. overrideMaterialSideOrientation: Nullable<number>;
  79926. private _areNormalsFrozen;
  79927. private _sourcePositions;
  79928. private _sourceNormals;
  79929. private _source;
  79930. private meshMap;
  79931. /**
  79932. * Gets the source mesh (the one used to clone this one from)
  79933. */
  79934. readonly source: Nullable<Mesh>;
  79935. /**
  79936. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79937. */
  79938. isUnIndexed: boolean;
  79939. /**
  79940. * @constructor
  79941. * @param name The value used by scene.getMeshByName() to do a lookup.
  79942. * @param scene The scene to add this mesh to.
  79943. * @param parent The parent of this mesh, if it has one
  79944. * @param source An optional Mesh from which geometry is shared, cloned.
  79945. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79946. * When false, achieved by calling a clone(), also passing False.
  79947. * This will make creation of children, recursive.
  79948. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79949. */
  79950. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79951. /**
  79952. * Gets the class name
  79953. * @returns the string "Mesh".
  79954. */
  79955. getClassName(): string;
  79956. /** @hidden */
  79957. readonly _isMesh: boolean;
  79958. /**
  79959. * Returns a description of this mesh
  79960. * @param fullDetails define if full details about this mesh must be used
  79961. * @returns a descriptive string representing this mesh
  79962. */
  79963. toString(fullDetails?: boolean): string;
  79964. /** @hidden */
  79965. _unBindEffect(): void;
  79966. /**
  79967. * Gets a boolean indicating if this mesh has LOD
  79968. */
  79969. readonly hasLODLevels: boolean;
  79970. /**
  79971. * Gets the list of MeshLODLevel associated with the current mesh
  79972. * @returns an array of MeshLODLevel
  79973. */
  79974. getLODLevels(): MeshLODLevel[];
  79975. private _sortLODLevels;
  79976. /**
  79977. * Add a mesh as LOD level triggered at the given distance.
  79978. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79979. * @param distance The distance from the center of the object to show this level
  79980. * @param mesh The mesh to be added as LOD level (can be null)
  79981. * @return This mesh (for chaining)
  79982. */
  79983. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79984. /**
  79985. * Returns the LOD level mesh at the passed distance or null if not found.
  79986. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79987. * @param distance The distance from the center of the object to show this level
  79988. * @returns a Mesh or `null`
  79989. */
  79990. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79991. /**
  79992. * Remove a mesh from the LOD array
  79993. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79994. * @param mesh defines the mesh to be removed
  79995. * @return This mesh (for chaining)
  79996. */
  79997. removeLODLevel(mesh: Mesh): Mesh;
  79998. /**
  79999. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80000. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80001. * @param camera defines the camera to use to compute distance
  80002. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80003. * @return This mesh (for chaining)
  80004. */
  80005. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80006. /**
  80007. * Gets the mesh internal Geometry object
  80008. */
  80009. readonly geometry: Nullable<Geometry>;
  80010. /**
  80011. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80012. * @returns the total number of vertices
  80013. */
  80014. getTotalVertices(): number;
  80015. /**
  80016. * Returns the content of an associated vertex buffer
  80017. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80018. * - VertexBuffer.PositionKind
  80019. * - VertexBuffer.UVKind
  80020. * - VertexBuffer.UV2Kind
  80021. * - VertexBuffer.UV3Kind
  80022. * - VertexBuffer.UV4Kind
  80023. * - VertexBuffer.UV5Kind
  80024. * - VertexBuffer.UV6Kind
  80025. * - VertexBuffer.ColorKind
  80026. * - VertexBuffer.MatricesIndicesKind
  80027. * - VertexBuffer.MatricesIndicesExtraKind
  80028. * - VertexBuffer.MatricesWeightsKind
  80029. * - VertexBuffer.MatricesWeightsExtraKind
  80030. * @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
  80031. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80032. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80033. */
  80034. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80035. /**
  80036. * Returns the mesh VertexBuffer object from the requested `kind`
  80037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80038. * - VertexBuffer.PositionKind
  80039. * - VertexBuffer.UVKind
  80040. * - VertexBuffer.UV2Kind
  80041. * - VertexBuffer.UV3Kind
  80042. * - VertexBuffer.UV4Kind
  80043. * - VertexBuffer.UV5Kind
  80044. * - VertexBuffer.UV6Kind
  80045. * - VertexBuffer.ColorKind
  80046. * - VertexBuffer.MatricesIndicesKind
  80047. * - VertexBuffer.MatricesIndicesExtraKind
  80048. * - VertexBuffer.MatricesWeightsKind
  80049. * - VertexBuffer.MatricesWeightsExtraKind
  80050. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80051. */
  80052. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80053. /**
  80054. * Tests if a specific vertex buffer is associated with this mesh
  80055. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80056. * - VertexBuffer.PositionKind
  80057. * - VertexBuffer.UVKind
  80058. * - VertexBuffer.UV2Kind
  80059. * - VertexBuffer.UV3Kind
  80060. * - VertexBuffer.UV4Kind
  80061. * - VertexBuffer.UV5Kind
  80062. * - VertexBuffer.UV6Kind
  80063. * - VertexBuffer.ColorKind
  80064. * - VertexBuffer.MatricesIndicesKind
  80065. * - VertexBuffer.MatricesIndicesExtraKind
  80066. * - VertexBuffer.MatricesWeightsKind
  80067. * - VertexBuffer.MatricesWeightsExtraKind
  80068. * @returns a boolean
  80069. */
  80070. isVerticesDataPresent(kind: string): boolean;
  80071. /**
  80072. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80073. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80074. * - VertexBuffer.PositionKind
  80075. * - VertexBuffer.UVKind
  80076. * - VertexBuffer.UV2Kind
  80077. * - VertexBuffer.UV3Kind
  80078. * - VertexBuffer.UV4Kind
  80079. * - VertexBuffer.UV5Kind
  80080. * - VertexBuffer.UV6Kind
  80081. * - VertexBuffer.ColorKind
  80082. * - VertexBuffer.MatricesIndicesKind
  80083. * - VertexBuffer.MatricesIndicesExtraKind
  80084. * - VertexBuffer.MatricesWeightsKind
  80085. * - VertexBuffer.MatricesWeightsExtraKind
  80086. * @returns a boolean
  80087. */
  80088. isVertexBufferUpdatable(kind: string): boolean;
  80089. /**
  80090. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80091. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80092. * - VertexBuffer.PositionKind
  80093. * - VertexBuffer.UVKind
  80094. * - VertexBuffer.UV2Kind
  80095. * - VertexBuffer.UV3Kind
  80096. * - VertexBuffer.UV4Kind
  80097. * - VertexBuffer.UV5Kind
  80098. * - VertexBuffer.UV6Kind
  80099. * - VertexBuffer.ColorKind
  80100. * - VertexBuffer.MatricesIndicesKind
  80101. * - VertexBuffer.MatricesIndicesExtraKind
  80102. * - VertexBuffer.MatricesWeightsKind
  80103. * - VertexBuffer.MatricesWeightsExtraKind
  80104. * @returns an array of strings
  80105. */
  80106. getVerticesDataKinds(): string[];
  80107. /**
  80108. * Returns a positive integer : the total number of indices in this mesh geometry.
  80109. * @returns the numner of indices or zero if the mesh has no geometry.
  80110. */
  80111. getTotalIndices(): number;
  80112. /**
  80113. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80114. * @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.
  80115. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80116. * @returns the indices array or an empty array if the mesh has no geometry
  80117. */
  80118. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80119. readonly isBlocked: boolean;
  80120. /**
  80121. * Determine if the current mesh is ready to be rendered
  80122. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80123. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80124. * @returns true if all associated assets are ready (material, textures, shaders)
  80125. */
  80126. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80127. /**
  80128. * 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.
  80129. */
  80130. readonly areNormalsFrozen: boolean;
  80131. /**
  80132. * 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.
  80133. * @returns the current mesh
  80134. */
  80135. freezeNormals(): Mesh;
  80136. /**
  80137. * 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
  80138. * @returns the current mesh
  80139. */
  80140. unfreezeNormals(): Mesh;
  80141. /**
  80142. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80143. */
  80144. overridenInstanceCount: number;
  80145. /** @hidden */
  80146. _preActivate(): Mesh;
  80147. /** @hidden */
  80148. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80149. /** @hidden */
  80150. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80151. /**
  80152. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80153. * This means the mesh underlying bounding box and sphere are recomputed.
  80154. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80155. * @returns the current mesh
  80156. */
  80157. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80158. /** @hidden */
  80159. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80160. /**
  80161. * This function will subdivide the mesh into multiple submeshes
  80162. * @param count defines the expected number of submeshes
  80163. */
  80164. subdivide(count: number): void;
  80165. /**
  80166. * Copy a FloatArray into a specific associated vertex buffer
  80167. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80168. * - VertexBuffer.PositionKind
  80169. * - VertexBuffer.UVKind
  80170. * - VertexBuffer.UV2Kind
  80171. * - VertexBuffer.UV3Kind
  80172. * - VertexBuffer.UV4Kind
  80173. * - VertexBuffer.UV5Kind
  80174. * - VertexBuffer.UV6Kind
  80175. * - VertexBuffer.ColorKind
  80176. * - VertexBuffer.MatricesIndicesKind
  80177. * - VertexBuffer.MatricesIndicesExtraKind
  80178. * - VertexBuffer.MatricesWeightsKind
  80179. * - VertexBuffer.MatricesWeightsExtraKind
  80180. * @param data defines the data source
  80181. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80182. * @param stride defines the data stride size (can be null)
  80183. * @returns the current mesh
  80184. */
  80185. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80186. /**
  80187. * Flags an associated vertex buffer as updatable
  80188. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80189. * - VertexBuffer.PositionKind
  80190. * - VertexBuffer.UVKind
  80191. * - VertexBuffer.UV2Kind
  80192. * - VertexBuffer.UV3Kind
  80193. * - VertexBuffer.UV4Kind
  80194. * - VertexBuffer.UV5Kind
  80195. * - VertexBuffer.UV6Kind
  80196. * - VertexBuffer.ColorKind
  80197. * - VertexBuffer.MatricesIndicesKind
  80198. * - VertexBuffer.MatricesIndicesExtraKind
  80199. * - VertexBuffer.MatricesWeightsKind
  80200. * - VertexBuffer.MatricesWeightsExtraKind
  80201. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80202. */
  80203. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80204. /**
  80205. * Sets the mesh global Vertex Buffer
  80206. * @param buffer defines the buffer to use
  80207. * @returns the current mesh
  80208. */
  80209. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80210. /**
  80211. * Update a specific associated vertex buffer
  80212. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80213. * - VertexBuffer.PositionKind
  80214. * - VertexBuffer.UVKind
  80215. * - VertexBuffer.UV2Kind
  80216. * - VertexBuffer.UV3Kind
  80217. * - VertexBuffer.UV4Kind
  80218. * - VertexBuffer.UV5Kind
  80219. * - VertexBuffer.UV6Kind
  80220. * - VertexBuffer.ColorKind
  80221. * - VertexBuffer.MatricesIndicesKind
  80222. * - VertexBuffer.MatricesIndicesExtraKind
  80223. * - VertexBuffer.MatricesWeightsKind
  80224. * - VertexBuffer.MatricesWeightsExtraKind
  80225. * @param data defines the data source
  80226. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80227. * @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)
  80228. * @returns the current mesh
  80229. */
  80230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80231. /**
  80232. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80233. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80234. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80235. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80236. * @returns the current mesh
  80237. */
  80238. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80239. /**
  80240. * Creates a un-shared specific occurence of the geometry for the mesh.
  80241. * @returns the current mesh
  80242. */
  80243. makeGeometryUnique(): Mesh;
  80244. /**
  80245. * Set the index buffer of this mesh
  80246. * @param indices defines the source data
  80247. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80248. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80249. * @returns the current mesh
  80250. */
  80251. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80252. /**
  80253. * Update the current index buffer
  80254. * @param indices defines the source data
  80255. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80256. * @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)
  80257. * @returns the current mesh
  80258. */
  80259. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80260. /**
  80261. * Invert the geometry to move from a right handed system to a left handed one.
  80262. * @returns the current mesh
  80263. */
  80264. toLeftHanded(): Mesh;
  80265. /** @hidden */
  80266. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80267. /** @hidden */
  80268. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80269. /**
  80270. * Registers for this mesh a javascript function called just before the rendering process
  80271. * @param func defines the function to call before rendering this mesh
  80272. * @returns the current mesh
  80273. */
  80274. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80275. /**
  80276. * Disposes a previously registered javascript function called before the rendering
  80277. * @param func defines the function to remove
  80278. * @returns the current mesh
  80279. */
  80280. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80281. /**
  80282. * Registers for this mesh a javascript function called just after the rendering is complete
  80283. * @param func defines the function to call after rendering this mesh
  80284. * @returns the current mesh
  80285. */
  80286. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80287. /**
  80288. * Disposes a previously registered javascript function called after the rendering.
  80289. * @param func defines the function to remove
  80290. * @returns the current mesh
  80291. */
  80292. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80293. /** @hidden */
  80294. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80295. /** @hidden */
  80296. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80297. /** @hidden */
  80298. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80299. /**
  80300. * 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
  80301. * @param subMesh defines the subMesh to render
  80302. * @param enableAlphaMode defines if alpha mode can be changed
  80303. * @returns the current mesh
  80304. */
  80305. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80306. private _onBeforeDraw;
  80307. /**
  80308. * Renormalize the mesh and patch it up if there are no weights
  80309. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80310. * However in the case of zero weights then we set just a single influence to 1.
  80311. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80312. */
  80313. cleanMatrixWeights(): void;
  80314. private normalizeSkinFourWeights;
  80315. private normalizeSkinWeightsAndExtra;
  80316. /**
  80317. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80318. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80319. * the user know there was an issue with importing the mesh
  80320. * @returns a validation object with skinned, valid and report string
  80321. */
  80322. validateSkinning(): {
  80323. skinned: boolean;
  80324. valid: boolean;
  80325. report: string;
  80326. };
  80327. /** @hidden */
  80328. _checkDelayState(): Mesh;
  80329. private _queueLoad;
  80330. /**
  80331. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80332. * A mesh is in the frustum if its bounding box intersects the frustum
  80333. * @param frustumPlanes defines the frustum to test
  80334. * @returns true if the mesh is in the frustum planes
  80335. */
  80336. isInFrustum(frustumPlanes: Plane[]): boolean;
  80337. /**
  80338. * Sets the mesh material by the material or multiMaterial `id` property
  80339. * @param id is a string identifying the material or the multiMaterial
  80340. * @returns the current mesh
  80341. */
  80342. setMaterialByID(id: string): Mesh;
  80343. /**
  80344. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80345. * @returns an array of IAnimatable
  80346. */
  80347. getAnimatables(): IAnimatable[];
  80348. /**
  80349. * Modifies the mesh geometry according to the passed transformation matrix.
  80350. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80351. * The mesh normals are modified using the same transformation.
  80352. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80353. * @param transform defines the transform matrix to use
  80354. * @see http://doc.babylonjs.com/resources/baking_transformations
  80355. * @returns the current mesh
  80356. */
  80357. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80358. /**
  80359. * Modifies the mesh geometry according to its own current World Matrix.
  80360. * The mesh World Matrix is then reset.
  80361. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80362. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80363. * @see http://doc.babylonjs.com/resources/baking_transformations
  80364. * @returns the current mesh
  80365. */
  80366. bakeCurrentTransformIntoVertices(): Mesh;
  80367. /** @hidden */
  80368. readonly _positions: Nullable<Vector3[]>;
  80369. /** @hidden */
  80370. _resetPointsArrayCache(): Mesh;
  80371. /** @hidden */
  80372. _generatePointsArray(): boolean;
  80373. /**
  80374. * Returns a new Mesh object generated from the current mesh properties.
  80375. * This method must not get confused with createInstance()
  80376. * @param name is a string, the name given to the new mesh
  80377. * @param newParent can be any Node object (default `null`)
  80378. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80379. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80380. * @returns a new mesh
  80381. */
  80382. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80383. /**
  80384. * Releases resources associated with this mesh.
  80385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80387. */
  80388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80389. /**
  80390. * Modifies the mesh geometry according to a displacement map.
  80391. * 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.
  80392. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80393. * @param url is a string, the URL from the image file is to be downloaded.
  80394. * @param minHeight is the lower limit of the displacement.
  80395. * @param maxHeight is the upper limit of the displacement.
  80396. * @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.
  80397. * @param uvOffset is an optional vector2 used to offset UV.
  80398. * @param uvScale is an optional vector2 used to scale UV.
  80399. * @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.
  80400. * @returns the Mesh.
  80401. */
  80402. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80403. /**
  80404. * Modifies the mesh geometry according to a displacementMap buffer.
  80405. * 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.
  80406. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80407. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80408. * @param heightMapWidth is the width of the buffer image.
  80409. * @param heightMapHeight is the height of the buffer image.
  80410. * @param minHeight is the lower limit of the displacement.
  80411. * @param maxHeight is the upper limit of the displacement.
  80412. * @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.
  80413. * @param uvOffset is an optional vector2 used to offset UV.
  80414. * @param uvScale is an optional vector2 used to scale UV.
  80415. * @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.
  80416. * @returns the Mesh.
  80417. */
  80418. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80419. /**
  80420. * Modify the mesh to get a flat shading rendering.
  80421. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80422. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80423. * @returns current mesh
  80424. */
  80425. convertToFlatShadedMesh(): Mesh;
  80426. /**
  80427. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80428. * In other words, more vertices, no more indices and a single bigger VBO.
  80429. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80430. * @returns current mesh
  80431. */
  80432. convertToUnIndexedMesh(): Mesh;
  80433. /**
  80434. * Inverses facet orientations.
  80435. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80436. * @param flipNormals will also inverts the normals
  80437. * @returns current mesh
  80438. */
  80439. flipFaces(flipNormals?: boolean): Mesh;
  80440. /**
  80441. * Increase the number of facets and hence vertices in a mesh
  80442. * Vertex normals are interpolated from existing vertex normals
  80443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80444. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80445. */
  80446. increaseVertices(numberPerEdge: number): void;
  80447. /**
  80448. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80449. * This will undo any application of covertToFlatShadedMesh
  80450. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80451. */
  80452. forceSharedVertices(): void;
  80453. /** @hidden */
  80454. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80455. /** @hidden */
  80456. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80457. /**
  80458. * Creates a new InstancedMesh object from the mesh model.
  80459. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80460. * @param name defines the name of the new instance
  80461. * @returns a new InstancedMesh
  80462. */
  80463. createInstance(name: string): InstancedMesh;
  80464. /**
  80465. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80466. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80467. * @returns the current mesh
  80468. */
  80469. synchronizeInstances(): Mesh;
  80470. /**
  80471. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80472. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80473. * This should be used together with the simplification to avoid disappearing triangles.
  80474. * @param successCallback an optional success callback to be called after the optimization finished.
  80475. * @returns the current mesh
  80476. */
  80477. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80478. /**
  80479. * Serialize current mesh
  80480. * @param serializationObject defines the object which will receive the serialization data
  80481. */
  80482. serialize(serializationObject: any): void;
  80483. /** @hidden */
  80484. _syncGeometryWithMorphTargetManager(): void;
  80485. /** @hidden */
  80486. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80487. /**
  80488. * Returns a new Mesh object parsed from the source provided.
  80489. * @param parsedMesh is the source
  80490. * @param scene defines the hosting scene
  80491. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80492. * @returns a new Mesh
  80493. */
  80494. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80495. /**
  80496. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80497. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80498. * @param name defines the name of the mesh to create
  80499. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80500. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80501. * @param closePath creates a seam between the first and the last points of each path of the path array
  80502. * @param offset is taken in account only if the `pathArray` is containing a single path
  80503. * @param scene defines the hosting scene
  80504. * @param updatable defines if the mesh must be flagged as updatable
  80505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80506. * @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)
  80507. * @returns a new Mesh
  80508. */
  80509. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80510. /**
  80511. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80512. * @param name defines the name of the mesh to create
  80513. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80514. * @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
  80515. * @param scene defines the hosting scene
  80516. * @param updatable defines if the mesh must be flagged as updatable
  80517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80518. * @returns a new Mesh
  80519. */
  80520. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80521. /**
  80522. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80523. * @param name defines the name of the mesh to create
  80524. * @param size sets the size (float) of each box side (default 1)
  80525. * @param scene defines the hosting scene
  80526. * @param updatable defines if the mesh must be flagged as updatable
  80527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80528. * @returns a new Mesh
  80529. */
  80530. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80531. /**
  80532. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80533. * @param name defines the name of the mesh to create
  80534. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80535. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80536. * @param scene defines the hosting scene
  80537. * @param updatable defines if the mesh must be flagged as updatable
  80538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80539. * @returns a new Mesh
  80540. */
  80541. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80542. /**
  80543. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80544. * @param name defines the name of the mesh to create
  80545. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80546. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80547. * @param scene defines the hosting scene
  80548. * @returns a new Mesh
  80549. */
  80550. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80551. /**
  80552. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80553. * @param name defines the name of the mesh to create
  80554. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80555. * @param diameterTop set the top cap diameter (floats, default 1)
  80556. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80557. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80558. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80559. * @param scene defines the hosting scene
  80560. * @param updatable defines if the mesh must be flagged as updatable
  80561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80562. * @returns a new Mesh
  80563. */
  80564. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80565. /**
  80566. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80567. * @param name defines the name of the mesh to create
  80568. * @param diameter sets the diameter size (float) of the torus (default 1)
  80569. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80570. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80571. * @param scene defines the hosting scene
  80572. * @param updatable defines if the mesh must be flagged as updatable
  80573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80574. * @returns a new Mesh
  80575. */
  80576. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80577. /**
  80578. * Creates a torus knot mesh. 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 global radius size (float) of the torus knot (default 2)
  80581. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80582. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80583. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80584. * @param p the number of windings on X axis (positive integers, default 2)
  80585. * @param q the number of windings on Y axis (positive integers, default 3)
  80586. * @param scene defines the hosting scene
  80587. * @param updatable defines if the mesh must be flagged as updatable
  80588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80589. * @returns a new Mesh
  80590. */
  80591. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80592. /**
  80593. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80594. * @param name defines the name of the mesh to create
  80595. * @param points is an array successive Vector3
  80596. * @param scene defines the hosting scene
  80597. * @param updatable defines if the mesh must be flagged as updatable
  80598. * @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).
  80599. * @returns a new Mesh
  80600. */
  80601. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80602. /**
  80603. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80604. * @param name defines the name of the mesh to create
  80605. * @param points is an array successive Vector3
  80606. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80607. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80608. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80609. * @param scene defines the hosting scene
  80610. * @param updatable defines if the mesh must be flagged as updatable
  80611. * @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)
  80612. * @returns a new Mesh
  80613. */
  80614. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80615. /**
  80616. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80617. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80618. * 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.
  80619. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80620. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80621. * Remember you can only change the shape positions, not their number when updating a polygon.
  80622. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80623. * @param name defines the name of the mesh to create
  80624. * @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
  80625. * @param scene defines the hosting scene
  80626. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  80630. * @returns a new Mesh
  80631. */
  80632. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80633. /**
  80634. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80635. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80636. * @param name defines the name of the mesh to create
  80637. * @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
  80638. * @param depth defines the height of extrusion
  80639. * @param scene defines the hosting scene
  80640. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80641. * @param updatable defines if the mesh must be flagged as updatable
  80642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80643. * @param earcutInjection can be used to inject your own earcut reference
  80644. * @returns a new Mesh
  80645. */
  80646. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80647. /**
  80648. * Creates an extruded shape mesh.
  80649. * 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
  80650. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80652. * @param name defines the name of the mesh to create
  80653. * @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
  80654. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80655. * @param scale is the value to scale the shape
  80656. * @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
  80657. * @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
  80658. * @param scene defines the hosting scene
  80659. * @param updatable defines if the mesh must be flagged as updatable
  80660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80661. * @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)
  80662. * @returns a new Mesh
  80663. */
  80664. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80665. /**
  80666. * Creates an custom extruded shape mesh.
  80667. * The custom extrusion is a parametric shape.
  80668. * It has no predefined shape. Its final shape will depend on the input parameters.
  80669. * Please consider using the same method from the MeshBuilder class instead
  80670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80671. * @param name defines the name of the mesh to create
  80672. * @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
  80673. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80674. * @param scaleFunction is a custom Javascript function called on each path point
  80675. * @param rotationFunction is a custom Javascript function called on each path point
  80676. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80677. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80678. * @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
  80679. * @param scene defines the hosting scene
  80680. * @param updatable defines if the mesh must be flagged as updatable
  80681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80682. * @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)
  80683. * @returns a new Mesh
  80684. */
  80685. 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;
  80686. /**
  80687. * Creates lathe mesh.
  80688. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80689. * Please consider using the same method from the MeshBuilder class instead
  80690. * @param name defines the name of the mesh to create
  80691. * @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
  80692. * @param radius is the radius value of the lathe
  80693. * @param tessellation is the side number of the lathe.
  80694. * @param scene defines the hosting scene
  80695. * @param updatable defines if the mesh must be flagged as updatable
  80696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80697. * @returns a new Mesh
  80698. */
  80699. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80700. /**
  80701. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80702. * @param name defines the name of the mesh to create
  80703. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80704. * @param scene defines the hosting scene
  80705. * @param updatable defines if the mesh must be flagged as updatable
  80706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80707. * @returns a new Mesh
  80708. */
  80709. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80710. /**
  80711. * Creates a ground mesh.
  80712. * Please consider using the same method from the MeshBuilder class instead
  80713. * @param name defines the name of the mesh to create
  80714. * @param width set the width of the ground
  80715. * @param height set the height of the ground
  80716. * @param subdivisions sets the number of subdivisions per side
  80717. * @param scene defines the hosting scene
  80718. * @param updatable defines if the mesh must be flagged as updatable
  80719. * @returns a new Mesh
  80720. */
  80721. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80722. /**
  80723. * Creates a tiled ground mesh.
  80724. * Please consider using the same method from the MeshBuilder class instead
  80725. * @param name defines the name of the mesh to create
  80726. * @param xmin set the ground minimum X coordinate
  80727. * @param zmin set the ground minimum Y coordinate
  80728. * @param xmax set the ground maximum X coordinate
  80729. * @param zmax set the ground maximum Z coordinate
  80730. * @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
  80731. * @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
  80732. * @param scene defines the hosting scene
  80733. * @param updatable defines if the mesh must be flagged as updatable
  80734. * @returns a new Mesh
  80735. */
  80736. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80737. w: number;
  80738. h: number;
  80739. }, precision: {
  80740. w: number;
  80741. h: number;
  80742. }, scene: Scene, updatable?: boolean): Mesh;
  80743. /**
  80744. * Creates a ground mesh from a height map.
  80745. * Please consider using the same method from the MeshBuilder class instead
  80746. * @see http://doc.babylonjs.com/babylon101/height_map
  80747. * @param name defines the name of the mesh to create
  80748. * @param url sets the URL of the height map image resource
  80749. * @param width set the ground width size
  80750. * @param height set the ground height size
  80751. * @param subdivisions sets the number of subdivision per side
  80752. * @param minHeight is the minimum altitude on the ground
  80753. * @param maxHeight is the maximum altitude on the ground
  80754. * @param scene defines the hosting scene
  80755. * @param updatable defines if the mesh must be flagged as updatable
  80756. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80757. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80758. * @returns a new Mesh
  80759. */
  80760. 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;
  80761. /**
  80762. * Creates a tube mesh.
  80763. * The tube is a parametric shape.
  80764. * It has no predefined shape. Its final shape will depend on the input parameters.
  80765. * Please consider using the same method from the MeshBuilder class instead
  80766. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80767. * @param name defines the name of the mesh to create
  80768. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80769. * @param radius sets the tube radius size
  80770. * @param tessellation is the number of sides on the tubular surface
  80771. * @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
  80772. * @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
  80773. * @param scene defines the hosting scene
  80774. * @param updatable defines if the mesh must be flagged as updatable
  80775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80776. * @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)
  80777. * @returns a new Mesh
  80778. */
  80779. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80780. (i: number, distance: number): number;
  80781. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80782. /**
  80783. * Creates a polyhedron mesh.
  80784. * Please consider using the same method from the MeshBuilder class instead.
  80785. * * 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
  80786. * * The parameter `size` (positive float, default 1) sets the polygon size
  80787. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80788. * * 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`
  80789. * * 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
  80790. * * 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)`)
  80791. * * 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
  80792. * * 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
  80793. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80794. * * If you create a double-sided mesh, you can choose what parts of 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
  80795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80796. * @param name defines the name of the mesh to create
  80797. * @param options defines the options used to create the mesh
  80798. * @param scene defines the hosting scene
  80799. * @returns a new Mesh
  80800. */
  80801. static CreatePolyhedron(name: string, options: {
  80802. type?: number;
  80803. size?: number;
  80804. sizeX?: number;
  80805. sizeY?: number;
  80806. sizeZ?: number;
  80807. custom?: any;
  80808. faceUV?: Vector4[];
  80809. faceColors?: Color4[];
  80810. updatable?: boolean;
  80811. sideOrientation?: number;
  80812. }, scene: Scene): Mesh;
  80813. /**
  80814. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80815. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80816. * * 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`)
  80817. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80818. * * 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
  80819. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80820. * * If you create a double-sided mesh, you can choose what parts of 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
  80821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80822. * @param name defines the name of the mesh
  80823. * @param options defines the options used to create the mesh
  80824. * @param scene defines the hosting scene
  80825. * @returns a new Mesh
  80826. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80827. */
  80828. static CreateIcoSphere(name: string, options: {
  80829. radius?: number;
  80830. flat?: boolean;
  80831. subdivisions?: number;
  80832. sideOrientation?: number;
  80833. updatable?: boolean;
  80834. }, scene: Scene): Mesh;
  80835. /**
  80836. * Creates a decal mesh.
  80837. * Please consider using the same method from the MeshBuilder class instead.
  80838. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80839. * @param name defines the name of the mesh
  80840. * @param sourceMesh defines the mesh receiving the decal
  80841. * @param position sets the position of the decal in world coordinates
  80842. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80843. * @param size sets the decal scaling
  80844. * @param angle sets the angle to rotate the decal
  80845. * @returns a new Mesh
  80846. */
  80847. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80848. /**
  80849. * Prepare internal position array for software CPU skinning
  80850. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80851. */
  80852. setPositionsForCPUSkinning(): Float32Array;
  80853. /**
  80854. * Prepare internal normal array for software CPU skinning
  80855. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80856. */
  80857. setNormalsForCPUSkinning(): Float32Array;
  80858. /**
  80859. * Updates the vertex buffer by applying transformation from the bones
  80860. * @param skeleton defines the skeleton to apply to current mesh
  80861. * @returns the current mesh
  80862. */
  80863. applySkeleton(skeleton: Skeleton): Mesh;
  80864. /**
  80865. * 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
  80866. * @param meshes defines the list of meshes to scan
  80867. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80868. */
  80869. static MinMax(meshes: AbstractMesh[]): {
  80870. min: Vector3;
  80871. max: Vector3;
  80872. };
  80873. /**
  80874. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80875. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80876. * @returns a vector3
  80877. */
  80878. static Center(meshesOrMinMaxVector: {
  80879. min: Vector3;
  80880. max: Vector3;
  80881. } | AbstractMesh[]): Vector3;
  80882. /**
  80883. * Merge the array of meshes into a single mesh for performance reasons.
  80884. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80885. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80886. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80887. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80888. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80889. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80890. * @returns a new mesh
  80891. */
  80892. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80893. /** @hidden */
  80894. addInstance(instance: InstancedMesh): void;
  80895. /** @hidden */
  80896. removeInstance(instance: InstancedMesh): void;
  80897. }
  80898. }
  80899. declare module BABYLON {
  80900. /**
  80901. * Base class for the main features of a material in Babylon.js
  80902. */
  80903. export class Material implements IAnimatable {
  80904. /**
  80905. * Returns the triangle fill mode
  80906. */
  80907. static readonly TriangleFillMode: number;
  80908. /**
  80909. * Returns the wireframe mode
  80910. */
  80911. static readonly WireFrameFillMode: number;
  80912. /**
  80913. * Returns the point fill mode
  80914. */
  80915. static readonly PointFillMode: number;
  80916. /**
  80917. * Returns the point list draw mode
  80918. */
  80919. static readonly PointListDrawMode: number;
  80920. /**
  80921. * Returns the line list draw mode
  80922. */
  80923. static readonly LineListDrawMode: number;
  80924. /**
  80925. * Returns the line loop draw mode
  80926. */
  80927. static readonly LineLoopDrawMode: number;
  80928. /**
  80929. * Returns the line strip draw mode
  80930. */
  80931. static readonly LineStripDrawMode: number;
  80932. /**
  80933. * Returns the triangle strip draw mode
  80934. */
  80935. static readonly TriangleStripDrawMode: number;
  80936. /**
  80937. * Returns the triangle fan draw mode
  80938. */
  80939. static readonly TriangleFanDrawMode: number;
  80940. /**
  80941. * Stores the clock-wise side orientation
  80942. */
  80943. static readonly ClockWiseSideOrientation: number;
  80944. /**
  80945. * Stores the counter clock-wise side orientation
  80946. */
  80947. static readonly CounterClockWiseSideOrientation: number;
  80948. /**
  80949. * The dirty texture flag value
  80950. */
  80951. static readonly TextureDirtyFlag: number;
  80952. /**
  80953. * The dirty light flag value
  80954. */
  80955. static readonly LightDirtyFlag: number;
  80956. /**
  80957. * The dirty fresnel flag value
  80958. */
  80959. static readonly FresnelDirtyFlag: number;
  80960. /**
  80961. * The dirty attribute flag value
  80962. */
  80963. static readonly AttributesDirtyFlag: number;
  80964. /**
  80965. * The dirty misc flag value
  80966. */
  80967. static readonly MiscDirtyFlag: number;
  80968. /**
  80969. * The all dirty flag value
  80970. */
  80971. static readonly AllDirtyFlag: number;
  80972. /**
  80973. * The ID of the material
  80974. */
  80975. id: string;
  80976. /**
  80977. * Gets or sets the unique id of the material
  80978. */
  80979. uniqueId: number;
  80980. /**
  80981. * The name of the material
  80982. */
  80983. name: string;
  80984. /**
  80985. * Gets or sets user defined metadata
  80986. */
  80987. metadata: any;
  80988. /**
  80989. * For internal use only. Please do not use.
  80990. */
  80991. reservedDataStore: any;
  80992. /**
  80993. * Specifies if the ready state should be checked on each call
  80994. */
  80995. checkReadyOnEveryCall: boolean;
  80996. /**
  80997. * Specifies if the ready state should be checked once
  80998. */
  80999. checkReadyOnlyOnce: boolean;
  81000. /**
  81001. * The state of the material
  81002. */
  81003. state: string;
  81004. /**
  81005. * The alpha value of the material
  81006. */
  81007. protected _alpha: number;
  81008. /**
  81009. * List of inspectable custom properties (used by the Inspector)
  81010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81011. */
  81012. inspectableCustomProperties: IInspectable[];
  81013. /**
  81014. * Sets the alpha value of the material
  81015. */
  81016. /**
  81017. * Gets the alpha value of the material
  81018. */
  81019. alpha: number;
  81020. /**
  81021. * Specifies if back face culling is enabled
  81022. */
  81023. protected _backFaceCulling: boolean;
  81024. /**
  81025. * Sets the back-face culling state
  81026. */
  81027. /**
  81028. * Gets the back-face culling state
  81029. */
  81030. backFaceCulling: boolean;
  81031. /**
  81032. * Stores the value for side orientation
  81033. */
  81034. sideOrientation: number;
  81035. /**
  81036. * Callback triggered when the material is compiled
  81037. */
  81038. onCompiled: (effect: Effect) => void;
  81039. /**
  81040. * Callback triggered when an error occurs
  81041. */
  81042. onError: (effect: Effect, errors: string) => void;
  81043. /**
  81044. * Callback triggered to get the render target textures
  81045. */
  81046. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81047. /**
  81048. * Gets a boolean indicating that current material needs to register RTT
  81049. */
  81050. readonly hasRenderTargetTextures: boolean;
  81051. /**
  81052. * Specifies if the material should be serialized
  81053. */
  81054. doNotSerialize: boolean;
  81055. /**
  81056. * @hidden
  81057. */
  81058. _storeEffectOnSubMeshes: boolean;
  81059. /**
  81060. * Stores the animations for the material
  81061. */
  81062. animations: Array<Animation>;
  81063. /**
  81064. * An event triggered when the material is disposed
  81065. */
  81066. onDisposeObservable: Observable<Material>;
  81067. /**
  81068. * An observer which watches for dispose events
  81069. */
  81070. private _onDisposeObserver;
  81071. private _onUnBindObservable;
  81072. /**
  81073. * Called during a dispose event
  81074. */
  81075. onDispose: () => void;
  81076. private _onBindObservable;
  81077. /**
  81078. * An event triggered when the material is bound
  81079. */
  81080. readonly onBindObservable: Observable<AbstractMesh>;
  81081. /**
  81082. * An observer which watches for bind events
  81083. */
  81084. private _onBindObserver;
  81085. /**
  81086. * Called during a bind event
  81087. */
  81088. onBind: (Mesh: AbstractMesh) => void;
  81089. /**
  81090. * An event triggered when the material is unbound
  81091. */
  81092. readonly onUnBindObservable: Observable<Material>;
  81093. /**
  81094. * Stores the value of the alpha mode
  81095. */
  81096. private _alphaMode;
  81097. /**
  81098. * Sets the value of the alpha mode.
  81099. *
  81100. * | Value | Type | Description |
  81101. * | --- | --- | --- |
  81102. * | 0 | ALPHA_DISABLE | |
  81103. * | 1 | ALPHA_ADD | |
  81104. * | 2 | ALPHA_COMBINE | |
  81105. * | 3 | ALPHA_SUBTRACT | |
  81106. * | 4 | ALPHA_MULTIPLY | |
  81107. * | 5 | ALPHA_MAXIMIZED | |
  81108. * | 6 | ALPHA_ONEONE | |
  81109. * | 7 | ALPHA_PREMULTIPLIED | |
  81110. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81111. * | 9 | ALPHA_INTERPOLATE | |
  81112. * | 10 | ALPHA_SCREENMODE | |
  81113. *
  81114. */
  81115. /**
  81116. * Gets the value of the alpha mode
  81117. */
  81118. alphaMode: number;
  81119. /**
  81120. * Stores the state of the need depth pre-pass value
  81121. */
  81122. private _needDepthPrePass;
  81123. /**
  81124. * Sets the need depth pre-pass value
  81125. */
  81126. /**
  81127. * Gets the depth pre-pass value
  81128. */
  81129. needDepthPrePass: boolean;
  81130. /**
  81131. * Specifies if depth writing should be disabled
  81132. */
  81133. disableDepthWrite: boolean;
  81134. /**
  81135. * Specifies if depth writing should be forced
  81136. */
  81137. forceDepthWrite: boolean;
  81138. /**
  81139. * Specifies if there should be a separate pass for culling
  81140. */
  81141. separateCullingPass: boolean;
  81142. /**
  81143. * Stores the state specifing if fog should be enabled
  81144. */
  81145. private _fogEnabled;
  81146. /**
  81147. * Sets the state for enabling fog
  81148. */
  81149. /**
  81150. * Gets the value of the fog enabled state
  81151. */
  81152. fogEnabled: boolean;
  81153. /**
  81154. * Stores the size of points
  81155. */
  81156. pointSize: number;
  81157. /**
  81158. * Stores the z offset value
  81159. */
  81160. zOffset: number;
  81161. /**
  81162. * Gets a value specifying if wireframe mode is enabled
  81163. */
  81164. /**
  81165. * Sets the state of wireframe mode
  81166. */
  81167. wireframe: boolean;
  81168. /**
  81169. * Gets the value specifying if point clouds are enabled
  81170. */
  81171. /**
  81172. * Sets the state of point cloud mode
  81173. */
  81174. pointsCloud: boolean;
  81175. /**
  81176. * Gets the material fill mode
  81177. */
  81178. /**
  81179. * Sets the material fill mode
  81180. */
  81181. fillMode: number;
  81182. /**
  81183. * @hidden
  81184. * Stores the effects for the material
  81185. */
  81186. _effect: Nullable<Effect>;
  81187. /**
  81188. * @hidden
  81189. * Specifies if the material was previously ready
  81190. */
  81191. _wasPreviouslyReady: boolean;
  81192. /**
  81193. * Specifies if uniform buffers should be used
  81194. */
  81195. private _useUBO;
  81196. /**
  81197. * Stores a reference to the scene
  81198. */
  81199. private _scene;
  81200. /**
  81201. * Stores the fill mode state
  81202. */
  81203. private _fillMode;
  81204. /**
  81205. * Specifies if the depth write state should be cached
  81206. */
  81207. private _cachedDepthWriteState;
  81208. /**
  81209. * Stores the uniform buffer
  81210. */
  81211. protected _uniformBuffer: UniformBuffer;
  81212. /** @hidden */
  81213. _indexInSceneMaterialArray: number;
  81214. /** @hidden */
  81215. meshMap: Nullable<{
  81216. [id: string]: AbstractMesh | undefined;
  81217. }>;
  81218. /**
  81219. * Creates a material instance
  81220. * @param name defines the name of the material
  81221. * @param scene defines the scene to reference
  81222. * @param doNotAdd specifies if the material should be added to the scene
  81223. */
  81224. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81225. /**
  81226. * Returns a string representation of the current material
  81227. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81228. * @returns a string with material information
  81229. */
  81230. toString(fullDetails?: boolean): string;
  81231. /**
  81232. * Gets the class name of the material
  81233. * @returns a string with the class name of the material
  81234. */
  81235. getClassName(): string;
  81236. /**
  81237. * Specifies if updates for the material been locked
  81238. */
  81239. readonly isFrozen: boolean;
  81240. /**
  81241. * Locks updates for the material
  81242. */
  81243. freeze(): void;
  81244. /**
  81245. * Unlocks updates for the material
  81246. */
  81247. unfreeze(): void;
  81248. /**
  81249. * Specifies if the material is ready to be used
  81250. * @param mesh defines the mesh to check
  81251. * @param useInstances specifies if instances should be used
  81252. * @returns a boolean indicating if the material is ready to be used
  81253. */
  81254. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81255. /**
  81256. * Specifies that the submesh is ready to be used
  81257. * @param mesh defines the mesh to check
  81258. * @param subMesh defines which submesh to check
  81259. * @param useInstances specifies that instances should be used
  81260. * @returns a boolean indicating that the submesh is ready or not
  81261. */
  81262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81263. /**
  81264. * Returns the material effect
  81265. * @returns the effect associated with the material
  81266. */
  81267. getEffect(): Nullable<Effect>;
  81268. /**
  81269. * Returns the current scene
  81270. * @returns a Scene
  81271. */
  81272. getScene(): Scene;
  81273. /**
  81274. * Specifies if the material will require alpha blending
  81275. * @returns a boolean specifying if alpha blending is needed
  81276. */
  81277. needAlphaBlending(): boolean;
  81278. /**
  81279. * Specifies if the mesh will require alpha blending
  81280. * @param mesh defines the mesh to check
  81281. * @returns a boolean specifying if alpha blending is needed for the mesh
  81282. */
  81283. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81284. /**
  81285. * Specifies if this material should be rendered in alpha test mode
  81286. * @returns a boolean specifying if an alpha test is needed.
  81287. */
  81288. needAlphaTesting(): boolean;
  81289. /**
  81290. * Gets the texture used for the alpha test
  81291. * @returns the texture to use for alpha testing
  81292. */
  81293. getAlphaTestTexture(): Nullable<BaseTexture>;
  81294. /**
  81295. * Marks the material to indicate that it needs to be re-calculated
  81296. */
  81297. markDirty(): void;
  81298. /** @hidden */
  81299. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81300. /**
  81301. * Binds the material to the mesh
  81302. * @param world defines the world transformation matrix
  81303. * @param mesh defines the mesh to bind the material to
  81304. */
  81305. bind(world: Matrix, mesh?: Mesh): void;
  81306. /**
  81307. * Binds the submesh to the material
  81308. * @param world defines the world transformation matrix
  81309. * @param mesh defines the mesh containing the submesh
  81310. * @param subMesh defines the submesh to bind the material to
  81311. */
  81312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81313. /**
  81314. * Binds the world matrix to the material
  81315. * @param world defines the world transformation matrix
  81316. */
  81317. bindOnlyWorldMatrix(world: Matrix): void;
  81318. /**
  81319. * Binds the scene's uniform buffer to the effect.
  81320. * @param effect defines the effect to bind to the scene uniform buffer
  81321. * @param sceneUbo defines the uniform buffer storing scene data
  81322. */
  81323. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81324. /**
  81325. * Binds the view matrix to the effect
  81326. * @param effect defines the effect to bind the view matrix to
  81327. */
  81328. bindView(effect: Effect): void;
  81329. /**
  81330. * Binds the view projection matrix to the effect
  81331. * @param effect defines the effect to bind the view projection matrix to
  81332. */
  81333. bindViewProjection(effect: Effect): void;
  81334. /**
  81335. * Specifies if material alpha testing should be turned on for the mesh
  81336. * @param mesh defines the mesh to check
  81337. */
  81338. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81339. /**
  81340. * Processes to execute after binding the material to a mesh
  81341. * @param mesh defines the rendered mesh
  81342. */
  81343. protected _afterBind(mesh?: Mesh): void;
  81344. /**
  81345. * Unbinds the material from the mesh
  81346. */
  81347. unbind(): void;
  81348. /**
  81349. * Gets the active textures from the material
  81350. * @returns an array of textures
  81351. */
  81352. getActiveTextures(): BaseTexture[];
  81353. /**
  81354. * Specifies if the material uses a texture
  81355. * @param texture defines the texture to check against the material
  81356. * @returns a boolean specifying if the material uses the texture
  81357. */
  81358. hasTexture(texture: BaseTexture): boolean;
  81359. /**
  81360. * Makes a duplicate of the material, and gives it a new name
  81361. * @param name defines the new name for the duplicated material
  81362. * @returns the cloned material
  81363. */
  81364. clone(name: string): Nullable<Material>;
  81365. /**
  81366. * Gets the meshes bound to the material
  81367. * @returns an array of meshes bound to the material
  81368. */
  81369. getBindedMeshes(): AbstractMesh[];
  81370. /**
  81371. * Force shader compilation
  81372. * @param mesh defines the mesh associated with this material
  81373. * @param onCompiled defines a function to execute once the material is compiled
  81374. * @param options defines the options to configure the compilation
  81375. */
  81376. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81377. clipPlane: boolean;
  81378. }>): void;
  81379. /**
  81380. * Force shader compilation
  81381. * @param mesh defines the mesh that will use this material
  81382. * @param options defines additional options for compiling the shaders
  81383. * @returns a promise that resolves when the compilation completes
  81384. */
  81385. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81386. clipPlane: boolean;
  81387. }>): Promise<void>;
  81388. private static readonly _ImageProcessingDirtyCallBack;
  81389. private static readonly _TextureDirtyCallBack;
  81390. private static readonly _FresnelDirtyCallBack;
  81391. private static readonly _MiscDirtyCallBack;
  81392. private static readonly _LightsDirtyCallBack;
  81393. private static readonly _AttributeDirtyCallBack;
  81394. private static _FresnelAndMiscDirtyCallBack;
  81395. private static _TextureAndMiscDirtyCallBack;
  81396. private static readonly _DirtyCallbackArray;
  81397. private static readonly _RunDirtyCallBacks;
  81398. /**
  81399. * Marks a define in the material to indicate that it needs to be re-computed
  81400. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81401. */
  81402. markAsDirty(flag: number): void;
  81403. /**
  81404. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81405. * @param func defines a function which checks material defines against the submeshes
  81406. */
  81407. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81408. /**
  81409. * Indicates that image processing needs to be re-calculated for all submeshes
  81410. */
  81411. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81412. /**
  81413. * Indicates that textures need to be re-calculated for all submeshes
  81414. */
  81415. protected _markAllSubMeshesAsTexturesDirty(): void;
  81416. /**
  81417. * Indicates that fresnel needs to be re-calculated for all submeshes
  81418. */
  81419. protected _markAllSubMeshesAsFresnelDirty(): void;
  81420. /**
  81421. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81422. */
  81423. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81424. /**
  81425. * Indicates that lights need to be re-calculated for all submeshes
  81426. */
  81427. protected _markAllSubMeshesAsLightsDirty(): void;
  81428. /**
  81429. * Indicates that attributes need to be re-calculated for all submeshes
  81430. */
  81431. protected _markAllSubMeshesAsAttributesDirty(): void;
  81432. /**
  81433. * Indicates that misc needs to be re-calculated for all submeshes
  81434. */
  81435. protected _markAllSubMeshesAsMiscDirty(): void;
  81436. /**
  81437. * Indicates that textures and misc need to be re-calculated for all submeshes
  81438. */
  81439. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81440. /**
  81441. * Disposes the material
  81442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81445. */
  81446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81447. /** @hidden */
  81448. private releaseVertexArrayObject;
  81449. /**
  81450. * Serializes this material
  81451. * @returns the serialized material object
  81452. */
  81453. serialize(): any;
  81454. /**
  81455. * Creates a material from parsed material data
  81456. * @param parsedMaterial defines parsed material data
  81457. * @param scene defines the hosting scene
  81458. * @param rootUrl defines the root URL to use to load textures
  81459. * @returns a new material
  81460. */
  81461. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81462. }
  81463. }
  81464. declare module BABYLON {
  81465. /**
  81466. * Base class for submeshes
  81467. */
  81468. export class BaseSubMesh {
  81469. /** @hidden */
  81470. _materialDefines: Nullable<MaterialDefines>;
  81471. /** @hidden */
  81472. _materialEffect: Nullable<Effect>;
  81473. /**
  81474. * Gets associated effect
  81475. */
  81476. readonly effect: Nullable<Effect>;
  81477. /**
  81478. * Sets associated effect (effect used to render this submesh)
  81479. * @param effect defines the effect to associate with
  81480. * @param defines defines the set of defines used to compile this effect
  81481. */
  81482. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81483. }
  81484. /**
  81485. * Defines a subdivision inside a mesh
  81486. */
  81487. export class SubMesh extends BaseSubMesh implements ICullable {
  81488. /** the material index to use */
  81489. materialIndex: number;
  81490. /** vertex index start */
  81491. verticesStart: number;
  81492. /** vertices count */
  81493. verticesCount: number;
  81494. /** index start */
  81495. indexStart: number;
  81496. /** indices count */
  81497. indexCount: number;
  81498. /** @hidden */
  81499. _linesIndexCount: number;
  81500. private _mesh;
  81501. private _renderingMesh;
  81502. private _boundingInfo;
  81503. private _linesIndexBuffer;
  81504. /** @hidden */
  81505. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81506. /** @hidden */
  81507. _trianglePlanes: Plane[];
  81508. /** @hidden */
  81509. _lastColliderTransformMatrix: Matrix;
  81510. /** @hidden */
  81511. _renderId: number;
  81512. /** @hidden */
  81513. _alphaIndex: number;
  81514. /** @hidden */
  81515. _distanceToCamera: number;
  81516. /** @hidden */
  81517. _id: number;
  81518. private _currentMaterial;
  81519. /**
  81520. * Add a new submesh to a mesh
  81521. * @param materialIndex defines the material index to use
  81522. * @param verticesStart defines vertex index start
  81523. * @param verticesCount defines vertices count
  81524. * @param indexStart defines index start
  81525. * @param indexCount defines indices count
  81526. * @param mesh defines the parent mesh
  81527. * @param renderingMesh defines an optional rendering mesh
  81528. * @param createBoundingBox defines if bounding box should be created for this submesh
  81529. * @returns the new submesh
  81530. */
  81531. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81532. /**
  81533. * Creates a new submesh
  81534. * @param materialIndex defines the material index to use
  81535. * @param verticesStart defines vertex index start
  81536. * @param verticesCount defines vertices count
  81537. * @param indexStart defines index start
  81538. * @param indexCount defines indices count
  81539. * @param mesh defines the parent mesh
  81540. * @param renderingMesh defines an optional rendering mesh
  81541. * @param createBoundingBox defines if bounding box should be created for this submesh
  81542. */
  81543. constructor(
  81544. /** the material index to use */
  81545. materialIndex: number,
  81546. /** vertex index start */
  81547. verticesStart: number,
  81548. /** vertices count */
  81549. verticesCount: number,
  81550. /** index start */
  81551. indexStart: number,
  81552. /** indices count */
  81553. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81554. /**
  81555. * Returns true if this submesh covers the entire parent mesh
  81556. * @ignorenaming
  81557. */
  81558. readonly IsGlobal: boolean;
  81559. /**
  81560. * Returns the submesh BoudingInfo object
  81561. * @returns current bounding info (or mesh's one if the submesh is global)
  81562. */
  81563. getBoundingInfo(): BoundingInfo;
  81564. /**
  81565. * Sets the submesh BoundingInfo
  81566. * @param boundingInfo defines the new bounding info to use
  81567. * @returns the SubMesh
  81568. */
  81569. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81570. /**
  81571. * Returns the mesh of the current submesh
  81572. * @return the parent mesh
  81573. */
  81574. getMesh(): AbstractMesh;
  81575. /**
  81576. * Returns the rendering mesh of the submesh
  81577. * @returns the rendering mesh (could be different from parent mesh)
  81578. */
  81579. getRenderingMesh(): Mesh;
  81580. /**
  81581. * Returns the submesh material
  81582. * @returns null or the current material
  81583. */
  81584. getMaterial(): Nullable<Material>;
  81585. /**
  81586. * Sets a new updated BoundingInfo object to the submesh
  81587. * @returns the SubMesh
  81588. */
  81589. refreshBoundingInfo(): SubMesh;
  81590. /** @hidden */
  81591. _checkCollision(collider: Collider): boolean;
  81592. /**
  81593. * Updates the submesh BoundingInfo
  81594. * @param world defines the world matrix to use to update the bounding info
  81595. * @returns the submesh
  81596. */
  81597. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81598. /**
  81599. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81600. * @param frustumPlanes defines the frustum planes
  81601. * @returns true if the submesh is intersecting with the frustum
  81602. */
  81603. isInFrustum(frustumPlanes: Plane[]): boolean;
  81604. /**
  81605. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81606. * @param frustumPlanes defines the frustum planes
  81607. * @returns true if the submesh is inside the frustum
  81608. */
  81609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81610. /**
  81611. * Renders the submesh
  81612. * @param enableAlphaMode defines if alpha needs to be used
  81613. * @returns the submesh
  81614. */
  81615. render(enableAlphaMode: boolean): SubMesh;
  81616. /**
  81617. * @hidden
  81618. */
  81619. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81620. /**
  81621. * Checks if the submesh intersects with a ray
  81622. * @param ray defines the ray to test
  81623. * @returns true is the passed ray intersects the submesh bounding box
  81624. */
  81625. canIntersects(ray: Ray): boolean;
  81626. /**
  81627. * Intersects current submesh with a ray
  81628. * @param ray defines the ray to test
  81629. * @param positions defines mesh's positions array
  81630. * @param indices defines mesh's indices array
  81631. * @param fastCheck defines if only bounding info should be used
  81632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81633. * @returns intersection info or null if no intersection
  81634. */
  81635. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81636. /** @hidden */
  81637. private _intersectLines;
  81638. /** @hidden */
  81639. private _intersectTriangles;
  81640. /** @hidden */
  81641. _rebuild(): void;
  81642. /**
  81643. * Creates a new submesh from the passed mesh
  81644. * @param newMesh defines the new hosting mesh
  81645. * @param newRenderingMesh defines an optional rendering mesh
  81646. * @returns the new submesh
  81647. */
  81648. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81649. /**
  81650. * Release associated resources
  81651. */
  81652. dispose(): void;
  81653. /**
  81654. * Gets the class name
  81655. * @returns the string "SubMesh".
  81656. */
  81657. getClassName(): string;
  81658. /**
  81659. * Creates a new submesh from indices data
  81660. * @param materialIndex the index of the main mesh material
  81661. * @param startIndex the index where to start the copy in the mesh indices array
  81662. * @param indexCount the number of indices to copy then from the startIndex
  81663. * @param mesh the main mesh to create the submesh from
  81664. * @param renderingMesh the optional rendering mesh
  81665. * @returns a new submesh
  81666. */
  81667. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81668. }
  81669. }
  81670. declare module BABYLON {
  81671. /**
  81672. * Class used to store geometry data (vertex buffers + index buffer)
  81673. */
  81674. export class Geometry implements IGetSetVerticesData {
  81675. /**
  81676. * Gets or sets the ID of the geometry
  81677. */
  81678. id: string;
  81679. /**
  81680. * Gets or sets the unique ID of the geometry
  81681. */
  81682. uniqueId: number;
  81683. /**
  81684. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81685. */
  81686. delayLoadState: number;
  81687. /**
  81688. * Gets the file containing the data to load when running in delay load state
  81689. */
  81690. delayLoadingFile: Nullable<string>;
  81691. /**
  81692. * Callback called when the geometry is updated
  81693. */
  81694. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81695. private _scene;
  81696. private _engine;
  81697. private _meshes;
  81698. private _totalVertices;
  81699. /** @hidden */
  81700. _indices: IndicesArray;
  81701. /** @hidden */
  81702. _vertexBuffers: {
  81703. [key: string]: VertexBuffer;
  81704. };
  81705. private _isDisposed;
  81706. private _extend;
  81707. private _boundingBias;
  81708. /** @hidden */
  81709. _delayInfo: Array<string>;
  81710. private _indexBuffer;
  81711. private _indexBufferIsUpdatable;
  81712. /** @hidden */
  81713. _boundingInfo: Nullable<BoundingInfo>;
  81714. /** @hidden */
  81715. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81716. /** @hidden */
  81717. _softwareSkinningFrameId: number;
  81718. private _vertexArrayObjects;
  81719. private _updatable;
  81720. /** @hidden */
  81721. _positions: Nullable<Vector3[]>;
  81722. /**
  81723. * 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
  81724. */
  81725. /**
  81726. * 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
  81727. */
  81728. boundingBias: Vector2;
  81729. /**
  81730. * Static function used to attach a new empty geometry to a mesh
  81731. * @param mesh defines the mesh to attach the geometry to
  81732. * @returns the new Geometry
  81733. */
  81734. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81735. /**
  81736. * Creates a new geometry
  81737. * @param id defines the unique ID
  81738. * @param scene defines the hosting scene
  81739. * @param vertexData defines the VertexData used to get geometry data
  81740. * @param updatable defines if geometry must be updatable (false by default)
  81741. * @param mesh defines the mesh that will be associated with the geometry
  81742. */
  81743. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81744. /**
  81745. * Gets the current extend of the geometry
  81746. */
  81747. readonly extend: {
  81748. minimum: Vector3;
  81749. maximum: Vector3;
  81750. };
  81751. /**
  81752. * Gets the hosting scene
  81753. * @returns the hosting Scene
  81754. */
  81755. getScene(): Scene;
  81756. /**
  81757. * Gets the hosting engine
  81758. * @returns the hosting Engine
  81759. */
  81760. getEngine(): Engine;
  81761. /**
  81762. * Defines if the geometry is ready to use
  81763. * @returns true if the geometry is ready to be used
  81764. */
  81765. isReady(): boolean;
  81766. /**
  81767. * Gets a value indicating that the geometry should not be serialized
  81768. */
  81769. readonly doNotSerialize: boolean;
  81770. /** @hidden */
  81771. _rebuild(): void;
  81772. /**
  81773. * Affects all geometry data in one call
  81774. * @param vertexData defines the geometry data
  81775. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81776. */
  81777. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81778. /**
  81779. * Set specific vertex data
  81780. * @param kind defines the data kind (Position, normal, etc...)
  81781. * @param data defines the vertex data to use
  81782. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81783. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81784. */
  81785. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81786. /**
  81787. * Removes a specific vertex data
  81788. * @param kind defines the data kind (Position, normal, etc...)
  81789. */
  81790. removeVerticesData(kind: string): void;
  81791. /**
  81792. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81793. * @param buffer defines the vertex buffer to use
  81794. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81795. */
  81796. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81797. /**
  81798. * Update a specific vertex buffer
  81799. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81800. * It will do nothing if the buffer is not updatable
  81801. * @param kind defines the data kind (Position, normal, etc...)
  81802. * @param data defines the data to use
  81803. * @param offset defines the offset in the target buffer where to store the data
  81804. * @param useBytes set to true if the offset is in bytes
  81805. */
  81806. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81807. /**
  81808. * Update a specific vertex buffer
  81809. * This function will create a new buffer if the current one is not updatable
  81810. * @param kind defines the data kind (Position, normal, etc...)
  81811. * @param data defines the data to use
  81812. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81813. */
  81814. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81815. private _updateBoundingInfo;
  81816. /** @hidden */
  81817. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81818. /**
  81819. * Gets total number of vertices
  81820. * @returns the total number of vertices
  81821. */
  81822. getTotalVertices(): number;
  81823. /**
  81824. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81825. * @param kind defines the data kind (Position, normal, etc...)
  81826. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81827. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81828. * @returns a float array containing vertex data
  81829. */
  81830. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81831. /**
  81832. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81833. * @param kind defines the data kind (Position, normal, etc...)
  81834. * @returns true if the vertex buffer with the specified kind is updatable
  81835. */
  81836. isVertexBufferUpdatable(kind: string): boolean;
  81837. /**
  81838. * Gets a specific vertex buffer
  81839. * @param kind defines the data kind (Position, normal, etc...)
  81840. * @returns a VertexBuffer
  81841. */
  81842. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81843. /**
  81844. * Returns all vertex buffers
  81845. * @return an object holding all vertex buffers indexed by kind
  81846. */
  81847. getVertexBuffers(): Nullable<{
  81848. [key: string]: VertexBuffer;
  81849. }>;
  81850. /**
  81851. * Gets a boolean indicating if specific vertex buffer is present
  81852. * @param kind defines the data kind (Position, normal, etc...)
  81853. * @returns true if data is present
  81854. */
  81855. isVerticesDataPresent(kind: string): boolean;
  81856. /**
  81857. * Gets a list of all attached data kinds (Position, normal, etc...)
  81858. * @returns a list of string containing all kinds
  81859. */
  81860. getVerticesDataKinds(): string[];
  81861. /**
  81862. * Update index buffer
  81863. * @param indices defines the indices to store in the index buffer
  81864. * @param offset defines the offset in the target buffer where to store the data
  81865. * @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)
  81866. */
  81867. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81868. /**
  81869. * Creates a new index buffer
  81870. * @param indices defines the indices to store in the index buffer
  81871. * @param totalVertices defines the total number of vertices (could be null)
  81872. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81873. */
  81874. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81875. /**
  81876. * Return the total number of indices
  81877. * @returns the total number of indices
  81878. */
  81879. getTotalIndices(): number;
  81880. /**
  81881. * Gets the index buffer array
  81882. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81883. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81884. * @returns the index buffer array
  81885. */
  81886. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81887. /**
  81888. * Gets the index buffer
  81889. * @return the index buffer
  81890. */
  81891. getIndexBuffer(): Nullable<WebGLBuffer>;
  81892. /** @hidden */
  81893. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81894. /**
  81895. * Release the associated resources for a specific mesh
  81896. * @param mesh defines the source mesh
  81897. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81898. */
  81899. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81900. /**
  81901. * Apply current geometry to a given mesh
  81902. * @param mesh defines the mesh to apply geometry to
  81903. */
  81904. applyToMesh(mesh: Mesh): void;
  81905. private _updateExtend;
  81906. private _applyToMesh;
  81907. private notifyUpdate;
  81908. /**
  81909. * Load the geometry if it was flagged as delay loaded
  81910. * @param scene defines the hosting scene
  81911. * @param onLoaded defines a callback called when the geometry is loaded
  81912. */
  81913. load(scene: Scene, onLoaded?: () => void): void;
  81914. private _queueLoad;
  81915. /**
  81916. * Invert the geometry to move from a right handed system to a left handed one.
  81917. */
  81918. toLeftHanded(): void;
  81919. /** @hidden */
  81920. _resetPointsArrayCache(): void;
  81921. /** @hidden */
  81922. _generatePointsArray(): boolean;
  81923. /**
  81924. * Gets a value indicating if the geometry is disposed
  81925. * @returns true if the geometry was disposed
  81926. */
  81927. isDisposed(): boolean;
  81928. private _disposeVertexArrayObjects;
  81929. /**
  81930. * Free all associated resources
  81931. */
  81932. dispose(): void;
  81933. /**
  81934. * Clone the current geometry into a new geometry
  81935. * @param id defines the unique ID of the new geometry
  81936. * @returns a new geometry object
  81937. */
  81938. copy(id: string): Geometry;
  81939. /**
  81940. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81941. * @return a JSON representation of the current geometry data (without the vertices data)
  81942. */
  81943. serialize(): any;
  81944. private toNumberArray;
  81945. /**
  81946. * Serialize all vertices data into a JSON oject
  81947. * @returns a JSON representation of the current geometry data
  81948. */
  81949. serializeVerticeData(): any;
  81950. /**
  81951. * Extracts a clone of a mesh geometry
  81952. * @param mesh defines the source mesh
  81953. * @param id defines the unique ID of the new geometry object
  81954. * @returns the new geometry object
  81955. */
  81956. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81957. /**
  81958. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81959. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81960. * Be aware Math.random() could cause collisions, but:
  81961. * "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"
  81962. * @returns a string containing a new GUID
  81963. */
  81964. static RandomId(): string;
  81965. /** @hidden */
  81966. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81967. private static _CleanMatricesWeights;
  81968. /**
  81969. * Create a new geometry from persisted data (Using .babylon file format)
  81970. * @param parsedVertexData defines the persisted data
  81971. * @param scene defines the hosting scene
  81972. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81973. * @returns the new geometry object
  81974. */
  81975. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81976. }
  81977. }
  81978. declare module BABYLON {
  81979. /**
  81980. * Define an interface for all classes that will get and set the data on vertices
  81981. */
  81982. export interface IGetSetVerticesData {
  81983. /**
  81984. * Gets a boolean indicating if specific vertex data is present
  81985. * @param kind defines the vertex data kind to use
  81986. * @returns true is data kind is present
  81987. */
  81988. isVerticesDataPresent(kind: string): boolean;
  81989. /**
  81990. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81991. * @param kind defines the data kind (Position, normal, etc...)
  81992. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81993. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81994. * @returns a float array containing vertex data
  81995. */
  81996. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81997. /**
  81998. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81999. * @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.
  82000. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82001. * @returns the indices array or an empty array if the mesh has no geometry
  82002. */
  82003. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82004. /**
  82005. * Set specific vertex data
  82006. * @param kind defines the data kind (Position, normal, etc...)
  82007. * @param data defines the vertex data to use
  82008. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82009. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82010. */
  82011. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82012. /**
  82013. * Update a specific associated vertex buffer
  82014. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82015. * - VertexBuffer.PositionKind
  82016. * - VertexBuffer.UVKind
  82017. * - VertexBuffer.UV2Kind
  82018. * - VertexBuffer.UV3Kind
  82019. * - VertexBuffer.UV4Kind
  82020. * - VertexBuffer.UV5Kind
  82021. * - VertexBuffer.UV6Kind
  82022. * - VertexBuffer.ColorKind
  82023. * - VertexBuffer.MatricesIndicesKind
  82024. * - VertexBuffer.MatricesIndicesExtraKind
  82025. * - VertexBuffer.MatricesWeightsKind
  82026. * - VertexBuffer.MatricesWeightsExtraKind
  82027. * @param data defines the data source
  82028. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82029. * @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)
  82030. */
  82031. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82032. /**
  82033. * Creates a new index buffer
  82034. * @param indices defines the indices to store in the index buffer
  82035. * @param totalVertices defines the total number of vertices (could be null)
  82036. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82037. */
  82038. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82039. }
  82040. /**
  82041. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82042. */
  82043. export class VertexData {
  82044. /**
  82045. * Mesh side orientation : usually the external or front surface
  82046. */
  82047. static readonly FRONTSIDE: number;
  82048. /**
  82049. * Mesh side orientation : usually the internal or back surface
  82050. */
  82051. static readonly BACKSIDE: number;
  82052. /**
  82053. * Mesh side orientation : both internal and external or front and back surfaces
  82054. */
  82055. static readonly DOUBLESIDE: number;
  82056. /**
  82057. * Mesh side orientation : by default, `FRONTSIDE`
  82058. */
  82059. static readonly DEFAULTSIDE: number;
  82060. /**
  82061. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82062. */
  82063. positions: Nullable<FloatArray>;
  82064. /**
  82065. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82066. */
  82067. normals: Nullable<FloatArray>;
  82068. /**
  82069. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82070. */
  82071. tangents: Nullable<FloatArray>;
  82072. /**
  82073. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82074. */
  82075. uvs: Nullable<FloatArray>;
  82076. /**
  82077. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82078. */
  82079. uvs2: Nullable<FloatArray>;
  82080. /**
  82081. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82082. */
  82083. uvs3: Nullable<FloatArray>;
  82084. /**
  82085. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82086. */
  82087. uvs4: Nullable<FloatArray>;
  82088. /**
  82089. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82090. */
  82091. uvs5: Nullable<FloatArray>;
  82092. /**
  82093. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82094. */
  82095. uvs6: Nullable<FloatArray>;
  82096. /**
  82097. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82098. */
  82099. colors: Nullable<FloatArray>;
  82100. /**
  82101. * 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).
  82102. */
  82103. matricesIndices: Nullable<FloatArray>;
  82104. /**
  82105. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82106. */
  82107. matricesWeights: Nullable<FloatArray>;
  82108. /**
  82109. * An array extending the number of possible indices
  82110. */
  82111. matricesIndicesExtra: Nullable<FloatArray>;
  82112. /**
  82113. * An array extending the number of possible weights when the number of indices is extended
  82114. */
  82115. matricesWeightsExtra: Nullable<FloatArray>;
  82116. /**
  82117. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82118. */
  82119. indices: Nullable<IndicesArray>;
  82120. /**
  82121. * Uses the passed data array to set the set the values for the specified kind of data
  82122. * @param data a linear array of floating numbers
  82123. * @param kind the type of data that is being set, eg positions, colors etc
  82124. */
  82125. set(data: FloatArray, kind: string): void;
  82126. /**
  82127. * Associates the vertexData to the passed Mesh.
  82128. * Sets it as updatable or not (default `false`)
  82129. * @param mesh the mesh the vertexData is applied to
  82130. * @param updatable when used and having the value true allows new data to update the vertexData
  82131. * @returns the VertexData
  82132. */
  82133. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82134. /**
  82135. * Associates the vertexData to the passed Geometry.
  82136. * Sets it as updatable or not (default `false`)
  82137. * @param geometry the geometry the vertexData is applied to
  82138. * @param updatable when used and having the value true allows new data to update the vertexData
  82139. * @returns VertexData
  82140. */
  82141. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82142. /**
  82143. * Updates the associated mesh
  82144. * @param mesh the mesh to be updated
  82145. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82146. * @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
  82147. * @returns VertexData
  82148. */
  82149. updateMesh(mesh: Mesh): VertexData;
  82150. /**
  82151. * Updates the associated geometry
  82152. * @param geometry the geometry to be updated
  82153. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82154. * @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
  82155. * @returns VertexData.
  82156. */
  82157. updateGeometry(geometry: Geometry): VertexData;
  82158. private _applyTo;
  82159. private _update;
  82160. /**
  82161. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82162. * @param matrix the transforming matrix
  82163. * @returns the VertexData
  82164. */
  82165. transform(matrix: Matrix): VertexData;
  82166. /**
  82167. * Merges the passed VertexData into the current one
  82168. * @param other the VertexData to be merged into the current one
  82169. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82170. * @returns the modified VertexData
  82171. */
  82172. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82173. private _mergeElement;
  82174. private _validate;
  82175. /**
  82176. * Serializes the VertexData
  82177. * @returns a serialized object
  82178. */
  82179. serialize(): any;
  82180. /**
  82181. * Extracts the vertexData from a mesh
  82182. * @param mesh the mesh from which to extract the VertexData
  82183. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82184. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82185. * @returns the object VertexData associated to the passed mesh
  82186. */
  82187. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82188. /**
  82189. * Extracts the vertexData from the geometry
  82190. * @param geometry the geometry from which to extract the VertexData
  82191. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82192. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82193. * @returns the object VertexData associated to the passed mesh
  82194. */
  82195. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82196. private static _ExtractFrom;
  82197. /**
  82198. * Creates the VertexData for a Ribbon
  82199. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82200. * * pathArray array of paths, each of which an array of successive Vector3
  82201. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82202. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82203. * * 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
  82204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82205. * * 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)
  82206. * * 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)
  82207. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82208. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82209. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82210. * @returns the VertexData of the ribbon
  82211. */
  82212. static CreateRibbon(options: {
  82213. pathArray: Vector3[][];
  82214. closeArray?: boolean;
  82215. closePath?: boolean;
  82216. offset?: number;
  82217. sideOrientation?: number;
  82218. frontUVs?: Vector4;
  82219. backUVs?: Vector4;
  82220. invertUV?: boolean;
  82221. uvs?: Vector2[];
  82222. colors?: Color4[];
  82223. }): VertexData;
  82224. /**
  82225. * Creates the VertexData for a box
  82226. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82227. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82228. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82229. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82230. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82231. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82232. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82234. * * 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)
  82235. * * 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)
  82236. * @returns the VertexData of the box
  82237. */
  82238. static CreateBox(options: {
  82239. size?: number;
  82240. width?: number;
  82241. height?: number;
  82242. depth?: number;
  82243. faceUV?: Vector4[];
  82244. faceColors?: Color4[];
  82245. sideOrientation?: number;
  82246. frontUVs?: Vector4;
  82247. backUVs?: Vector4;
  82248. }): VertexData;
  82249. /**
  82250. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82251. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82252. * * segments sets the number of horizontal strips optional, default 32
  82253. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82254. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82255. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82256. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82257. * * 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
  82258. * * 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
  82259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82260. * * 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)
  82261. * * 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)
  82262. * @returns the VertexData of the ellipsoid
  82263. */
  82264. static CreateSphere(options: {
  82265. segments?: number;
  82266. diameter?: number;
  82267. diameterX?: number;
  82268. diameterY?: number;
  82269. diameterZ?: number;
  82270. arc?: number;
  82271. slice?: number;
  82272. sideOrientation?: number;
  82273. frontUVs?: Vector4;
  82274. backUVs?: Vector4;
  82275. }): VertexData;
  82276. /**
  82277. * Creates the VertexData for a cylinder, cone or prism
  82278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82279. * * height sets the height (y direction) of the cylinder, optional, default 2
  82280. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82281. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82282. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82283. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82284. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82285. * * 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
  82286. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82287. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82288. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82289. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82291. * * 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)
  82292. * * 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)
  82293. * @returns the VertexData of the cylinder, cone or prism
  82294. */
  82295. static CreateCylinder(options: {
  82296. height?: number;
  82297. diameterTop?: number;
  82298. diameterBottom?: number;
  82299. diameter?: number;
  82300. tessellation?: number;
  82301. subdivisions?: number;
  82302. arc?: number;
  82303. faceColors?: Color4[];
  82304. faceUV?: Vector4[];
  82305. hasRings?: boolean;
  82306. enclose?: boolean;
  82307. sideOrientation?: number;
  82308. frontUVs?: Vector4;
  82309. backUVs?: Vector4;
  82310. }): VertexData;
  82311. /**
  82312. * Creates the VertexData for a torus
  82313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82314. * * diameter the diameter of the torus, optional default 1
  82315. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82316. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82318. * * 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)
  82319. * * 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)
  82320. * @returns the VertexData of the torus
  82321. */
  82322. static CreateTorus(options: {
  82323. diameter?: number;
  82324. thickness?: number;
  82325. tessellation?: number;
  82326. sideOrientation?: number;
  82327. frontUVs?: Vector4;
  82328. backUVs?: Vector4;
  82329. }): VertexData;
  82330. /**
  82331. * Creates the VertexData of the LineSystem
  82332. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82333. * - lines an array of lines, each line being an array of successive Vector3
  82334. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82335. * @returns the VertexData of the LineSystem
  82336. */
  82337. static CreateLineSystem(options: {
  82338. lines: Vector3[][];
  82339. colors?: Nullable<Color4[][]>;
  82340. }): VertexData;
  82341. /**
  82342. * Create the VertexData for a DashedLines
  82343. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82344. * - points an array successive Vector3
  82345. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82346. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82347. * - dashNb the intended total number of dashes, optional, default 200
  82348. * @returns the VertexData for the DashedLines
  82349. */
  82350. static CreateDashedLines(options: {
  82351. points: Vector3[];
  82352. dashSize?: number;
  82353. gapSize?: number;
  82354. dashNb?: number;
  82355. }): VertexData;
  82356. /**
  82357. * Creates the VertexData for a Ground
  82358. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82359. * - width the width (x direction) of the ground, optional, default 1
  82360. * - height the height (z direction) of the ground, optional, default 1
  82361. * - subdivisions the number of subdivisions per side, optional, default 1
  82362. * @returns the VertexData of the Ground
  82363. */
  82364. static CreateGround(options: {
  82365. width?: number;
  82366. height?: number;
  82367. subdivisions?: number;
  82368. subdivisionsX?: number;
  82369. subdivisionsY?: number;
  82370. }): VertexData;
  82371. /**
  82372. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82373. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82374. * * xmin the ground minimum X coordinate, optional, default -1
  82375. * * zmin the ground minimum Z coordinate, optional, default -1
  82376. * * xmax the ground maximum X coordinate, optional, default 1
  82377. * * zmax the ground maximum Z coordinate, optional, default 1
  82378. * * 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}
  82379. * * 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}
  82380. * @returns the VertexData of the TiledGround
  82381. */
  82382. static CreateTiledGround(options: {
  82383. xmin: number;
  82384. zmin: number;
  82385. xmax: number;
  82386. zmax: number;
  82387. subdivisions?: {
  82388. w: number;
  82389. h: number;
  82390. };
  82391. precision?: {
  82392. w: number;
  82393. h: number;
  82394. };
  82395. }): VertexData;
  82396. /**
  82397. * Creates the VertexData of the Ground designed from a heightmap
  82398. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82399. * * width the width (x direction) of the ground
  82400. * * height the height (z direction) of the ground
  82401. * * subdivisions the number of subdivisions per side
  82402. * * minHeight the minimum altitude on the ground, optional, default 0
  82403. * * maxHeight the maximum altitude on the ground, optional default 1
  82404. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82405. * * buffer the array holding the image color data
  82406. * * bufferWidth the width of image
  82407. * * bufferHeight the height of image
  82408. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82409. * @returns the VertexData of the Ground designed from a heightmap
  82410. */
  82411. static CreateGroundFromHeightMap(options: {
  82412. width: number;
  82413. height: number;
  82414. subdivisions: number;
  82415. minHeight: number;
  82416. maxHeight: number;
  82417. colorFilter: Color3;
  82418. buffer: Uint8Array;
  82419. bufferWidth: number;
  82420. bufferHeight: number;
  82421. alphaFilter: number;
  82422. }): VertexData;
  82423. /**
  82424. * Creates the VertexData for a Plane
  82425. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82426. * * size sets the width and height of the plane to the value of size, optional default 1
  82427. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82428. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82430. * * 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)
  82431. * * 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)
  82432. * @returns the VertexData of the box
  82433. */
  82434. static CreatePlane(options: {
  82435. size?: number;
  82436. width?: number;
  82437. height?: number;
  82438. sideOrientation?: number;
  82439. frontUVs?: Vector4;
  82440. backUVs?: Vector4;
  82441. }): VertexData;
  82442. /**
  82443. * Creates the VertexData of the Disc or regular Polygon
  82444. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82445. * * radius the radius of the disc, optional default 0.5
  82446. * * tessellation the number of polygon sides, optional, default 64
  82447. * * 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
  82448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82449. * * 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)
  82450. * * 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)
  82451. * @returns the VertexData of the box
  82452. */
  82453. static CreateDisc(options: {
  82454. radius?: number;
  82455. tessellation?: number;
  82456. arc?: number;
  82457. sideOrientation?: number;
  82458. frontUVs?: Vector4;
  82459. backUVs?: Vector4;
  82460. }): VertexData;
  82461. /**
  82462. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82463. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82464. * @param polygon a mesh built from polygonTriangulation.build()
  82465. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82466. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82467. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82468. * @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)
  82469. * @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)
  82470. * @returns the VertexData of the Polygon
  82471. */
  82472. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82473. /**
  82474. * Creates the VertexData of the IcoSphere
  82475. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82476. * * radius the radius of the IcoSphere, optional default 1
  82477. * * radiusX allows stretching in the x direction, optional, default radius
  82478. * * radiusY allows stretching in the y direction, optional, default radius
  82479. * * radiusZ allows stretching in the z direction, optional, default radius
  82480. * * flat when true creates a flat shaded mesh, optional, default true
  82481. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82483. * * 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)
  82484. * * 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)
  82485. * @returns the VertexData of the IcoSphere
  82486. */
  82487. static CreateIcoSphere(options: {
  82488. radius?: number;
  82489. radiusX?: number;
  82490. radiusY?: number;
  82491. radiusZ?: number;
  82492. flat?: boolean;
  82493. subdivisions?: number;
  82494. sideOrientation?: number;
  82495. frontUVs?: Vector4;
  82496. backUVs?: Vector4;
  82497. }): VertexData;
  82498. /**
  82499. * Creates the VertexData for a Polyhedron
  82500. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82501. * * type provided types are:
  82502. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82503. * * 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)
  82504. * * size the size of the IcoSphere, optional default 1
  82505. * * sizeX allows stretching in the x direction, optional, default size
  82506. * * sizeY allows stretching in the y direction, optional, default size
  82507. * * sizeZ allows stretching in the z direction, optional, default size
  82508. * * 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
  82509. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82510. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82511. * * flat when true creates a flat shaded mesh, optional, default true
  82512. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82514. * * 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)
  82515. * * 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)
  82516. * @returns the VertexData of the Polyhedron
  82517. */
  82518. static CreatePolyhedron(options: {
  82519. type?: number;
  82520. size?: number;
  82521. sizeX?: number;
  82522. sizeY?: number;
  82523. sizeZ?: number;
  82524. custom?: any;
  82525. faceUV?: Vector4[];
  82526. faceColors?: Color4[];
  82527. flat?: boolean;
  82528. sideOrientation?: number;
  82529. frontUVs?: Vector4;
  82530. backUVs?: Vector4;
  82531. }): VertexData;
  82532. /**
  82533. * Creates the VertexData for a TorusKnot
  82534. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82535. * * radius the radius of the torus knot, optional, default 2
  82536. * * tube the thickness of the tube, optional, default 0.5
  82537. * * radialSegments the number of sides on each tube segments, optional, default 32
  82538. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82539. * * p the number of windings around the z axis, optional, default 2
  82540. * * q the number of windings around the x axis, optional, default 3
  82541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82542. * * 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)
  82543. * * 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)
  82544. * @returns the VertexData of the Torus Knot
  82545. */
  82546. static CreateTorusKnot(options: {
  82547. radius?: number;
  82548. tube?: number;
  82549. radialSegments?: number;
  82550. tubularSegments?: number;
  82551. p?: number;
  82552. q?: number;
  82553. sideOrientation?: number;
  82554. frontUVs?: Vector4;
  82555. backUVs?: Vector4;
  82556. }): VertexData;
  82557. /**
  82558. * Compute normals for given positions and indices
  82559. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82560. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82561. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82562. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82563. * * facetNormals : optional array of facet normals (vector3)
  82564. * * facetPositions : optional array of facet positions (vector3)
  82565. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82566. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82567. * * bInfo : optional bounding info, required for facetPartitioning computation
  82568. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82569. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82570. * * useRightHandedSystem: optional boolean to for right handed system computation
  82571. * * depthSort : optional boolean to enable the facet depth sort computation
  82572. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82573. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82574. */
  82575. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82576. facetNormals?: any;
  82577. facetPositions?: any;
  82578. facetPartitioning?: any;
  82579. ratio?: number;
  82580. bInfo?: any;
  82581. bbSize?: Vector3;
  82582. subDiv?: any;
  82583. useRightHandedSystem?: boolean;
  82584. depthSort?: boolean;
  82585. distanceTo?: Vector3;
  82586. depthSortedFacets?: any;
  82587. }): void;
  82588. /** @hidden */
  82589. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82590. /**
  82591. * Applies VertexData created from the imported parameters to the geometry
  82592. * @param parsedVertexData the parsed data from an imported file
  82593. * @param geometry the geometry to apply the VertexData to
  82594. */
  82595. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82596. }
  82597. }
  82598. declare module BABYLON {
  82599. /**
  82600. * Class containing static functions to help procedurally build meshes
  82601. */
  82602. export class DiscBuilder {
  82603. /**
  82604. * Creates a plane polygonal mesh. By default, this is a disc
  82605. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82606. * * 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
  82607. * * 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
  82608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82611. * @param name defines the name of the mesh
  82612. * @param options defines the options used to create the mesh
  82613. * @param scene defines the hosting scene
  82614. * @returns the plane polygonal mesh
  82615. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82616. */
  82617. static CreateDisc(name: string, options: {
  82618. radius?: number;
  82619. tessellation?: number;
  82620. arc?: number;
  82621. updatable?: boolean;
  82622. sideOrientation?: number;
  82623. frontUVs?: Vector4;
  82624. backUVs?: Vector4;
  82625. }, scene?: Nullable<Scene>): Mesh;
  82626. }
  82627. }
  82628. declare module BABYLON {
  82629. /**
  82630. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82631. *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.
  82632. * The SPS is also a particle system. It provides some methods to manage the particles.
  82633. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82634. *
  82635. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82636. */
  82637. export class SolidParticleSystem implements IDisposable {
  82638. /**
  82639. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82640. * Example : var p = SPS.particles[i];
  82641. */
  82642. particles: SolidParticle[];
  82643. /**
  82644. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82645. */
  82646. nbParticles: number;
  82647. /**
  82648. * If the particles must ever face the camera (default false). Useful for planar particles.
  82649. */
  82650. billboard: boolean;
  82651. /**
  82652. * Recompute normals when adding a shape
  82653. */
  82654. recomputeNormals: boolean;
  82655. /**
  82656. * This a counter ofr your own usage. It's not set by any SPS functions.
  82657. */
  82658. counter: number;
  82659. /**
  82660. * The SPS name. This name is also given to the underlying mesh.
  82661. */
  82662. name: string;
  82663. /**
  82664. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82665. */
  82666. mesh: Mesh;
  82667. /**
  82668. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82669. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82670. */
  82671. vars: any;
  82672. /**
  82673. * This array is populated when the SPS is set as 'pickable'.
  82674. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82675. * Each element of this array is an object `{idx: int, faceId: int}`.
  82676. * `idx` is the picked particle index in the `SPS.particles` array
  82677. * `faceId` is the picked face index counted within this particle.
  82678. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82679. */
  82680. pickedParticles: {
  82681. idx: number;
  82682. faceId: number;
  82683. }[];
  82684. /**
  82685. * This array is populated when `enableDepthSort` is set to true.
  82686. * Each element of this array is an instance of the class DepthSortedParticle.
  82687. */
  82688. depthSortedParticles: DepthSortedParticle[];
  82689. /**
  82690. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82691. * @hidden
  82692. */
  82693. _bSphereOnly: boolean;
  82694. /**
  82695. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82696. * @hidden
  82697. */
  82698. _bSphereRadiusFactor: number;
  82699. private _scene;
  82700. private _positions;
  82701. private _indices;
  82702. private _normals;
  82703. private _colors;
  82704. private _uvs;
  82705. private _indices32;
  82706. private _positions32;
  82707. private _normals32;
  82708. private _fixedNormal32;
  82709. private _colors32;
  82710. private _uvs32;
  82711. private _index;
  82712. private _updatable;
  82713. private _pickable;
  82714. private _isVisibilityBoxLocked;
  82715. private _alwaysVisible;
  82716. private _depthSort;
  82717. private _shapeCounter;
  82718. private _copy;
  82719. private _color;
  82720. private _computeParticleColor;
  82721. private _computeParticleTexture;
  82722. private _computeParticleRotation;
  82723. private _computeParticleVertex;
  82724. private _computeBoundingBox;
  82725. private _depthSortParticles;
  82726. private _camera;
  82727. private _mustUnrotateFixedNormals;
  82728. private _particlesIntersect;
  82729. private _needs32Bits;
  82730. /**
  82731. * Creates a SPS (Solid Particle System) object.
  82732. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82733. * @param scene (Scene) is the scene in which the SPS is added.
  82734. * @param options defines the options of the sps e.g.
  82735. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82736. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82737. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82738. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82739. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82740. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82741. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82742. */
  82743. constructor(name: string, scene: Scene, options?: {
  82744. updatable?: boolean;
  82745. isPickable?: boolean;
  82746. enableDepthSort?: boolean;
  82747. particleIntersection?: boolean;
  82748. boundingSphereOnly?: boolean;
  82749. bSphereRadiusFactor?: number;
  82750. });
  82751. /**
  82752. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82753. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82754. * @returns the created mesh
  82755. */
  82756. buildMesh(): Mesh;
  82757. /**
  82758. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82759. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82760. * Thus the particles generated from `digest()` have their property `position` set yet.
  82761. * @param mesh ( Mesh ) is the mesh to be digested
  82762. * @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
  82763. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82764. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82765. * @returns the current SPS
  82766. */
  82767. digest(mesh: Mesh, options?: {
  82768. facetNb?: number;
  82769. number?: number;
  82770. delta?: number;
  82771. }): SolidParticleSystem;
  82772. private _unrotateFixedNormals;
  82773. private _resetCopy;
  82774. private _meshBuilder;
  82775. private _posToShape;
  82776. private _uvsToShapeUV;
  82777. private _addParticle;
  82778. /**
  82779. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82780. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82781. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82782. * @param nb (positive integer) the number of particles to be created from this model
  82783. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82784. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82785. * @returns the number of shapes in the system
  82786. */
  82787. addShape(mesh: Mesh, nb: number, options?: {
  82788. positionFunction?: any;
  82789. vertexFunction?: any;
  82790. }): number;
  82791. private _rebuildParticle;
  82792. /**
  82793. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82794. * @returns the SPS.
  82795. */
  82796. rebuildMesh(): SolidParticleSystem;
  82797. /**
  82798. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82799. * This method calls `updateParticle()` for each particle of the SPS.
  82800. * For an animated SPS, it is usually called within the render loop.
  82801. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82802. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82803. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82804. * @returns the SPS.
  82805. */
  82806. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82807. /**
  82808. * Disposes the SPS.
  82809. */
  82810. dispose(): void;
  82811. /**
  82812. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82814. * @returns the SPS.
  82815. */
  82816. refreshVisibleSize(): SolidParticleSystem;
  82817. /**
  82818. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82819. * @param size the size (float) of the visibility box
  82820. * note : this doesn't lock the SPS mesh bounding box.
  82821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82822. */
  82823. setVisibilityBox(size: number): void;
  82824. /**
  82825. * Gets whether the SPS as always visible or not
  82826. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82827. */
  82828. /**
  82829. * Sets the SPS as always visible or not
  82830. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82831. */
  82832. isAlwaysVisible: boolean;
  82833. /**
  82834. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82835. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82836. */
  82837. /**
  82838. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82840. */
  82841. isVisibilityBoxLocked: boolean;
  82842. /**
  82843. * Tells to `setParticles()` to compute the particle rotations or not.
  82844. * Default value : true. The SPS is faster when it's set to false.
  82845. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82846. */
  82847. /**
  82848. * Gets if `setParticles()` computes the particle rotations or not.
  82849. * Default value : true. The SPS is faster when it's set to false.
  82850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82851. */
  82852. computeParticleRotation: boolean;
  82853. /**
  82854. * Tells to `setParticles()` to compute the particle colors or not.
  82855. * Default value : true. The SPS is faster when it's set to false.
  82856. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82857. */
  82858. /**
  82859. * Gets if `setParticles()` computes the particle colors or not.
  82860. * Default value : true. The SPS is faster when it's set to false.
  82861. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82862. */
  82863. computeParticleColor: boolean;
  82864. /**
  82865. * Gets if `setParticles()` computes the particle textures or not.
  82866. * Default value : true. The SPS is faster when it's set to false.
  82867. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82868. */
  82869. computeParticleTexture: boolean;
  82870. /**
  82871. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82872. * Default value : false. The SPS is faster when it's set to false.
  82873. * Note : the particle custom vertex positions aren't stored values.
  82874. */
  82875. /**
  82876. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82877. * Default value : false. The SPS is faster when it's set to false.
  82878. * Note : the particle custom vertex positions aren't stored values.
  82879. */
  82880. computeParticleVertex: boolean;
  82881. /**
  82882. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82883. */
  82884. /**
  82885. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82886. */
  82887. computeBoundingBox: boolean;
  82888. /**
  82889. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82890. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82891. * Default : `true`
  82892. */
  82893. /**
  82894. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82895. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82896. * Default : `true`
  82897. */
  82898. depthSortParticles: boolean;
  82899. /**
  82900. * This function does nothing. It may be overwritten to set all the particle first values.
  82901. * The SPS doesn't call this function, you may have to call it by your own.
  82902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82903. */
  82904. initParticles(): void;
  82905. /**
  82906. * This function does nothing. It may be overwritten to recycle a particle.
  82907. * The SPS doesn't call this function, you may have to call it by your own.
  82908. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82909. * @param particle The particle to recycle
  82910. * @returns the recycled particle
  82911. */
  82912. recycleParticle(particle: SolidParticle): SolidParticle;
  82913. /**
  82914. * Updates a particle : this function should be overwritten by the user.
  82915. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82916. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82917. * @example : just set a particle position or velocity and recycle conditions
  82918. * @param particle The particle to update
  82919. * @returns the updated particle
  82920. */
  82921. updateParticle(particle: SolidParticle): SolidParticle;
  82922. /**
  82923. * Updates a vertex of a particle : it can be overwritten by the user.
  82924. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82925. * @param particle the current particle
  82926. * @param vertex the current index of the current particle
  82927. * @param pt the index of the current vertex in the particle shape
  82928. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82929. * @example : just set a vertex particle position
  82930. * @returns the updated vertex
  82931. */
  82932. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82933. /**
  82934. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82935. * This does nothing and may be overwritten by the user.
  82936. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82938. * @param update the boolean update value actually passed to setParticles()
  82939. */
  82940. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82941. /**
  82942. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82943. * This will be passed three parameters.
  82944. * This does nothing and may be overwritten by the user.
  82945. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82946. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82947. * @param update the boolean update value actually passed to setParticles()
  82948. */
  82949. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82950. }
  82951. }
  82952. declare module BABYLON {
  82953. /**
  82954. * Represents one particle of a solid particle system.
  82955. */
  82956. export class SolidParticle {
  82957. /**
  82958. * particle global index
  82959. */
  82960. idx: number;
  82961. /**
  82962. * The color of the particle
  82963. */
  82964. color: Nullable<Color4>;
  82965. /**
  82966. * The world space position of the particle.
  82967. */
  82968. position: Vector3;
  82969. /**
  82970. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82971. */
  82972. rotation: Vector3;
  82973. /**
  82974. * The world space rotation quaternion of the particle.
  82975. */
  82976. rotationQuaternion: Nullable<Quaternion>;
  82977. /**
  82978. * The scaling of the particle.
  82979. */
  82980. scaling: Vector3;
  82981. /**
  82982. * The uvs of the particle.
  82983. */
  82984. uvs: Vector4;
  82985. /**
  82986. * The current speed of the particle.
  82987. */
  82988. velocity: Vector3;
  82989. /**
  82990. * The pivot point in the particle local space.
  82991. */
  82992. pivot: Vector3;
  82993. /**
  82994. * Must the particle be translated from its pivot point in its local space ?
  82995. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82996. * Default : false
  82997. */
  82998. translateFromPivot: boolean;
  82999. /**
  83000. * Is the particle active or not ?
  83001. */
  83002. alive: boolean;
  83003. /**
  83004. * Is the particle visible or not ?
  83005. */
  83006. isVisible: boolean;
  83007. /**
  83008. * Index of this particle in the global "positions" array (Internal use)
  83009. * @hidden
  83010. */
  83011. _pos: number;
  83012. /**
  83013. * @hidden Index of this particle in the global "indices" array (Internal use)
  83014. */
  83015. _ind: number;
  83016. /**
  83017. * @hidden ModelShape of this particle (Internal use)
  83018. */
  83019. _model: ModelShape;
  83020. /**
  83021. * ModelShape id of this particle
  83022. */
  83023. shapeId: number;
  83024. /**
  83025. * Index of the particle in its shape id (Internal use)
  83026. */
  83027. idxInShape: number;
  83028. /**
  83029. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83030. */
  83031. _modelBoundingInfo: BoundingInfo;
  83032. /**
  83033. * @hidden Particle BoundingInfo object (Internal use)
  83034. */
  83035. _boundingInfo: BoundingInfo;
  83036. /**
  83037. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83038. */
  83039. _sps: SolidParticleSystem;
  83040. /**
  83041. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83042. */
  83043. _stillInvisible: boolean;
  83044. /**
  83045. * @hidden Last computed particle rotation matrix
  83046. */
  83047. _rotationMatrix: number[];
  83048. /**
  83049. * Parent particle Id, if any.
  83050. * Default null.
  83051. */
  83052. parentId: Nullable<number>;
  83053. /**
  83054. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83055. * The possible values are :
  83056. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83057. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83058. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83059. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83060. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83061. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83062. * */
  83063. cullingStrategy: number;
  83064. /**
  83065. * @hidden Internal global position in the SPS.
  83066. */
  83067. _globalPosition: Vector3;
  83068. /**
  83069. * Creates a Solid Particle object.
  83070. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83071. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83072. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83073. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83074. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83075. * @param shapeId (integer) is the model shape identifier in the SPS.
  83076. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83077. * @param sps defines the sps it is associated to
  83078. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83079. */
  83080. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83081. /**
  83082. * Legacy support, changed scale to scaling
  83083. */
  83084. /**
  83085. * Legacy support, changed scale to scaling
  83086. */
  83087. scale: Vector3;
  83088. /**
  83089. * Legacy support, changed quaternion to rotationQuaternion
  83090. */
  83091. /**
  83092. * Legacy support, changed quaternion to rotationQuaternion
  83093. */
  83094. quaternion: Nullable<Quaternion>;
  83095. /**
  83096. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83097. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83098. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83099. * @returns true if it intersects
  83100. */
  83101. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83102. /**
  83103. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83104. * A particle is in the frustum if its bounding box intersects the frustum
  83105. * @param frustumPlanes defines the frustum to test
  83106. * @returns true if the particle is in the frustum planes
  83107. */
  83108. isInFrustum(frustumPlanes: Plane[]): boolean;
  83109. /**
  83110. * get the rotation matrix of the particle
  83111. * @hidden
  83112. */
  83113. getRotationMatrix(m: Matrix): void;
  83114. }
  83115. /**
  83116. * Represents the shape of the model used by one particle of a solid particle system.
  83117. * SPS internal tool, don't use it manually.
  83118. */
  83119. export class ModelShape {
  83120. /**
  83121. * The shape id
  83122. * @hidden
  83123. */
  83124. shapeID: number;
  83125. /**
  83126. * flat array of model positions (internal use)
  83127. * @hidden
  83128. */
  83129. _shape: Vector3[];
  83130. /**
  83131. * flat array of model UVs (internal use)
  83132. * @hidden
  83133. */
  83134. _shapeUV: number[];
  83135. /**
  83136. * length of the shape in the model indices array (internal use)
  83137. * @hidden
  83138. */
  83139. _indicesLength: number;
  83140. /**
  83141. * Custom position function (internal use)
  83142. * @hidden
  83143. */
  83144. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83145. /**
  83146. * Custom vertex function (internal use)
  83147. * @hidden
  83148. */
  83149. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83150. /**
  83151. * 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.
  83152. * SPS internal tool, don't use it manually.
  83153. * @hidden
  83154. */
  83155. 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>);
  83156. }
  83157. /**
  83158. * Represents a Depth Sorted Particle in the solid particle system.
  83159. */
  83160. export class DepthSortedParticle {
  83161. /**
  83162. * Index of the particle in the "indices" array
  83163. */
  83164. ind: number;
  83165. /**
  83166. * Length of the particle shape in the "indices" array
  83167. */
  83168. indicesLength: number;
  83169. /**
  83170. * Squared distance from the particle to the camera
  83171. */
  83172. sqDistance: number;
  83173. }
  83174. }
  83175. declare module BABYLON {
  83176. /**
  83177. * Class used to store all common mesh properties
  83178. */
  83179. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83180. /** No occlusion */
  83181. static OCCLUSION_TYPE_NONE: number;
  83182. /** Occlusion set to optimisitic */
  83183. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83184. /** Occlusion set to strict */
  83185. static OCCLUSION_TYPE_STRICT: number;
  83186. /** Use an accurante occlusion algorithm */
  83187. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83188. /** Use a conservative occlusion algorithm */
  83189. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83190. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83191. * Test order :
  83192. * Is the bounding sphere outside the frustum ?
  83193. * If not, are the bounding box vertices outside the frustum ?
  83194. * It not, then the cullable object is in the frustum.
  83195. */
  83196. static readonly CULLINGSTRATEGY_STANDARD: number;
  83197. /** Culling strategy : Bounding Sphere Only.
  83198. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83199. * It's also less accurate than the standard because some not visible objects can still be selected.
  83200. * Test : is the bounding sphere outside the frustum ?
  83201. * If not, then the cullable object is in the frustum.
  83202. */
  83203. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83204. /** Culling strategy : Optimistic Inclusion.
  83205. * This in an inclusion test first, then the standard exclusion test.
  83206. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83207. * 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.
  83208. * Anyway, it's as accurate as the standard strategy.
  83209. * Test :
  83210. * Is the cullable object bounding sphere center in the frustum ?
  83211. * If not, apply the default culling strategy.
  83212. */
  83213. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83214. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83215. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83216. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83217. * 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.
  83218. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83219. * Test :
  83220. * Is the cullable object bounding sphere center in the frustum ?
  83221. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83222. */
  83223. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83224. /**
  83225. * No billboard
  83226. */
  83227. static readonly BILLBOARDMODE_NONE: number;
  83228. /** Billboard on X axis */
  83229. static readonly BILLBOARDMODE_X: number;
  83230. /** Billboard on Y axis */
  83231. static readonly BILLBOARDMODE_Y: number;
  83232. /** Billboard on Z axis */
  83233. static readonly BILLBOARDMODE_Z: number;
  83234. /** Billboard on all axes */
  83235. static readonly BILLBOARDMODE_ALL: number;
  83236. private _facetData;
  83237. /**
  83238. * The culling strategy to use to check whether the mesh must be rendered or not.
  83239. * This value can be changed at any time and will be used on the next render mesh selection.
  83240. * The possible values are :
  83241. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83242. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83243. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83244. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83245. * Please read each static variable documentation to get details about the culling process.
  83246. * */
  83247. cullingStrategy: number;
  83248. /**
  83249. * Gets the number of facets in the mesh
  83250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83251. */
  83252. readonly facetNb: number;
  83253. /**
  83254. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83256. */
  83257. partitioningSubdivisions: number;
  83258. /**
  83259. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83260. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83261. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83262. */
  83263. partitioningBBoxRatio: number;
  83264. /**
  83265. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83266. * Works only for updatable meshes.
  83267. * Doesn't work with multi-materials
  83268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83269. */
  83270. mustDepthSortFacets: boolean;
  83271. /**
  83272. * The location (Vector3) where the facet depth sort must be computed from.
  83273. * By default, the active camera position.
  83274. * Used only when facet depth sort is enabled
  83275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83276. */
  83277. facetDepthSortFrom: Vector3;
  83278. /**
  83279. * gets a boolean indicating if facetData is enabled
  83280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83281. */
  83282. readonly isFacetDataEnabled: boolean;
  83283. /** @hidden */
  83284. _updateNonUniformScalingState(value: boolean): boolean;
  83285. /**
  83286. * An event triggered when this mesh collides with another one
  83287. */
  83288. onCollideObservable: Observable<AbstractMesh>;
  83289. private _onCollideObserver;
  83290. /** Set a function to call when this mesh collides with another one */
  83291. onCollide: () => void;
  83292. /**
  83293. * An event triggered when the collision's position changes
  83294. */
  83295. onCollisionPositionChangeObservable: Observable<Vector3>;
  83296. private _onCollisionPositionChangeObserver;
  83297. /** Set a function to call when the collision's position changes */
  83298. onCollisionPositionChange: () => void;
  83299. /**
  83300. * An event triggered when material is changed
  83301. */
  83302. onMaterialChangedObservable: Observable<AbstractMesh>;
  83303. /**
  83304. * Gets or sets the orientation for POV movement & rotation
  83305. */
  83306. definedFacingForward: boolean;
  83307. /** @hidden */
  83308. _occlusionQuery: Nullable<WebGLQuery>;
  83309. private _visibility;
  83310. /**
  83311. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83312. */
  83313. /**
  83314. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83315. */
  83316. visibility: number;
  83317. /** Gets or sets the alpha index used to sort transparent meshes
  83318. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83319. */
  83320. alphaIndex: number;
  83321. /**
  83322. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83323. */
  83324. isVisible: boolean;
  83325. /**
  83326. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83327. */
  83328. isPickable: boolean;
  83329. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83330. showSubMeshesBoundingBox: boolean;
  83331. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83332. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83333. */
  83334. isBlocker: boolean;
  83335. /**
  83336. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83337. */
  83338. enablePointerMoveEvents: boolean;
  83339. /**
  83340. * Specifies the rendering group id for this mesh (0 by default)
  83341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83342. */
  83343. renderingGroupId: number;
  83344. private _material;
  83345. /** Gets or sets current material */
  83346. material: Nullable<Material>;
  83347. private _receiveShadows;
  83348. /**
  83349. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83350. * @see http://doc.babylonjs.com/babylon101/shadows
  83351. */
  83352. receiveShadows: boolean;
  83353. /** Defines color to use when rendering outline */
  83354. outlineColor: Color3;
  83355. /** Define width to use when rendering outline */
  83356. outlineWidth: number;
  83357. /** Defines color to use when rendering overlay */
  83358. overlayColor: Color3;
  83359. /** Defines alpha to use when rendering overlay */
  83360. overlayAlpha: number;
  83361. private _hasVertexAlpha;
  83362. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83363. hasVertexAlpha: boolean;
  83364. private _useVertexColors;
  83365. /** 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) */
  83366. useVertexColors: boolean;
  83367. private _computeBonesUsingShaders;
  83368. /**
  83369. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83370. */
  83371. computeBonesUsingShaders: boolean;
  83372. private _numBoneInfluencers;
  83373. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83374. numBoneInfluencers: number;
  83375. private _applyFog;
  83376. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83377. applyFog: boolean;
  83378. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83379. useOctreeForRenderingSelection: boolean;
  83380. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83381. useOctreeForPicking: boolean;
  83382. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83383. useOctreeForCollisions: boolean;
  83384. private _layerMask;
  83385. /**
  83386. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83387. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83388. */
  83389. layerMask: number;
  83390. /**
  83391. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83392. */
  83393. alwaysSelectAsActiveMesh: boolean;
  83394. /**
  83395. * Gets or sets the current action manager
  83396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83397. */
  83398. actionManager: Nullable<AbstractActionManager>;
  83399. private _checkCollisions;
  83400. private _collisionMask;
  83401. private _collisionGroup;
  83402. /**
  83403. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83405. */
  83406. ellipsoid: Vector3;
  83407. /**
  83408. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83410. */
  83411. ellipsoidOffset: Vector3;
  83412. private _collider;
  83413. private _oldPositionForCollisions;
  83414. private _diffPositionForCollisions;
  83415. /**
  83416. * Gets or sets a collision mask used to mask collisions (default is -1).
  83417. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83418. */
  83419. collisionMask: number;
  83420. /**
  83421. * Gets or sets the current collision group mask (-1 by default).
  83422. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83423. */
  83424. collisionGroup: number;
  83425. /**
  83426. * Defines edge width used when edgesRenderer is enabled
  83427. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83428. */
  83429. edgesWidth: number;
  83430. /**
  83431. * Defines edge color used when edgesRenderer is enabled
  83432. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83433. */
  83434. edgesColor: Color4;
  83435. /** @hidden */
  83436. _edgesRenderer: Nullable<IEdgesRenderer>;
  83437. /** @hidden */
  83438. _masterMesh: Nullable<AbstractMesh>;
  83439. /** @hidden */
  83440. _boundingInfo: Nullable<BoundingInfo>;
  83441. /** @hidden */
  83442. _renderId: number;
  83443. /**
  83444. * Gets or sets the list of subMeshes
  83445. * @see http://doc.babylonjs.com/how_to/multi_materials
  83446. */
  83447. subMeshes: SubMesh[];
  83448. /** @hidden */
  83449. _intersectionsInProgress: AbstractMesh[];
  83450. /** @hidden */
  83451. _unIndexed: boolean;
  83452. /** @hidden */
  83453. _lightSources: Light[];
  83454. /** @hidden */
  83455. readonly _positions: Nullable<Vector3[]>;
  83456. /** @hidden */
  83457. _waitingActions: any;
  83458. /** @hidden */
  83459. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83460. private _skeleton;
  83461. /** @hidden */
  83462. _bonesTransformMatrices: Nullable<Float32Array>;
  83463. /**
  83464. * Gets or sets a skeleton to apply skining transformations
  83465. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83466. */
  83467. skeleton: Nullable<Skeleton>;
  83468. /**
  83469. * An event triggered when the mesh is rebuilt.
  83470. */
  83471. onRebuildObservable: Observable<AbstractMesh>;
  83472. /**
  83473. * Creates a new AbstractMesh
  83474. * @param name defines the name of the mesh
  83475. * @param scene defines the hosting scene
  83476. */
  83477. constructor(name: string, scene?: Nullable<Scene>);
  83478. /**
  83479. * Returns the string "AbstractMesh"
  83480. * @returns "AbstractMesh"
  83481. */
  83482. getClassName(): string;
  83483. /**
  83484. * Gets a string representation of the current mesh
  83485. * @param fullDetails defines a boolean indicating if full details must be included
  83486. * @returns a string representation of the current mesh
  83487. */
  83488. toString(fullDetails?: boolean): string;
  83489. /**
  83490. * @hidden
  83491. */
  83492. protected _getEffectiveParent(): Nullable<Node>;
  83493. /** @hidden */
  83494. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83495. /** @hidden */
  83496. _rebuild(): void;
  83497. /** @hidden */
  83498. _resyncLightSources(): void;
  83499. /** @hidden */
  83500. _resyncLighSource(light: Light): void;
  83501. /** @hidden */
  83502. _unBindEffect(): void;
  83503. /** @hidden */
  83504. _removeLightSource(light: Light): void;
  83505. private _markSubMeshesAsDirty;
  83506. /** @hidden */
  83507. _markSubMeshesAsLightDirty(): void;
  83508. /** @hidden */
  83509. _markSubMeshesAsAttributesDirty(): void;
  83510. /** @hidden */
  83511. _markSubMeshesAsMiscDirty(): void;
  83512. /**
  83513. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83514. */
  83515. scaling: Vector3;
  83516. /**
  83517. * Returns true if the mesh is blocked. Implemented by child classes
  83518. */
  83519. readonly isBlocked: boolean;
  83520. /**
  83521. * Returns the mesh itself by default. Implemented by child classes
  83522. * @param camera defines the camera to use to pick the right LOD level
  83523. * @returns the currentAbstractMesh
  83524. */
  83525. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83526. /**
  83527. * Returns 0 by default. Implemented by child classes
  83528. * @returns an integer
  83529. */
  83530. getTotalVertices(): number;
  83531. /**
  83532. * Returns a positive integer : the total number of indices in this mesh geometry.
  83533. * @returns the numner of indices or zero if the mesh has no geometry.
  83534. */
  83535. getTotalIndices(): number;
  83536. /**
  83537. * Returns null by default. Implemented by child classes
  83538. * @returns null
  83539. */
  83540. getIndices(): Nullable<IndicesArray>;
  83541. /**
  83542. * Returns the array of the requested vertex data kind. Implemented by child classes
  83543. * @param kind defines the vertex data kind to use
  83544. * @returns null
  83545. */
  83546. getVerticesData(kind: string): Nullable<FloatArray>;
  83547. /**
  83548. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83549. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83550. * Note that a new underlying VertexBuffer object is created each call.
  83551. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83552. * @param kind defines vertex data kind:
  83553. * * VertexBuffer.PositionKind
  83554. * * VertexBuffer.UVKind
  83555. * * VertexBuffer.UV2Kind
  83556. * * VertexBuffer.UV3Kind
  83557. * * VertexBuffer.UV4Kind
  83558. * * VertexBuffer.UV5Kind
  83559. * * VertexBuffer.UV6Kind
  83560. * * VertexBuffer.ColorKind
  83561. * * VertexBuffer.MatricesIndicesKind
  83562. * * VertexBuffer.MatricesIndicesExtraKind
  83563. * * VertexBuffer.MatricesWeightsKind
  83564. * * VertexBuffer.MatricesWeightsExtraKind
  83565. * @param data defines the data source
  83566. * @param updatable defines if the data must be flagged as updatable (or static)
  83567. * @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
  83568. * @returns the current mesh
  83569. */
  83570. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83571. /**
  83572. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83573. * If the mesh has no geometry, it is simply returned as it is.
  83574. * @param kind defines vertex data kind:
  83575. * * VertexBuffer.PositionKind
  83576. * * VertexBuffer.UVKind
  83577. * * VertexBuffer.UV2Kind
  83578. * * VertexBuffer.UV3Kind
  83579. * * VertexBuffer.UV4Kind
  83580. * * VertexBuffer.UV5Kind
  83581. * * VertexBuffer.UV6Kind
  83582. * * VertexBuffer.ColorKind
  83583. * * VertexBuffer.MatricesIndicesKind
  83584. * * VertexBuffer.MatricesIndicesExtraKind
  83585. * * VertexBuffer.MatricesWeightsKind
  83586. * * VertexBuffer.MatricesWeightsExtraKind
  83587. * @param data defines the data source
  83588. * @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
  83589. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83590. * @returns the current mesh
  83591. */
  83592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83593. /**
  83594. * Sets the mesh indices,
  83595. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83596. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83597. * @param totalVertices Defines the total number of vertices
  83598. * @returns the current mesh
  83599. */
  83600. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83601. /**
  83602. * Gets a boolean indicating if specific vertex data is present
  83603. * @param kind defines the vertex data kind to use
  83604. * @returns true is data kind is present
  83605. */
  83606. isVerticesDataPresent(kind: string): boolean;
  83607. /**
  83608. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83609. * @returns a BoundingInfo
  83610. */
  83611. getBoundingInfo(): BoundingInfo;
  83612. /**
  83613. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83614. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83615. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83616. * @returns the current mesh
  83617. */
  83618. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83619. /**
  83620. * Overwrite the current bounding info
  83621. * @param boundingInfo defines the new bounding info
  83622. * @returns the current mesh
  83623. */
  83624. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83625. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83626. readonly useBones: boolean;
  83627. /** @hidden */
  83628. _preActivate(): void;
  83629. /** @hidden */
  83630. _preActivateForIntermediateRendering(renderId: number): void;
  83631. /** @hidden */
  83632. _activate(renderId: number): void;
  83633. /**
  83634. * Gets the current world matrix
  83635. * @returns a Matrix
  83636. */
  83637. getWorldMatrix(): Matrix;
  83638. /** @hidden */
  83639. _getWorldMatrixDeterminant(): number;
  83640. /**
  83641. * Perform relative position change from the point of view of behind the front of the mesh.
  83642. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83643. * Supports definition of mesh facing forward or backward
  83644. * @param amountRight defines the distance on the right axis
  83645. * @param amountUp defines the distance on the up axis
  83646. * @param amountForward defines the distance on the forward axis
  83647. * @returns the current mesh
  83648. */
  83649. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83650. /**
  83651. * Calculate relative position change from the point of view of behind the front of the mesh.
  83652. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83653. * Supports definition of mesh facing forward or backward
  83654. * @param amountRight defines the distance on the right axis
  83655. * @param amountUp defines the distance on the up axis
  83656. * @param amountForward defines the distance on the forward axis
  83657. * @returns the new displacement vector
  83658. */
  83659. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83660. /**
  83661. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83662. * Supports definition of mesh facing forward or backward
  83663. * @param flipBack defines the flip
  83664. * @param twirlClockwise defines the twirl
  83665. * @param tiltRight defines the tilt
  83666. * @returns the current mesh
  83667. */
  83668. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83669. /**
  83670. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83671. * Supports definition of mesh facing forward or backward.
  83672. * @param flipBack defines the flip
  83673. * @param twirlClockwise defines the twirl
  83674. * @param tiltRight defines the tilt
  83675. * @returns the new rotation vector
  83676. */
  83677. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83678. /**
  83679. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83680. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83681. * @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
  83682. * @returns the new bounding vectors
  83683. */
  83684. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83685. min: Vector3;
  83686. max: Vector3;
  83687. };
  83688. /**
  83689. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83690. * This means the mesh underlying bounding box and sphere are recomputed.
  83691. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83692. * @returns the current mesh
  83693. */
  83694. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83695. /** @hidden */
  83696. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83697. /** @hidden */
  83698. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83699. /** @hidden */
  83700. _updateBoundingInfo(): AbstractMesh;
  83701. /** @hidden */
  83702. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83703. /** @hidden */
  83704. protected _afterComputeWorldMatrix(): void;
  83705. /** @hidden */
  83706. readonly _effectiveMesh: AbstractMesh;
  83707. /**
  83708. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83709. * A mesh is in the frustum if its bounding box intersects the frustum
  83710. * @param frustumPlanes defines the frustum to test
  83711. * @returns true if the mesh is in the frustum planes
  83712. */
  83713. isInFrustum(frustumPlanes: Plane[]): boolean;
  83714. /**
  83715. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83716. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83717. * @param frustumPlanes defines the frustum to test
  83718. * @returns true if the mesh is completely in the frustum planes
  83719. */
  83720. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83721. /**
  83722. * True if the mesh intersects another mesh or a SolidParticle object
  83723. * @param mesh defines a target mesh or SolidParticle to test
  83724. * @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)
  83725. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83726. * @returns true if there is an intersection
  83727. */
  83728. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83729. /**
  83730. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83731. * @param point defines the point to test
  83732. * @returns true if there is an intersection
  83733. */
  83734. intersectsPoint(point: Vector3): boolean;
  83735. /**
  83736. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83737. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83738. */
  83739. checkCollisions: boolean;
  83740. /**
  83741. * Gets Collider object used to compute collisions (not physics)
  83742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83743. */
  83744. readonly collider: Collider;
  83745. /**
  83746. * Move the mesh using collision engine
  83747. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83748. * @param displacement defines the requested displacement vector
  83749. * @returns the current mesh
  83750. */
  83751. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83752. private _onCollisionPositionChange;
  83753. /** @hidden */
  83754. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83755. /** @hidden */
  83756. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83757. /** @hidden */
  83758. _checkCollision(collider: Collider): AbstractMesh;
  83759. /** @hidden */
  83760. _generatePointsArray(): boolean;
  83761. /**
  83762. * Checks if the passed Ray intersects with the mesh
  83763. * @param ray defines the ray to use
  83764. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83766. * @returns the picking info
  83767. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83768. */
  83769. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83770. /**
  83771. * Clones the current mesh
  83772. * @param name defines the mesh name
  83773. * @param newParent defines the new mesh parent
  83774. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83775. * @returns the new mesh
  83776. */
  83777. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83778. /**
  83779. * Disposes all the submeshes of the current meshnp
  83780. * @returns the current mesh
  83781. */
  83782. releaseSubMeshes(): AbstractMesh;
  83783. /**
  83784. * Releases resources associated with this abstract mesh.
  83785. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83786. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83787. */
  83788. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83789. /**
  83790. * Adds the passed mesh as a child to the current mesh
  83791. * @param mesh defines the child mesh
  83792. * @returns the current mesh
  83793. */
  83794. addChild(mesh: AbstractMesh): AbstractMesh;
  83795. /**
  83796. * Removes the passed mesh from the current mesh children list
  83797. * @param mesh defines the child mesh
  83798. * @returns the current mesh
  83799. */
  83800. removeChild(mesh: AbstractMesh): AbstractMesh;
  83801. /** @hidden */
  83802. private _initFacetData;
  83803. /**
  83804. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83805. * This method can be called within the render loop.
  83806. * 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
  83807. * @returns the current mesh
  83808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83809. */
  83810. updateFacetData(): AbstractMesh;
  83811. /**
  83812. * Returns the facetLocalNormals array.
  83813. * The normals are expressed in the mesh local spac
  83814. * @returns an array of Vector3
  83815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83816. */
  83817. getFacetLocalNormals(): Vector3[];
  83818. /**
  83819. * Returns the facetLocalPositions array.
  83820. * The facet positions are expressed in the mesh local space
  83821. * @returns an array of Vector3
  83822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83823. */
  83824. getFacetLocalPositions(): Vector3[];
  83825. /**
  83826. * Returns the facetLocalPartioning array
  83827. * @returns an array of array of numbers
  83828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83829. */
  83830. getFacetLocalPartitioning(): number[][];
  83831. /**
  83832. * Returns the i-th facet position in the world system.
  83833. * This method allocates a new Vector3 per call
  83834. * @param i defines the facet index
  83835. * @returns a new Vector3
  83836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83837. */
  83838. getFacetPosition(i: number): Vector3;
  83839. /**
  83840. * Sets the reference Vector3 with the i-th facet position in the world system
  83841. * @param i defines the facet index
  83842. * @param ref defines the target vector
  83843. * @returns the current mesh
  83844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83845. */
  83846. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83847. /**
  83848. * Returns the i-th facet normal in the world system.
  83849. * This method allocates a new Vector3 per call
  83850. * @param i defines the facet index
  83851. * @returns a new Vector3
  83852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83853. */
  83854. getFacetNormal(i: number): Vector3;
  83855. /**
  83856. * Sets the reference Vector3 with the i-th facet normal in the world system
  83857. * @param i defines the facet index
  83858. * @param ref defines the target vector
  83859. * @returns the current mesh
  83860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83861. */
  83862. getFacetNormalToRef(i: number, ref: Vector3): this;
  83863. /**
  83864. * 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)
  83865. * @param x defines x coordinate
  83866. * @param y defines y coordinate
  83867. * @param z defines z coordinate
  83868. * @returns the array of facet indexes
  83869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83870. */
  83871. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83872. /**
  83873. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83874. * @param projected sets as the (x,y,z) world projection on the facet
  83875. * @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
  83876. * @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
  83877. * @param x defines x coordinate
  83878. * @param y defines y coordinate
  83879. * @param z defines z coordinate
  83880. * @returns the face index if found (or null instead)
  83881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83882. */
  83883. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83884. /**
  83885. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83886. * @param projected sets as the (x,y,z) local projection on the facet
  83887. * @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
  83888. * @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
  83889. * @param x defines x coordinate
  83890. * @param y defines y coordinate
  83891. * @param z defines z coordinate
  83892. * @returns the face index if found (or null instead)
  83893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83894. */
  83895. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83896. /**
  83897. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83898. * @returns the parameters
  83899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83900. */
  83901. getFacetDataParameters(): any;
  83902. /**
  83903. * Disables the feature FacetData and frees the related memory
  83904. * @returns the current mesh
  83905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83906. */
  83907. disableFacetData(): AbstractMesh;
  83908. /**
  83909. * Updates the AbstractMesh indices array
  83910. * @param indices defines the data source
  83911. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83912. * @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)
  83913. * @returns the current mesh
  83914. */
  83915. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83916. /**
  83917. * Creates new normals data for the mesh
  83918. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83919. * @returns the current mesh
  83920. */
  83921. createNormals(updatable: boolean): AbstractMesh;
  83922. /**
  83923. * Align the mesh with a normal
  83924. * @param normal defines the normal to use
  83925. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83926. * @returns the current mesh
  83927. */
  83928. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83929. /** @hidden */
  83930. _checkOcclusionQuery(): boolean;
  83931. }
  83932. }
  83933. declare module BABYLON {
  83934. /**
  83935. * Interface used to define ActionEvent
  83936. */
  83937. export interface IActionEvent {
  83938. /** The mesh or sprite that triggered the action */
  83939. source: any;
  83940. /** The X mouse cursor position at the time of the event */
  83941. pointerX: number;
  83942. /** The Y mouse cursor position at the time of the event */
  83943. pointerY: number;
  83944. /** The mesh that is currently pointed at (can be null) */
  83945. meshUnderPointer: Nullable<AbstractMesh>;
  83946. /** the original (browser) event that triggered the ActionEvent */
  83947. sourceEvent?: any;
  83948. /** additional data for the event */
  83949. additionalData?: any;
  83950. }
  83951. /**
  83952. * ActionEvent is the event being sent when an action is triggered.
  83953. */
  83954. export class ActionEvent implements IActionEvent {
  83955. /** The mesh or sprite that triggered the action */
  83956. source: any;
  83957. /** The X mouse cursor position at the time of the event */
  83958. pointerX: number;
  83959. /** The Y mouse cursor position at the time of the event */
  83960. pointerY: number;
  83961. /** The mesh that is currently pointed at (can be null) */
  83962. meshUnderPointer: Nullable<AbstractMesh>;
  83963. /** the original (browser) event that triggered the ActionEvent */
  83964. sourceEvent?: any;
  83965. /** additional data for the event */
  83966. additionalData?: any;
  83967. /**
  83968. * Creates a new ActionEvent
  83969. * @param source The mesh or sprite that triggered the action
  83970. * @param pointerX The X mouse cursor position at the time of the event
  83971. * @param pointerY The Y mouse cursor position at the time of the event
  83972. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83973. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83974. * @param additionalData additional data for the event
  83975. */
  83976. constructor(
  83977. /** The mesh or sprite that triggered the action */
  83978. source: any,
  83979. /** The X mouse cursor position at the time of the event */
  83980. pointerX: number,
  83981. /** The Y mouse cursor position at the time of the event */
  83982. pointerY: number,
  83983. /** The mesh that is currently pointed at (can be null) */
  83984. meshUnderPointer: Nullable<AbstractMesh>,
  83985. /** the original (browser) event that triggered the ActionEvent */
  83986. sourceEvent?: any,
  83987. /** additional data for the event */
  83988. additionalData?: any);
  83989. /**
  83990. * Helper function to auto-create an ActionEvent from a source mesh.
  83991. * @param source The source mesh that triggered the event
  83992. * @param evt The original (browser) event
  83993. * @param additionalData additional data for the event
  83994. * @returns the new ActionEvent
  83995. */
  83996. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83997. /**
  83998. * Helper function to auto-create an ActionEvent from a source sprite
  83999. * @param source The source sprite that triggered the event
  84000. * @param scene Scene associated with the sprite
  84001. * @param evt The original (browser) event
  84002. * @param additionalData additional data for the event
  84003. * @returns the new ActionEvent
  84004. */
  84005. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84006. /**
  84007. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84008. * @param scene the scene where the event occurred
  84009. * @param evt The original (browser) event
  84010. * @returns the new ActionEvent
  84011. */
  84012. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84013. /**
  84014. * Helper function to auto-create an ActionEvent from a primitive
  84015. * @param prim defines the target primitive
  84016. * @param pointerPos defines the pointer position
  84017. * @param evt The original (browser) event
  84018. * @param additionalData additional data for the event
  84019. * @returns the new ActionEvent
  84020. */
  84021. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84022. }
  84023. }
  84024. declare module BABYLON {
  84025. /**
  84026. * Abstract class used to decouple action Manager from scene and meshes.
  84027. * Do not instantiate.
  84028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84029. */
  84030. export abstract class AbstractActionManager implements IDisposable {
  84031. /** Gets the list of active triggers */
  84032. static Triggers: {
  84033. [key: string]: number;
  84034. };
  84035. /** Gets the cursor to use when hovering items */
  84036. hoverCursor: string;
  84037. /** Gets the list of actions */
  84038. actions: IAction[];
  84039. /**
  84040. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84041. */
  84042. isRecursive: boolean;
  84043. /**
  84044. * Releases all associated resources
  84045. */
  84046. abstract dispose(): void;
  84047. /**
  84048. * Does this action manager has pointer triggers
  84049. */
  84050. abstract readonly hasPointerTriggers: boolean;
  84051. /**
  84052. * Does this action manager has pick triggers
  84053. */
  84054. abstract readonly hasPickTriggers: boolean;
  84055. /**
  84056. * Process a specific trigger
  84057. * @param trigger defines the trigger to process
  84058. * @param evt defines the event details to be processed
  84059. */
  84060. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84061. /**
  84062. * Does this action manager handles actions of any of the given triggers
  84063. * @param triggers defines the triggers to be tested
  84064. * @return a boolean indicating whether one (or more) of the triggers is handled
  84065. */
  84066. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84067. /**
  84068. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84069. * speed.
  84070. * @param triggerA defines the trigger to be tested
  84071. * @param triggerB defines the trigger to be tested
  84072. * @return a boolean indicating whether one (or more) of the triggers is handled
  84073. */
  84074. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84075. /**
  84076. * Does this action manager handles actions of a given trigger
  84077. * @param trigger defines the trigger to be tested
  84078. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84079. * @return whether the trigger is handled
  84080. */
  84081. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84082. /**
  84083. * Serialize this manager to a JSON object
  84084. * @param name defines the property name to store this manager
  84085. * @returns a JSON representation of this manager
  84086. */
  84087. abstract serialize(name: string): any;
  84088. /**
  84089. * Registers an action to this action manager
  84090. * @param action defines the action to be registered
  84091. * @return the action amended (prepared) after registration
  84092. */
  84093. abstract registerAction(action: IAction): Nullable<IAction>;
  84094. /**
  84095. * Unregisters an action to this action manager
  84096. * @param action defines the action to be unregistered
  84097. * @return a boolean indicating whether the action has been unregistered
  84098. */
  84099. abstract unregisterAction(action: IAction): Boolean;
  84100. /**
  84101. * Does exist one action manager with at least one trigger
  84102. **/
  84103. static readonly HasTriggers: boolean;
  84104. /**
  84105. * Does exist one action manager with at least one pick trigger
  84106. **/
  84107. static readonly HasPickTriggers: boolean;
  84108. /**
  84109. * Does exist one action manager that handles actions of a given trigger
  84110. * @param trigger defines the trigger to be tested
  84111. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84112. **/
  84113. static HasSpecificTrigger(trigger: number): boolean;
  84114. }
  84115. }
  84116. declare module BABYLON {
  84117. /**
  84118. * Defines how a node can be built from a string name.
  84119. */
  84120. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84121. /**
  84122. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84123. */
  84124. export class Node implements IBehaviorAware<Node> {
  84125. /** @hidden */
  84126. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84127. private static _NodeConstructors;
  84128. /**
  84129. * Add a new node constructor
  84130. * @param type defines the type name of the node to construct
  84131. * @param constructorFunc defines the constructor function
  84132. */
  84133. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84134. /**
  84135. * Returns a node constructor based on type name
  84136. * @param type defines the type name
  84137. * @param name defines the new node name
  84138. * @param scene defines the hosting scene
  84139. * @param options defines optional options to transmit to constructors
  84140. * @returns the new constructor or null
  84141. */
  84142. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84143. /**
  84144. * Gets or sets the name of the node
  84145. */
  84146. name: string;
  84147. /**
  84148. * Gets or sets the id of the node
  84149. */
  84150. id: string;
  84151. /**
  84152. * Gets or sets the unique id of the node
  84153. */
  84154. uniqueId: number;
  84155. /**
  84156. * Gets or sets a string used to store user defined state for the node
  84157. */
  84158. state: string;
  84159. /**
  84160. * Gets or sets an object used to store user defined information for the node
  84161. */
  84162. metadata: any;
  84163. /**
  84164. * For internal use only. Please do not use.
  84165. */
  84166. reservedDataStore: any;
  84167. /**
  84168. * List of inspectable custom properties (used by the Inspector)
  84169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84170. */
  84171. inspectableCustomProperties: IInspectable[];
  84172. /**
  84173. * Gets or sets a boolean used to define if the node must be serialized
  84174. */
  84175. doNotSerialize: boolean;
  84176. /** @hidden */
  84177. _isDisposed: boolean;
  84178. /**
  84179. * Gets a list of Animations associated with the node
  84180. */
  84181. animations: Animation[];
  84182. protected _ranges: {
  84183. [name: string]: Nullable<AnimationRange>;
  84184. };
  84185. /**
  84186. * Callback raised when the node is ready to be used
  84187. */
  84188. onReady: (node: Node) => void;
  84189. private _isEnabled;
  84190. private _isParentEnabled;
  84191. private _isReady;
  84192. /** @hidden */
  84193. _currentRenderId: number;
  84194. private _parentUpdateId;
  84195. protected _childUpdateId: number;
  84196. /** @hidden */
  84197. _waitingParentId: Nullable<string>;
  84198. /** @hidden */
  84199. _scene: Scene;
  84200. /** @hidden */
  84201. _cache: any;
  84202. private _parentNode;
  84203. private _children;
  84204. /** @hidden */
  84205. _worldMatrix: Matrix;
  84206. /** @hidden */
  84207. _worldMatrixDeterminant: number;
  84208. /** @hidden */
  84209. private _sceneRootNodesIndex;
  84210. /**
  84211. * Gets a boolean indicating if the node has been disposed
  84212. * @returns true if the node was disposed
  84213. */
  84214. isDisposed(): boolean;
  84215. /**
  84216. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84217. * @see https://doc.babylonjs.com/how_to/parenting
  84218. */
  84219. parent: Nullable<Node>;
  84220. private addToSceneRootNodes;
  84221. private removeFromSceneRootNodes;
  84222. private _animationPropertiesOverride;
  84223. /**
  84224. * Gets or sets the animation properties override
  84225. */
  84226. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84227. /**
  84228. * Gets a string idenfifying the name of the class
  84229. * @returns "Node" string
  84230. */
  84231. getClassName(): string;
  84232. /** @hidden */
  84233. readonly _isNode: boolean;
  84234. /**
  84235. * An event triggered when the mesh is disposed
  84236. */
  84237. onDisposeObservable: Observable<Node>;
  84238. private _onDisposeObserver;
  84239. /**
  84240. * Sets a callback that will be raised when the node will be disposed
  84241. */
  84242. onDispose: () => void;
  84243. /**
  84244. * Creates a new Node
  84245. * @param name the name and id to be given to this node
  84246. * @param scene the scene this node will be added to
  84247. * @param addToRootNodes the node will be added to scene.rootNodes
  84248. */
  84249. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84250. /**
  84251. * Gets the scene of the node
  84252. * @returns a scene
  84253. */
  84254. getScene(): Scene;
  84255. /**
  84256. * Gets the engine of the node
  84257. * @returns a Engine
  84258. */
  84259. getEngine(): Engine;
  84260. private _behaviors;
  84261. /**
  84262. * Attach a behavior to the node
  84263. * @see http://doc.babylonjs.com/features/behaviour
  84264. * @param behavior defines the behavior to attach
  84265. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84266. * @returns the current Node
  84267. */
  84268. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84269. /**
  84270. * Remove an attached behavior
  84271. * @see http://doc.babylonjs.com/features/behaviour
  84272. * @param behavior defines the behavior to attach
  84273. * @returns the current Node
  84274. */
  84275. removeBehavior(behavior: Behavior<Node>): Node;
  84276. /**
  84277. * Gets the list of attached behaviors
  84278. * @see http://doc.babylonjs.com/features/behaviour
  84279. */
  84280. readonly behaviors: Behavior<Node>[];
  84281. /**
  84282. * Gets an attached behavior by name
  84283. * @param name defines the name of the behavior to look for
  84284. * @see http://doc.babylonjs.com/features/behaviour
  84285. * @returns null if behavior was not found else the requested behavior
  84286. */
  84287. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84288. /**
  84289. * Returns the latest update of the World matrix
  84290. * @returns a Matrix
  84291. */
  84292. getWorldMatrix(): Matrix;
  84293. /** @hidden */
  84294. _getWorldMatrixDeterminant(): number;
  84295. /**
  84296. * Returns directly the latest state of the mesh World matrix.
  84297. * A Matrix is returned.
  84298. */
  84299. readonly worldMatrixFromCache: Matrix;
  84300. /** @hidden */
  84301. _initCache(): void;
  84302. /** @hidden */
  84303. updateCache(force?: boolean): void;
  84304. /** @hidden */
  84305. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84306. /** @hidden */
  84307. _updateCache(ignoreParentClass?: boolean): void;
  84308. /** @hidden */
  84309. _isSynchronized(): boolean;
  84310. /** @hidden */
  84311. _markSyncedWithParent(): void;
  84312. /** @hidden */
  84313. isSynchronizedWithParent(): boolean;
  84314. /** @hidden */
  84315. isSynchronized(): boolean;
  84316. /**
  84317. * Is this node ready to be used/rendered
  84318. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84319. * @return true if the node is ready
  84320. */
  84321. isReady(completeCheck?: boolean): boolean;
  84322. /**
  84323. * Is this node enabled?
  84324. * 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
  84325. * @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
  84326. * @return whether this node (and its parent) is enabled
  84327. */
  84328. isEnabled(checkAncestors?: boolean): boolean;
  84329. /** @hidden */
  84330. protected _syncParentEnabledState(): void;
  84331. /**
  84332. * Set the enabled state of this node
  84333. * @param value defines the new enabled state
  84334. */
  84335. setEnabled(value: boolean): void;
  84336. /**
  84337. * Is this node a descendant of the given node?
  84338. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84339. * @param ancestor defines the parent node to inspect
  84340. * @returns a boolean indicating if this node is a descendant of the given node
  84341. */
  84342. isDescendantOf(ancestor: Node): boolean;
  84343. /** @hidden */
  84344. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84345. /**
  84346. * Will return all nodes that have this node as ascendant
  84347. * @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
  84348. * @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
  84349. * @return all children nodes of all types
  84350. */
  84351. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84352. /**
  84353. * Get all child-meshes of this node
  84354. * @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)
  84355. * @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
  84356. * @returns an array of AbstractMesh
  84357. */
  84358. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84359. /**
  84360. * Get all direct children of this node
  84361. * @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
  84362. * @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)
  84363. * @returns an array of Node
  84364. */
  84365. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84366. /** @hidden */
  84367. _setReady(state: boolean): void;
  84368. /**
  84369. * Get an animation by name
  84370. * @param name defines the name of the animation to look for
  84371. * @returns null if not found else the requested animation
  84372. */
  84373. getAnimationByName(name: string): Nullable<Animation>;
  84374. /**
  84375. * Creates an animation range for this node
  84376. * @param name defines the name of the range
  84377. * @param from defines the starting key
  84378. * @param to defines the end key
  84379. */
  84380. createAnimationRange(name: string, from: number, to: number): void;
  84381. /**
  84382. * Delete a specific animation range
  84383. * @param name defines the name of the range to delete
  84384. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84385. */
  84386. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84387. /**
  84388. * Get an animation range by name
  84389. * @param name defines the name of the animation range to look for
  84390. * @returns null if not found else the requested animation range
  84391. */
  84392. getAnimationRange(name: string): Nullable<AnimationRange>;
  84393. /**
  84394. * Gets the list of all animation ranges defined on this node
  84395. * @returns an array
  84396. */
  84397. getAnimationRanges(): Nullable<AnimationRange>[];
  84398. /**
  84399. * Will start the animation sequence
  84400. * @param name defines the range frames for animation sequence
  84401. * @param loop defines if the animation should loop (false by default)
  84402. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84403. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84404. * @returns the object created for this animation. If range does not exist, it will return null
  84405. */
  84406. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84407. /**
  84408. * Serialize animation ranges into a JSON compatible object
  84409. * @returns serialization object
  84410. */
  84411. serializeAnimationRanges(): any;
  84412. /**
  84413. * Computes the world matrix of the node
  84414. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84415. * @returns the world matrix
  84416. */
  84417. computeWorldMatrix(force?: boolean): Matrix;
  84418. /**
  84419. * Releases resources associated with this node.
  84420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84422. */
  84423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84424. /**
  84425. * Parse animation range data from a serialization object and store them into a given node
  84426. * @param node defines where to store the animation ranges
  84427. * @param parsedNode defines the serialization object to read data from
  84428. * @param scene defines the hosting scene
  84429. */
  84430. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84431. }
  84432. }
  84433. declare module BABYLON {
  84434. /**
  84435. * Class used to store any kind of animation
  84436. */
  84437. export class Animation {
  84438. /**Name of the animation */
  84439. name: string;
  84440. /**Property to animate */
  84441. targetProperty: string;
  84442. /**The frames per second of the animation */
  84443. framePerSecond: number;
  84444. /**The data type of the animation */
  84445. dataType: number;
  84446. /**The loop mode of the animation */
  84447. loopMode?: number | undefined;
  84448. /**Specifies if blending should be enabled */
  84449. enableBlending?: boolean | undefined;
  84450. /**
  84451. * Use matrix interpolation instead of using direct key value when animating matrices
  84452. */
  84453. static AllowMatricesInterpolation: boolean;
  84454. /**
  84455. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84456. */
  84457. static AllowMatrixDecomposeForInterpolation: boolean;
  84458. /**
  84459. * Stores the key frames of the animation
  84460. */
  84461. private _keys;
  84462. /**
  84463. * Stores the easing function of the animation
  84464. */
  84465. private _easingFunction;
  84466. /**
  84467. * @hidden Internal use only
  84468. */
  84469. _runtimeAnimations: RuntimeAnimation[];
  84470. /**
  84471. * The set of event that will be linked to this animation
  84472. */
  84473. private _events;
  84474. /**
  84475. * Stores an array of target property paths
  84476. */
  84477. targetPropertyPath: string[];
  84478. /**
  84479. * Stores the blending speed of the animation
  84480. */
  84481. blendingSpeed: number;
  84482. /**
  84483. * Stores the animation ranges for the animation
  84484. */
  84485. private _ranges;
  84486. /**
  84487. * @hidden Internal use
  84488. */
  84489. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84490. /**
  84491. * Sets up an animation
  84492. * @param property The property to animate
  84493. * @param animationType The animation type to apply
  84494. * @param framePerSecond The frames per second of the animation
  84495. * @param easingFunction The easing function used in the animation
  84496. * @returns The created animation
  84497. */
  84498. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84499. /**
  84500. * Create and start an animation on a node
  84501. * @param name defines the name of the global animation that will be run on all nodes
  84502. * @param node defines the root node where the animation will take place
  84503. * @param targetProperty defines property to animate
  84504. * @param framePerSecond defines the number of frame per second yo use
  84505. * @param totalFrame defines the number of frames in total
  84506. * @param from defines the initial value
  84507. * @param to defines the final value
  84508. * @param loopMode defines which loop mode you want to use (off by default)
  84509. * @param easingFunction defines the easing function to use (linear by default)
  84510. * @param onAnimationEnd defines the callback to call when animation end
  84511. * @returns the animatable created for this animation
  84512. */
  84513. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84514. /**
  84515. * Create and start an animation on a node and its descendants
  84516. * @param name defines the name of the global animation that will be run on all nodes
  84517. * @param node defines the root node where the animation will take place
  84518. * @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
  84519. * @param targetProperty defines property to animate
  84520. * @param framePerSecond defines the number of frame per second to use
  84521. * @param totalFrame defines the number of frames in total
  84522. * @param from defines the initial value
  84523. * @param to defines the final value
  84524. * @param loopMode defines which loop mode you want to use (off by default)
  84525. * @param easingFunction defines the easing function to use (linear by default)
  84526. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84527. * @returns the list of animatables created for all nodes
  84528. * @example https://www.babylonjs-playground.com/#MH0VLI
  84529. */
  84530. 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[]>;
  84531. /**
  84532. * Creates a new animation, merges it with the existing animations and starts it
  84533. * @param name Name of the animation
  84534. * @param node Node which contains the scene that begins the animations
  84535. * @param targetProperty Specifies which property to animate
  84536. * @param framePerSecond The frames per second of the animation
  84537. * @param totalFrame The total number of frames
  84538. * @param from The frame at the beginning of the animation
  84539. * @param to The frame at the end of the animation
  84540. * @param loopMode Specifies the loop mode of the animation
  84541. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84542. * @param onAnimationEnd Callback to run once the animation is complete
  84543. * @returns Nullable animation
  84544. */
  84545. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84546. /**
  84547. * Transition property of an host to the target Value
  84548. * @param property The property to transition
  84549. * @param targetValue The target Value of the property
  84550. * @param host The object where the property to animate belongs
  84551. * @param scene Scene used to run the animation
  84552. * @param frameRate Framerate (in frame/s) to use
  84553. * @param transition The transition type we want to use
  84554. * @param duration The duration of the animation, in milliseconds
  84555. * @param onAnimationEnd Callback trigger at the end of the animation
  84556. * @returns Nullable animation
  84557. */
  84558. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84559. /**
  84560. * Return the array of runtime animations currently using this animation
  84561. */
  84562. readonly runtimeAnimations: RuntimeAnimation[];
  84563. /**
  84564. * Specifies if any of the runtime animations are currently running
  84565. */
  84566. readonly hasRunningRuntimeAnimations: boolean;
  84567. /**
  84568. * Initializes the animation
  84569. * @param name Name of the animation
  84570. * @param targetProperty Property to animate
  84571. * @param framePerSecond The frames per second of the animation
  84572. * @param dataType The data type of the animation
  84573. * @param loopMode The loop mode of the animation
  84574. * @param enableBlending Specifies if blending should be enabled
  84575. */
  84576. constructor(
  84577. /**Name of the animation */
  84578. name: string,
  84579. /**Property to animate */
  84580. targetProperty: string,
  84581. /**The frames per second of the animation */
  84582. framePerSecond: number,
  84583. /**The data type of the animation */
  84584. dataType: number,
  84585. /**The loop mode of the animation */
  84586. loopMode?: number | undefined,
  84587. /**Specifies if blending should be enabled */
  84588. enableBlending?: boolean | undefined);
  84589. /**
  84590. * Converts the animation to a string
  84591. * @param fullDetails support for multiple levels of logging within scene loading
  84592. * @returns String form of the animation
  84593. */
  84594. toString(fullDetails?: boolean): string;
  84595. /**
  84596. * Add an event to this animation
  84597. * @param event Event to add
  84598. */
  84599. addEvent(event: AnimationEvent): void;
  84600. /**
  84601. * Remove all events found at the given frame
  84602. * @param frame The frame to remove events from
  84603. */
  84604. removeEvents(frame: number): void;
  84605. /**
  84606. * Retrieves all the events from the animation
  84607. * @returns Events from the animation
  84608. */
  84609. getEvents(): AnimationEvent[];
  84610. /**
  84611. * Creates an animation range
  84612. * @param name Name of the animation range
  84613. * @param from Starting frame of the animation range
  84614. * @param to Ending frame of the animation
  84615. */
  84616. createRange(name: string, from: number, to: number): void;
  84617. /**
  84618. * Deletes an animation range by name
  84619. * @param name Name of the animation range to delete
  84620. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84621. */
  84622. deleteRange(name: string, deleteFrames?: boolean): void;
  84623. /**
  84624. * Gets the animation range by name, or null if not defined
  84625. * @param name Name of the animation range
  84626. * @returns Nullable animation range
  84627. */
  84628. getRange(name: string): Nullable<AnimationRange>;
  84629. /**
  84630. * Gets the key frames from the animation
  84631. * @returns The key frames of the animation
  84632. */
  84633. getKeys(): Array<IAnimationKey>;
  84634. /**
  84635. * Gets the highest frame rate of the animation
  84636. * @returns Highest frame rate of the animation
  84637. */
  84638. getHighestFrame(): number;
  84639. /**
  84640. * Gets the easing function of the animation
  84641. * @returns Easing function of the animation
  84642. */
  84643. getEasingFunction(): IEasingFunction;
  84644. /**
  84645. * Sets the easing function of the animation
  84646. * @param easingFunction A custom mathematical formula for animation
  84647. */
  84648. setEasingFunction(easingFunction: EasingFunction): void;
  84649. /**
  84650. * Interpolates a scalar linearly
  84651. * @param startValue Start value of the animation curve
  84652. * @param endValue End value of the animation curve
  84653. * @param gradient Scalar amount to interpolate
  84654. * @returns Interpolated scalar value
  84655. */
  84656. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84657. /**
  84658. * Interpolates a scalar cubically
  84659. * @param startValue Start value of the animation curve
  84660. * @param outTangent End tangent of the animation
  84661. * @param endValue End value of the animation curve
  84662. * @param inTangent Start tangent of the animation curve
  84663. * @param gradient Scalar amount to interpolate
  84664. * @returns Interpolated scalar value
  84665. */
  84666. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84667. /**
  84668. * Interpolates a quaternion using a spherical linear interpolation
  84669. * @param startValue Start value of the animation curve
  84670. * @param endValue End value of the animation curve
  84671. * @param gradient Scalar amount to interpolate
  84672. * @returns Interpolated quaternion value
  84673. */
  84674. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84675. /**
  84676. * Interpolates a quaternion cubically
  84677. * @param startValue Start value of the animation curve
  84678. * @param outTangent End tangent of the animation curve
  84679. * @param endValue End value of the animation curve
  84680. * @param inTangent Start tangent of the animation curve
  84681. * @param gradient Scalar amount to interpolate
  84682. * @returns Interpolated quaternion value
  84683. */
  84684. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84685. /**
  84686. * Interpolates a Vector3 linearl
  84687. * @param startValue Start value of the animation curve
  84688. * @param endValue End value of the animation curve
  84689. * @param gradient Scalar amount to interpolate
  84690. * @returns Interpolated scalar value
  84691. */
  84692. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84693. /**
  84694. * Interpolates a Vector3 cubically
  84695. * @param startValue Start value of the animation curve
  84696. * @param outTangent End tangent of the animation
  84697. * @param endValue End value of the animation curve
  84698. * @param inTangent Start tangent of the animation curve
  84699. * @param gradient Scalar amount to interpolate
  84700. * @returns InterpolatedVector3 value
  84701. */
  84702. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84703. /**
  84704. * Interpolates a Vector2 linearly
  84705. * @param startValue Start value of the animation curve
  84706. * @param endValue End value of the animation curve
  84707. * @param gradient Scalar amount to interpolate
  84708. * @returns Interpolated Vector2 value
  84709. */
  84710. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84711. /**
  84712. * Interpolates a Vector2 cubically
  84713. * @param startValue Start value of the animation curve
  84714. * @param outTangent End tangent of the animation
  84715. * @param endValue End value of the animation curve
  84716. * @param inTangent Start tangent of the animation curve
  84717. * @param gradient Scalar amount to interpolate
  84718. * @returns Interpolated Vector2 value
  84719. */
  84720. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84721. /**
  84722. * Interpolates a size linearly
  84723. * @param startValue Start value of the animation curve
  84724. * @param endValue End value of the animation curve
  84725. * @param gradient Scalar amount to interpolate
  84726. * @returns Interpolated Size value
  84727. */
  84728. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84729. /**
  84730. * Interpolates a Color3 linearly
  84731. * @param startValue Start value of the animation curve
  84732. * @param endValue End value of the animation curve
  84733. * @param gradient Scalar amount to interpolate
  84734. * @returns Interpolated Color3 value
  84735. */
  84736. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84737. /**
  84738. * @hidden Internal use only
  84739. */
  84740. _getKeyValue(value: any): any;
  84741. /**
  84742. * @hidden Internal use only
  84743. */
  84744. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84745. /**
  84746. * Defines the function to use to interpolate matrices
  84747. * @param startValue defines the start matrix
  84748. * @param endValue defines the end matrix
  84749. * @param gradient defines the gradient between both matrices
  84750. * @param result defines an optional target matrix where to store the interpolation
  84751. * @returns the interpolated matrix
  84752. */
  84753. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84754. /**
  84755. * Makes a copy of the animation
  84756. * @returns Cloned animation
  84757. */
  84758. clone(): Animation;
  84759. /**
  84760. * Sets the key frames of the animation
  84761. * @param values The animation key frames to set
  84762. */
  84763. setKeys(values: Array<IAnimationKey>): void;
  84764. /**
  84765. * Serializes the animation to an object
  84766. * @returns Serialized object
  84767. */
  84768. serialize(): any;
  84769. /**
  84770. * Float animation type
  84771. */
  84772. private static _ANIMATIONTYPE_FLOAT;
  84773. /**
  84774. * Vector3 animation type
  84775. */
  84776. private static _ANIMATIONTYPE_VECTOR3;
  84777. /**
  84778. * Quaternion animation type
  84779. */
  84780. private static _ANIMATIONTYPE_QUATERNION;
  84781. /**
  84782. * Matrix animation type
  84783. */
  84784. private static _ANIMATIONTYPE_MATRIX;
  84785. /**
  84786. * Color3 animation type
  84787. */
  84788. private static _ANIMATIONTYPE_COLOR3;
  84789. /**
  84790. * Vector2 animation type
  84791. */
  84792. private static _ANIMATIONTYPE_VECTOR2;
  84793. /**
  84794. * Size animation type
  84795. */
  84796. private static _ANIMATIONTYPE_SIZE;
  84797. /**
  84798. * Relative Loop Mode
  84799. */
  84800. private static _ANIMATIONLOOPMODE_RELATIVE;
  84801. /**
  84802. * Cycle Loop Mode
  84803. */
  84804. private static _ANIMATIONLOOPMODE_CYCLE;
  84805. /**
  84806. * Constant Loop Mode
  84807. */
  84808. private static _ANIMATIONLOOPMODE_CONSTANT;
  84809. /**
  84810. * Get the float animation type
  84811. */
  84812. static readonly ANIMATIONTYPE_FLOAT: number;
  84813. /**
  84814. * Get the Vector3 animation type
  84815. */
  84816. static readonly ANIMATIONTYPE_VECTOR3: number;
  84817. /**
  84818. * Get the Vector2 animation type
  84819. */
  84820. static readonly ANIMATIONTYPE_VECTOR2: number;
  84821. /**
  84822. * Get the Size animation type
  84823. */
  84824. static readonly ANIMATIONTYPE_SIZE: number;
  84825. /**
  84826. * Get the Quaternion animation type
  84827. */
  84828. static readonly ANIMATIONTYPE_QUATERNION: number;
  84829. /**
  84830. * Get the Matrix animation type
  84831. */
  84832. static readonly ANIMATIONTYPE_MATRIX: number;
  84833. /**
  84834. * Get the Color3 animation type
  84835. */
  84836. static readonly ANIMATIONTYPE_COLOR3: number;
  84837. /**
  84838. * Get the Relative Loop Mode
  84839. */
  84840. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84841. /**
  84842. * Get the Cycle Loop Mode
  84843. */
  84844. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84845. /**
  84846. * Get the Constant Loop Mode
  84847. */
  84848. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84849. /** @hidden */
  84850. static _UniversalLerp(left: any, right: any, amount: number): any;
  84851. /**
  84852. * Parses an animation object and creates an animation
  84853. * @param parsedAnimation Parsed animation object
  84854. * @returns Animation object
  84855. */
  84856. static Parse(parsedAnimation: any): Animation;
  84857. /**
  84858. * Appends the serialized animations from the source animations
  84859. * @param source Source containing the animations
  84860. * @param destination Target to store the animations
  84861. */
  84862. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84863. }
  84864. }
  84865. declare module BABYLON {
  84866. /**
  84867. * Base class of all the textures in babylon.
  84868. * It groups all the common properties the materials, post process, lights... might need
  84869. * in order to make a correct use of the texture.
  84870. */
  84871. export class BaseTexture implements IAnimatable {
  84872. /**
  84873. * Default anisotropic filtering level for the application.
  84874. * It is set to 4 as a good tradeoff between perf and quality.
  84875. */
  84876. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84877. /**
  84878. * Gets or sets the unique id of the texture
  84879. */
  84880. uniqueId: number;
  84881. /**
  84882. * Define the name of the texture.
  84883. */
  84884. name: string;
  84885. /**
  84886. * Gets or sets an object used to store user defined information.
  84887. */
  84888. metadata: any;
  84889. /**
  84890. * For internal use only. Please do not use.
  84891. */
  84892. reservedDataStore: any;
  84893. private _hasAlpha;
  84894. /**
  84895. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84896. */
  84897. hasAlpha: boolean;
  84898. /**
  84899. * Defines if the alpha value should be determined via the rgb values.
  84900. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84901. */
  84902. getAlphaFromRGB: boolean;
  84903. /**
  84904. * Intensity or strength of the texture.
  84905. * It is commonly used by materials to fine tune the intensity of the texture
  84906. */
  84907. level: number;
  84908. /**
  84909. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84910. * This is part of the texture as textures usually maps to one uv set.
  84911. */
  84912. coordinatesIndex: number;
  84913. private _coordinatesMode;
  84914. /**
  84915. * How a texture is mapped.
  84916. *
  84917. * | Value | Type | Description |
  84918. * | ----- | ----------------------------------- | ----------- |
  84919. * | 0 | EXPLICIT_MODE | |
  84920. * | 1 | SPHERICAL_MODE | |
  84921. * | 2 | PLANAR_MODE | |
  84922. * | 3 | CUBIC_MODE | |
  84923. * | 4 | PROJECTION_MODE | |
  84924. * | 5 | SKYBOX_MODE | |
  84925. * | 6 | INVCUBIC_MODE | |
  84926. * | 7 | EQUIRECTANGULAR_MODE | |
  84927. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84928. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84929. */
  84930. coordinatesMode: number;
  84931. /**
  84932. * | Value | Type | Description |
  84933. * | ----- | ------------------ | ----------- |
  84934. * | 0 | CLAMP_ADDRESSMODE | |
  84935. * | 1 | WRAP_ADDRESSMODE | |
  84936. * | 2 | MIRROR_ADDRESSMODE | |
  84937. */
  84938. wrapU: number;
  84939. /**
  84940. * | Value | Type | Description |
  84941. * | ----- | ------------------ | ----------- |
  84942. * | 0 | CLAMP_ADDRESSMODE | |
  84943. * | 1 | WRAP_ADDRESSMODE | |
  84944. * | 2 | MIRROR_ADDRESSMODE | |
  84945. */
  84946. wrapV: number;
  84947. /**
  84948. * | Value | Type | Description |
  84949. * | ----- | ------------------ | ----------- |
  84950. * | 0 | CLAMP_ADDRESSMODE | |
  84951. * | 1 | WRAP_ADDRESSMODE | |
  84952. * | 2 | MIRROR_ADDRESSMODE | |
  84953. */
  84954. wrapR: number;
  84955. /**
  84956. * With compliant hardware and browser (supporting anisotropic filtering)
  84957. * this defines the level of anisotropic filtering in the texture.
  84958. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84959. */
  84960. anisotropicFilteringLevel: number;
  84961. /**
  84962. * Define if the texture is a cube texture or if false a 2d texture.
  84963. */
  84964. isCube: boolean;
  84965. /**
  84966. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84967. */
  84968. is3D: boolean;
  84969. /**
  84970. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84971. * HDR texture are usually stored in linear space.
  84972. * This only impacts the PBR and Background materials
  84973. */
  84974. gammaSpace: boolean;
  84975. /**
  84976. * Gets whether or not the texture contains RGBD data.
  84977. */
  84978. readonly isRGBD: boolean;
  84979. /**
  84980. * Is Z inverted in the texture (useful in a cube texture).
  84981. */
  84982. invertZ: boolean;
  84983. /**
  84984. * Are mip maps generated for this texture or not.
  84985. */
  84986. readonly noMipmap: boolean;
  84987. /**
  84988. * @hidden
  84989. */
  84990. lodLevelInAlpha: boolean;
  84991. /**
  84992. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84993. */
  84994. lodGenerationOffset: number;
  84995. /**
  84996. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84997. */
  84998. lodGenerationScale: number;
  84999. /**
  85000. * Define if the texture is a render target.
  85001. */
  85002. isRenderTarget: boolean;
  85003. /**
  85004. * Define the unique id of the texture in the scene.
  85005. */
  85006. readonly uid: string;
  85007. /**
  85008. * Return a string representation of the texture.
  85009. * @returns the texture as a string
  85010. */
  85011. toString(): string;
  85012. /**
  85013. * Get the class name of the texture.
  85014. * @returns "BaseTexture"
  85015. */
  85016. getClassName(): string;
  85017. /**
  85018. * Define the list of animation attached to the texture.
  85019. */
  85020. animations: Animation[];
  85021. /**
  85022. * An event triggered when the texture is disposed.
  85023. */
  85024. onDisposeObservable: Observable<BaseTexture>;
  85025. private _onDisposeObserver;
  85026. /**
  85027. * Callback triggered when the texture has been disposed.
  85028. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85029. */
  85030. onDispose: () => void;
  85031. /**
  85032. * Define the current state of the loading sequence when in delayed load mode.
  85033. */
  85034. delayLoadState: number;
  85035. private _scene;
  85036. /** @hidden */
  85037. _texture: Nullable<InternalTexture>;
  85038. private _uid;
  85039. /**
  85040. * Define if the texture is preventinga material to render or not.
  85041. * If not and the texture is not ready, the engine will use a default black texture instead.
  85042. */
  85043. readonly isBlocking: boolean;
  85044. /**
  85045. * Instantiates a new BaseTexture.
  85046. * Base class of all the textures in babylon.
  85047. * It groups all the common properties the materials, post process, lights... might need
  85048. * in order to make a correct use of the texture.
  85049. * @param scene Define the scene the texture blongs to
  85050. */
  85051. constructor(scene: Nullable<Scene>);
  85052. /**
  85053. * Get the scene the texture belongs to.
  85054. * @returns the scene or null if undefined
  85055. */
  85056. getScene(): Nullable<Scene>;
  85057. /**
  85058. * Get the texture transform matrix used to offset tile the texture for istance.
  85059. * @returns the transformation matrix
  85060. */
  85061. getTextureMatrix(): Matrix;
  85062. /**
  85063. * Get the texture reflection matrix used to rotate/transform the reflection.
  85064. * @returns the reflection matrix
  85065. */
  85066. getReflectionTextureMatrix(): Matrix;
  85067. /**
  85068. * Get the underlying lower level texture from Babylon.
  85069. * @returns the insternal texture
  85070. */
  85071. getInternalTexture(): Nullable<InternalTexture>;
  85072. /**
  85073. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85074. * @returns true if ready or not blocking
  85075. */
  85076. isReadyOrNotBlocking(): boolean;
  85077. /**
  85078. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85079. * @returns true if fully ready
  85080. */
  85081. isReady(): boolean;
  85082. private _cachedSize;
  85083. /**
  85084. * Get the size of the texture.
  85085. * @returns the texture size.
  85086. */
  85087. getSize(): ISize;
  85088. /**
  85089. * Get the base size of the texture.
  85090. * It can be different from the size if the texture has been resized for POT for instance
  85091. * @returns the base size
  85092. */
  85093. getBaseSize(): ISize;
  85094. /**
  85095. * Update the sampling mode of the texture.
  85096. * Default is Trilinear mode.
  85097. *
  85098. * | Value | Type | Description |
  85099. * | ----- | ------------------ | ----------- |
  85100. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85101. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85102. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85103. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85104. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85105. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85106. * | 7 | NEAREST_LINEAR | |
  85107. * | 8 | NEAREST_NEAREST | |
  85108. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85109. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85110. * | 11 | LINEAR_LINEAR | |
  85111. * | 12 | LINEAR_NEAREST | |
  85112. *
  85113. * > _mag_: magnification filter (close to the viewer)
  85114. * > _min_: minification filter (far from the viewer)
  85115. * > _mip_: filter used between mip map levels
  85116. *@param samplingMode Define the new sampling mode of the texture
  85117. */
  85118. updateSamplingMode(samplingMode: number): void;
  85119. /**
  85120. * Scales the texture if is `canRescale()`
  85121. * @param ratio the resize factor we want to use to rescale
  85122. */
  85123. scale(ratio: number): void;
  85124. /**
  85125. * Get if the texture can rescale.
  85126. */
  85127. readonly canRescale: boolean;
  85128. /** @hidden */
  85129. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85130. /** @hidden */
  85131. _rebuild(): void;
  85132. /**
  85133. * Triggers the load sequence in delayed load mode.
  85134. */
  85135. delayLoad(): void;
  85136. /**
  85137. * Clones the texture.
  85138. * @returns the cloned texture
  85139. */
  85140. clone(): Nullable<BaseTexture>;
  85141. /**
  85142. * Get the texture underlying type (INT, FLOAT...)
  85143. */
  85144. readonly textureType: number;
  85145. /**
  85146. * Get the texture underlying format (RGB, RGBA...)
  85147. */
  85148. readonly textureFormat: number;
  85149. /**
  85150. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85151. * This will returns an RGBA array buffer containing either in values (0-255) or
  85152. * float values (0-1) depending of the underlying buffer type.
  85153. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85154. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85155. * @param buffer defines a user defined buffer to fill with data (can be null)
  85156. * @returns The Array buffer containing the pixels data.
  85157. */
  85158. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85159. /**
  85160. * Release and destroy the underlying lower level texture aka internalTexture.
  85161. */
  85162. releaseInternalTexture(): void;
  85163. /**
  85164. * Get the polynomial representation of the texture data.
  85165. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85166. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85167. */
  85168. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85169. /** @hidden */
  85170. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85171. /** @hidden */
  85172. readonly _lodTextureMid: Nullable<BaseTexture>;
  85173. /** @hidden */
  85174. readonly _lodTextureLow: Nullable<BaseTexture>;
  85175. /**
  85176. * Dispose the texture and release its associated resources.
  85177. */
  85178. dispose(): void;
  85179. /**
  85180. * Serialize the texture into a JSON representation that can be parsed later on.
  85181. * @returns the JSON representation of the texture
  85182. */
  85183. serialize(): any;
  85184. /**
  85185. * Helper function to be called back once a list of texture contains only ready textures.
  85186. * @param textures Define the list of textures to wait for
  85187. * @param callback Define the callback triggered once the entire list will be ready
  85188. */
  85189. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85190. }
  85191. }
  85192. declare module BABYLON {
  85193. /**
  85194. * Uniform buffer objects.
  85195. *
  85196. * Handles blocks of uniform on the GPU.
  85197. *
  85198. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85199. *
  85200. * For more information, please refer to :
  85201. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85202. */
  85203. export class UniformBuffer {
  85204. private _engine;
  85205. private _buffer;
  85206. private _data;
  85207. private _bufferData;
  85208. private _dynamic?;
  85209. private _uniformLocations;
  85210. private _uniformSizes;
  85211. private _uniformLocationPointer;
  85212. private _needSync;
  85213. private _noUBO;
  85214. private _currentEffect;
  85215. private static _MAX_UNIFORM_SIZE;
  85216. private static _tempBuffer;
  85217. /**
  85218. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85219. * This is dynamic to allow compat with webgl 1 and 2.
  85220. * You will need to pass the name of the uniform as well as the value.
  85221. */
  85222. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85223. /**
  85224. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85225. * This is dynamic to allow compat with webgl 1 and 2.
  85226. * You will need to pass the name of the uniform as well as the value.
  85227. */
  85228. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85229. /**
  85230. * Lambda to Update a single float in a uniform buffer.
  85231. * This is dynamic to allow compat with webgl 1 and 2.
  85232. * You will need to pass the name of the uniform as well as the value.
  85233. */
  85234. updateFloat: (name: string, x: number) => void;
  85235. /**
  85236. * Lambda to Update a vec2 of float in a uniform buffer.
  85237. * This is dynamic to allow compat with webgl 1 and 2.
  85238. * You will need to pass the name of the uniform as well as the value.
  85239. */
  85240. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85241. /**
  85242. * Lambda to Update a vec3 of float in a uniform buffer.
  85243. * This is dynamic to allow compat with webgl 1 and 2.
  85244. * You will need to pass the name of the uniform as well as the value.
  85245. */
  85246. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85247. /**
  85248. * Lambda to Update a vec4 of float in a uniform buffer.
  85249. * This is dynamic to allow compat with webgl 1 and 2.
  85250. * You will need to pass the name of the uniform as well as the value.
  85251. */
  85252. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85253. /**
  85254. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85255. * This is dynamic to allow compat with webgl 1 and 2.
  85256. * You will need to pass the name of the uniform as well as the value.
  85257. */
  85258. updateMatrix: (name: string, mat: Matrix) => void;
  85259. /**
  85260. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85261. * This is dynamic to allow compat with webgl 1 and 2.
  85262. * You will need to pass the name of the uniform as well as the value.
  85263. */
  85264. updateVector3: (name: string, vector: Vector3) => void;
  85265. /**
  85266. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85267. * This is dynamic to allow compat with webgl 1 and 2.
  85268. * You will need to pass the name of the uniform as well as the value.
  85269. */
  85270. updateVector4: (name: string, vector: Vector4) => void;
  85271. /**
  85272. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85273. * This is dynamic to allow compat with webgl 1 and 2.
  85274. * You will need to pass the name of the uniform as well as the value.
  85275. */
  85276. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85277. /**
  85278. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85279. * This is dynamic to allow compat with webgl 1 and 2.
  85280. * You will need to pass the name of the uniform as well as the value.
  85281. */
  85282. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85283. /**
  85284. * Instantiates a new Uniform buffer objects.
  85285. *
  85286. * Handles blocks of uniform on the GPU.
  85287. *
  85288. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85289. *
  85290. * For more information, please refer to :
  85291. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85292. * @param engine Define the engine the buffer is associated with
  85293. * @param data Define the data contained in the buffer
  85294. * @param dynamic Define if the buffer is updatable
  85295. */
  85296. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85297. /**
  85298. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85299. * or just falling back on setUniformXXX calls.
  85300. */
  85301. readonly useUbo: boolean;
  85302. /**
  85303. * Indicates if the WebGL underlying uniform buffer is in sync
  85304. * with the javascript cache data.
  85305. */
  85306. readonly isSync: boolean;
  85307. /**
  85308. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85309. * Also, a dynamic UniformBuffer will disable cache verification and always
  85310. * update the underlying WebGL uniform buffer to the GPU.
  85311. * @returns if Dynamic, otherwise false
  85312. */
  85313. isDynamic(): boolean;
  85314. /**
  85315. * The data cache on JS side.
  85316. * @returns the underlying data as a float array
  85317. */
  85318. getData(): Float32Array;
  85319. /**
  85320. * The underlying WebGL Uniform buffer.
  85321. * @returns the webgl buffer
  85322. */
  85323. getBuffer(): Nullable<WebGLBuffer>;
  85324. /**
  85325. * std140 layout specifies how to align data within an UBO structure.
  85326. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85327. * for specs.
  85328. */
  85329. private _fillAlignment;
  85330. /**
  85331. * Adds an uniform in the buffer.
  85332. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85333. * for the layout to be correct !
  85334. * @param name Name of the uniform, as used in the uniform block in the shader.
  85335. * @param size Data size, or data directly.
  85336. */
  85337. addUniform(name: string, size: number | number[]): void;
  85338. /**
  85339. * Adds a Matrix 4x4 to the uniform buffer.
  85340. * @param name Name of the uniform, as used in the uniform block in the shader.
  85341. * @param mat A 4x4 matrix.
  85342. */
  85343. addMatrix(name: string, mat: Matrix): void;
  85344. /**
  85345. * Adds a vec2 to the uniform buffer.
  85346. * @param name Name of the uniform, as used in the uniform block in the shader.
  85347. * @param x Define the x component value of the vec2
  85348. * @param y Define the y component value of the vec2
  85349. */
  85350. addFloat2(name: string, x: number, y: number): void;
  85351. /**
  85352. * Adds a vec3 to the uniform buffer.
  85353. * @param name Name of the uniform, as used in the uniform block in the shader.
  85354. * @param x Define the x component value of the vec3
  85355. * @param y Define the y component value of the vec3
  85356. * @param z Define the z component value of the vec3
  85357. */
  85358. addFloat3(name: string, x: number, y: number, z: number): void;
  85359. /**
  85360. * Adds a vec3 to the uniform buffer.
  85361. * @param name Name of the uniform, as used in the uniform block in the shader.
  85362. * @param color Define the vec3 from a Color
  85363. */
  85364. addColor3(name: string, color: Color3): void;
  85365. /**
  85366. * Adds a vec4 to the uniform buffer.
  85367. * @param name Name of the uniform, as used in the uniform block in the shader.
  85368. * @param color Define the rgb components from a Color
  85369. * @param alpha Define the a component of the vec4
  85370. */
  85371. addColor4(name: string, color: Color3, alpha: number): void;
  85372. /**
  85373. * Adds a vec3 to the uniform buffer.
  85374. * @param name Name of the uniform, as used in the uniform block in the shader.
  85375. * @param vector Define the vec3 components from a Vector
  85376. */
  85377. addVector3(name: string, vector: Vector3): void;
  85378. /**
  85379. * Adds a Matrix 3x3 to the uniform buffer.
  85380. * @param name Name of the uniform, as used in the uniform block in the shader.
  85381. */
  85382. addMatrix3x3(name: string): void;
  85383. /**
  85384. * Adds a Matrix 2x2 to the uniform buffer.
  85385. * @param name Name of the uniform, as used in the uniform block in the shader.
  85386. */
  85387. addMatrix2x2(name: string): void;
  85388. /**
  85389. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85390. */
  85391. create(): void;
  85392. /** @hidden */
  85393. _rebuild(): void;
  85394. /**
  85395. * Updates the WebGL Uniform Buffer on the GPU.
  85396. * If the `dynamic` flag is set to true, no cache comparison is done.
  85397. * Otherwise, the buffer will be updated only if the cache differs.
  85398. */
  85399. update(): void;
  85400. /**
  85401. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85402. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85403. * @param data Define the flattened data
  85404. * @param size Define the size of the data.
  85405. */
  85406. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85407. private _updateMatrix3x3ForUniform;
  85408. private _updateMatrix3x3ForEffect;
  85409. private _updateMatrix2x2ForEffect;
  85410. private _updateMatrix2x2ForUniform;
  85411. private _updateFloatForEffect;
  85412. private _updateFloatForUniform;
  85413. private _updateFloat2ForEffect;
  85414. private _updateFloat2ForUniform;
  85415. private _updateFloat3ForEffect;
  85416. private _updateFloat3ForUniform;
  85417. private _updateFloat4ForEffect;
  85418. private _updateFloat4ForUniform;
  85419. private _updateMatrixForEffect;
  85420. private _updateMatrixForUniform;
  85421. private _updateVector3ForEffect;
  85422. private _updateVector3ForUniform;
  85423. private _updateVector4ForEffect;
  85424. private _updateVector4ForUniform;
  85425. private _updateColor3ForEffect;
  85426. private _updateColor3ForUniform;
  85427. private _updateColor4ForEffect;
  85428. private _updateColor4ForUniform;
  85429. /**
  85430. * Sets a sampler uniform on the effect.
  85431. * @param name Define the name of the sampler.
  85432. * @param texture Define the texture to set in the sampler
  85433. */
  85434. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85435. /**
  85436. * Directly updates the value of the uniform in the cache AND on the GPU.
  85437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85438. * @param data Define the flattened data
  85439. */
  85440. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85441. /**
  85442. * Binds this uniform buffer to an effect.
  85443. * @param effect Define the effect to bind the buffer to
  85444. * @param name Name of the uniform block in the shader.
  85445. */
  85446. bindToEffect(effect: Effect, name: string): void;
  85447. /**
  85448. * Disposes the uniform buffer.
  85449. */
  85450. dispose(): void;
  85451. }
  85452. }
  85453. declare module BABYLON {
  85454. /**
  85455. * This represents the required contract to create a new type of texture loader.
  85456. */
  85457. export interface IInternalTextureLoader {
  85458. /**
  85459. * Defines wether the loader supports cascade loading the different faces.
  85460. */
  85461. supportCascades: boolean;
  85462. /**
  85463. * This returns if the loader support the current file information.
  85464. * @param extension defines the file extension of the file being loaded
  85465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85466. * @param fallback defines the fallback internal texture if any
  85467. * @param isBase64 defines whether the texture is encoded as a base64
  85468. * @param isBuffer defines whether the texture data are stored as a buffer
  85469. * @returns true if the loader can load the specified file
  85470. */
  85471. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85472. /**
  85473. * Transform the url before loading if required.
  85474. * @param rootUrl the url of the texture
  85475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85476. * @returns the transformed texture
  85477. */
  85478. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85479. /**
  85480. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85481. * @param rootUrl the url of the texture
  85482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85483. * @returns the fallback texture
  85484. */
  85485. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85486. /**
  85487. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85488. * @param data contains the texture data
  85489. * @param texture defines the BabylonJS internal texture
  85490. * @param createPolynomials will be true if polynomials have been requested
  85491. * @param onLoad defines the callback to trigger once the texture is ready
  85492. * @param onError defines the callback to trigger in case of error
  85493. */
  85494. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85495. /**
  85496. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85497. * @param data contains the texture data
  85498. * @param texture defines the BabylonJS internal texture
  85499. * @param callback defines the method to call once ready to upload
  85500. */
  85501. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85502. }
  85503. }
  85504. declare module BABYLON {
  85505. /**
  85506. * Creation options of the multi render target texture.
  85507. */
  85508. export interface IMultiRenderTargetOptions {
  85509. /**
  85510. * Define if the texture needs to create mip maps after render.
  85511. */
  85512. generateMipMaps?: boolean;
  85513. /**
  85514. * Define the types of all the draw buffers we want to create
  85515. */
  85516. types?: number[];
  85517. /**
  85518. * Define the sampling modes of all the draw buffers we want to create
  85519. */
  85520. samplingModes?: number[];
  85521. /**
  85522. * Define if a depth buffer is required
  85523. */
  85524. generateDepthBuffer?: boolean;
  85525. /**
  85526. * Define if a stencil buffer is required
  85527. */
  85528. generateStencilBuffer?: boolean;
  85529. /**
  85530. * Define if a depth texture is required instead of a depth buffer
  85531. */
  85532. generateDepthTexture?: boolean;
  85533. /**
  85534. * Define the number of desired draw buffers
  85535. */
  85536. textureCount?: number;
  85537. /**
  85538. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85539. */
  85540. doNotChangeAspectRatio?: boolean;
  85541. /**
  85542. * Define the default type of the buffers we are creating
  85543. */
  85544. defaultType?: number;
  85545. }
  85546. /**
  85547. * A multi render target, like a render target provides the ability to render to a texture.
  85548. * Unlike the render target, it can render to several draw buffers in one draw.
  85549. * This is specially interesting in deferred rendering or for any effects requiring more than
  85550. * just one color from a single pass.
  85551. */
  85552. export class MultiRenderTarget extends RenderTargetTexture {
  85553. private _internalTextures;
  85554. private _textures;
  85555. private _multiRenderTargetOptions;
  85556. /**
  85557. * Get if draw buffers are currently supported by the used hardware and browser.
  85558. */
  85559. readonly isSupported: boolean;
  85560. /**
  85561. * Get the list of textures generated by the multi render target.
  85562. */
  85563. readonly textures: Texture[];
  85564. /**
  85565. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85566. */
  85567. readonly depthTexture: Texture;
  85568. /**
  85569. * Set the wrapping mode on U of all the textures we are rendering to.
  85570. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85571. */
  85572. wrapU: number;
  85573. /**
  85574. * Set the wrapping mode on V of all the textures we are rendering to.
  85575. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85576. */
  85577. wrapV: number;
  85578. /**
  85579. * Instantiate a new multi render target texture.
  85580. * A multi render target, like a render target provides the ability to render to a texture.
  85581. * Unlike the render target, it can render to several draw buffers in one draw.
  85582. * This is specially interesting in deferred rendering or for any effects requiring more than
  85583. * just one color from a single pass.
  85584. * @param name Define the name of the texture
  85585. * @param size Define the size of the buffers to render to
  85586. * @param count Define the number of target we are rendering into
  85587. * @param scene Define the scene the texture belongs to
  85588. * @param options Define the options used to create the multi render target
  85589. */
  85590. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85591. /** @hidden */
  85592. _rebuild(): void;
  85593. private _createInternalTextures;
  85594. private _createTextures;
  85595. /**
  85596. * Define the number of samples used if MSAA is enabled.
  85597. */
  85598. samples: number;
  85599. /**
  85600. * Resize all the textures in the multi render target.
  85601. * Be carrefull as it will recreate all the data in the new texture.
  85602. * @param size Define the new size
  85603. */
  85604. resize(size: any): void;
  85605. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85606. /**
  85607. * Dispose the render targets and their associated resources
  85608. */
  85609. dispose(): void;
  85610. /**
  85611. * Release all the underlying texture used as draw buffers.
  85612. */
  85613. releaseInternalTextures(): void;
  85614. }
  85615. }
  85616. declare module BABYLON {
  85617. /**
  85618. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85620. */
  85621. export class Analyser {
  85622. /**
  85623. * Gets or sets the smoothing
  85624. * @ignorenaming
  85625. */
  85626. SMOOTHING: number;
  85627. /**
  85628. * Gets or sets the FFT table size
  85629. * @ignorenaming
  85630. */
  85631. FFT_SIZE: number;
  85632. /**
  85633. * Gets or sets the bar graph amplitude
  85634. * @ignorenaming
  85635. */
  85636. BARGRAPHAMPLITUDE: number;
  85637. /**
  85638. * Gets or sets the position of the debug canvas
  85639. * @ignorenaming
  85640. */
  85641. DEBUGCANVASPOS: {
  85642. x: number;
  85643. y: number;
  85644. };
  85645. /**
  85646. * Gets or sets the debug canvas size
  85647. * @ignorenaming
  85648. */
  85649. DEBUGCANVASSIZE: {
  85650. width: number;
  85651. height: number;
  85652. };
  85653. private _byteFreqs;
  85654. private _byteTime;
  85655. private _floatFreqs;
  85656. private _webAudioAnalyser;
  85657. private _debugCanvas;
  85658. private _debugCanvasContext;
  85659. private _scene;
  85660. private _registerFunc;
  85661. private _audioEngine;
  85662. /**
  85663. * Creates a new analyser
  85664. * @param scene defines hosting scene
  85665. */
  85666. constructor(scene: Scene);
  85667. /**
  85668. * Get the number of data values you will have to play with for the visualization
  85669. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85670. * @returns a number
  85671. */
  85672. getFrequencyBinCount(): number;
  85673. /**
  85674. * Gets the current frequency data as a byte array
  85675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85676. * @returns a Uint8Array
  85677. */
  85678. getByteFrequencyData(): Uint8Array;
  85679. /**
  85680. * Gets the current waveform as a byte array
  85681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85682. * @returns a Uint8Array
  85683. */
  85684. getByteTimeDomainData(): Uint8Array;
  85685. /**
  85686. * Gets the current frequency data as a float array
  85687. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85688. * @returns a Float32Array
  85689. */
  85690. getFloatFrequencyData(): Float32Array;
  85691. /**
  85692. * Renders the debug canvas
  85693. */
  85694. drawDebugCanvas(): void;
  85695. /**
  85696. * Stops rendering the debug canvas and removes it
  85697. */
  85698. stopDebugCanvas(): void;
  85699. /**
  85700. * Connects two audio nodes
  85701. * @param inputAudioNode defines first node to connect
  85702. * @param outputAudioNode defines second node to connect
  85703. */
  85704. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85705. /**
  85706. * Releases all associated resources
  85707. */
  85708. dispose(): void;
  85709. }
  85710. }
  85711. declare module BABYLON {
  85712. /**
  85713. * This represents an audio engine and it is responsible
  85714. * to play, synchronize and analyse sounds throughout the application.
  85715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85716. */
  85717. export interface IAudioEngine extends IDisposable {
  85718. /**
  85719. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85720. */
  85721. readonly canUseWebAudio: boolean;
  85722. /**
  85723. * Gets the current AudioContext if available.
  85724. */
  85725. readonly audioContext: Nullable<AudioContext>;
  85726. /**
  85727. * The master gain node defines the global audio volume of your audio engine.
  85728. */
  85729. readonly masterGain: GainNode;
  85730. /**
  85731. * Gets whether or not mp3 are supported by your browser.
  85732. */
  85733. readonly isMP3supported: boolean;
  85734. /**
  85735. * Gets whether or not ogg are supported by your browser.
  85736. */
  85737. readonly isOGGsupported: boolean;
  85738. /**
  85739. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85740. * @ignoreNaming
  85741. */
  85742. WarnedWebAudioUnsupported: boolean;
  85743. /**
  85744. * Defines if the audio engine relies on a custom unlocked button.
  85745. * In this case, the embedded button will not be displayed.
  85746. */
  85747. useCustomUnlockedButton: boolean;
  85748. /**
  85749. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85750. */
  85751. readonly unlocked: boolean;
  85752. /**
  85753. * Event raised when audio has been unlocked on the browser.
  85754. */
  85755. onAudioUnlockedObservable: Observable<AudioEngine>;
  85756. /**
  85757. * Event raised when audio has been locked on the browser.
  85758. */
  85759. onAudioLockedObservable: Observable<AudioEngine>;
  85760. /**
  85761. * Flags the audio engine in Locked state.
  85762. * This happens due to new browser policies preventing audio to autoplay.
  85763. */
  85764. lock(): void;
  85765. /**
  85766. * Unlocks the audio engine once a user action has been done on the dom.
  85767. * This is helpful to resume play once browser policies have been satisfied.
  85768. */
  85769. unlock(): void;
  85770. }
  85771. /**
  85772. * This represents the default audio engine used in babylon.
  85773. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85775. */
  85776. export class AudioEngine implements IAudioEngine {
  85777. private _audioContext;
  85778. private _audioContextInitialized;
  85779. private _muteButton;
  85780. private _hostElement;
  85781. /**
  85782. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85783. */
  85784. canUseWebAudio: boolean;
  85785. /**
  85786. * The master gain node defines the global audio volume of your audio engine.
  85787. */
  85788. masterGain: GainNode;
  85789. /**
  85790. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85791. * @ignoreNaming
  85792. */
  85793. WarnedWebAudioUnsupported: boolean;
  85794. /**
  85795. * Gets whether or not mp3 are supported by your browser.
  85796. */
  85797. isMP3supported: boolean;
  85798. /**
  85799. * Gets whether or not ogg are supported by your browser.
  85800. */
  85801. isOGGsupported: boolean;
  85802. /**
  85803. * Gets whether audio has been unlocked on the device.
  85804. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85805. * a user interaction has happened.
  85806. */
  85807. unlocked: boolean;
  85808. /**
  85809. * Defines if the audio engine relies on a custom unlocked button.
  85810. * In this case, the embedded button will not be displayed.
  85811. */
  85812. useCustomUnlockedButton: boolean;
  85813. /**
  85814. * Event raised when audio has been unlocked on the browser.
  85815. */
  85816. onAudioUnlockedObservable: Observable<AudioEngine>;
  85817. /**
  85818. * Event raised when audio has been locked on the browser.
  85819. */
  85820. onAudioLockedObservable: Observable<AudioEngine>;
  85821. /**
  85822. * Gets the current AudioContext if available.
  85823. */
  85824. readonly audioContext: Nullable<AudioContext>;
  85825. private _connectedAnalyser;
  85826. /**
  85827. * Instantiates a new audio engine.
  85828. *
  85829. * There should be only one per page as some browsers restrict the number
  85830. * of audio contexts you can create.
  85831. * @param hostElement defines the host element where to display the mute icon if necessary
  85832. */
  85833. constructor(hostElement?: Nullable<HTMLElement>);
  85834. /**
  85835. * Flags the audio engine in Locked state.
  85836. * This happens due to new browser policies preventing audio to autoplay.
  85837. */
  85838. lock(): void;
  85839. /**
  85840. * Unlocks the audio engine once a user action has been done on the dom.
  85841. * This is helpful to resume play once browser policies have been satisfied.
  85842. */
  85843. unlock(): void;
  85844. private _resumeAudioContext;
  85845. private _initializeAudioContext;
  85846. private _tryToRun;
  85847. private _triggerRunningState;
  85848. private _triggerSuspendedState;
  85849. private _displayMuteButton;
  85850. private _moveButtonToTopLeft;
  85851. private _onResize;
  85852. private _hideMuteButton;
  85853. /**
  85854. * Destroy and release the resources associated with the audio ccontext.
  85855. */
  85856. dispose(): void;
  85857. /**
  85858. * Gets the global volume sets on the master gain.
  85859. * @returns the global volume if set or -1 otherwise
  85860. */
  85861. getGlobalVolume(): number;
  85862. /**
  85863. * Sets the global volume of your experience (sets on the master gain).
  85864. * @param newVolume Defines the new global volume of the application
  85865. */
  85866. setGlobalVolume(newVolume: number): void;
  85867. /**
  85868. * Connect the audio engine to an audio analyser allowing some amazing
  85869. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85871. * @param analyser The analyser to connect to the engine
  85872. */
  85873. connectToAnalyser(analyser: Analyser): void;
  85874. }
  85875. }
  85876. declare module BABYLON {
  85877. /**
  85878. * Interface used to present a loading screen while loading a scene
  85879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85880. */
  85881. export interface ILoadingScreen {
  85882. /**
  85883. * Function called to display the loading screen
  85884. */
  85885. displayLoadingUI: () => void;
  85886. /**
  85887. * Function called to hide the loading screen
  85888. */
  85889. hideLoadingUI: () => void;
  85890. /**
  85891. * Gets or sets the color to use for the background
  85892. */
  85893. loadingUIBackgroundColor: string;
  85894. /**
  85895. * Gets or sets the text to display while loading
  85896. */
  85897. loadingUIText: string;
  85898. }
  85899. /**
  85900. * Class used for the default loading screen
  85901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85902. */
  85903. export class DefaultLoadingScreen implements ILoadingScreen {
  85904. private _renderingCanvas;
  85905. private _loadingText;
  85906. private _loadingDivBackgroundColor;
  85907. private _loadingDiv;
  85908. private _loadingTextDiv;
  85909. /**
  85910. * Creates a new default loading screen
  85911. * @param _renderingCanvas defines the canvas used to render the scene
  85912. * @param _loadingText defines the default text to display
  85913. * @param _loadingDivBackgroundColor defines the default background color
  85914. */
  85915. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85916. /**
  85917. * Function called to display the loading screen
  85918. */
  85919. displayLoadingUI(): void;
  85920. /**
  85921. * Function called to hide the loading screen
  85922. */
  85923. hideLoadingUI(): void;
  85924. /**
  85925. * Gets or sets the text to display while loading
  85926. */
  85927. loadingUIText: string;
  85928. /**
  85929. * Gets or sets the color to use for the background
  85930. */
  85931. loadingUIBackgroundColor: string;
  85932. private _resizeLoadingUI;
  85933. }
  85934. }
  85935. declare module BABYLON {
  85936. /**
  85937. * Settings for finer control over video usage
  85938. */
  85939. export interface VideoTextureSettings {
  85940. /**
  85941. * Applies `autoplay` to video, if specified
  85942. */
  85943. autoPlay?: boolean;
  85944. /**
  85945. * Applies `loop` to video, if specified
  85946. */
  85947. loop?: boolean;
  85948. /**
  85949. * Automatically updates internal texture from video at every frame in the render loop
  85950. */
  85951. autoUpdateTexture: boolean;
  85952. /**
  85953. * Image src displayed during the video loading or until the user interacts with the video.
  85954. */
  85955. poster?: string;
  85956. }
  85957. /**
  85958. * If you want to display a video in your scene, this is the special texture for that.
  85959. * This special texture works similar to other textures, with the exception of a few parameters.
  85960. * @see https://doc.babylonjs.com/how_to/video_texture
  85961. */
  85962. export class VideoTexture extends Texture {
  85963. /**
  85964. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85965. */
  85966. readonly autoUpdateTexture: boolean;
  85967. /**
  85968. * The video instance used by the texture internally
  85969. */
  85970. readonly video: HTMLVideoElement;
  85971. private _onUserActionRequestedObservable;
  85972. /**
  85973. * Event triggerd when a dom action is required by the user to play the video.
  85974. * This happens due to recent changes in browser policies preventing video to auto start.
  85975. */
  85976. readonly onUserActionRequestedObservable: Observable<Texture>;
  85977. private _generateMipMaps;
  85978. private _engine;
  85979. private _stillImageCaptured;
  85980. private _displayingPosterTexture;
  85981. private _settings;
  85982. private _createInternalTextureOnEvent;
  85983. /**
  85984. * Creates a video texture.
  85985. * If you want to display a video in your scene, this is the special texture for that.
  85986. * This special texture works similar to other textures, with the exception of a few parameters.
  85987. * @see https://doc.babylonjs.com/how_to/video_texture
  85988. * @param name optional name, will detect from video source, if not defined
  85989. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85990. * @param scene is obviously the current scene.
  85991. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85992. * @param invertY is false by default but can be used to invert video on Y axis
  85993. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85994. * @param settings allows finer control over video usage
  85995. */
  85996. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85997. private _getName;
  85998. private _getVideo;
  85999. private _createInternalTexture;
  86000. private reset;
  86001. /**
  86002. * @hidden Internal method to initiate `update`.
  86003. */
  86004. _rebuild(): void;
  86005. /**
  86006. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86007. */
  86008. update(): void;
  86009. /**
  86010. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86011. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86012. */
  86013. updateTexture(isVisible: boolean): void;
  86014. protected _updateInternalTexture: () => void;
  86015. /**
  86016. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86017. * @param url New url.
  86018. */
  86019. updateURL(url: string): void;
  86020. /**
  86021. * Dispose the texture and release its associated resources.
  86022. */
  86023. dispose(): void;
  86024. /**
  86025. * Creates a video texture straight from a stream.
  86026. * @param scene Define the scene the texture should be created in
  86027. * @param stream Define the stream the texture should be created from
  86028. * @returns The created video texture as a promise
  86029. */
  86030. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86031. /**
  86032. * Creates a video texture straight from your WebCam video feed.
  86033. * @param scene Define the scene the texture should be created in
  86034. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86035. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86036. * @returns The created video texture as a promise
  86037. */
  86038. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86039. minWidth: number;
  86040. maxWidth: number;
  86041. minHeight: number;
  86042. maxHeight: number;
  86043. deviceId: string;
  86044. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86045. /**
  86046. * Creates a video texture straight from your WebCam video feed.
  86047. * @param scene Define the scene the texture should be created in
  86048. * @param onReady Define a callback to triggered once the texture will be ready
  86049. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86050. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86051. */
  86052. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86053. minWidth: number;
  86054. maxWidth: number;
  86055. minHeight: number;
  86056. maxHeight: number;
  86057. deviceId: string;
  86058. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86059. }
  86060. }
  86061. declare module BABYLON {
  86062. /**
  86063. * Interface for attribute information associated with buffer instanciation
  86064. */
  86065. export class InstancingAttributeInfo {
  86066. /**
  86067. * Index/offset of the attribute in the vertex shader
  86068. */
  86069. index: number;
  86070. /**
  86071. * size of the attribute, 1, 2, 3 or 4
  86072. */
  86073. attributeSize: number;
  86074. /**
  86075. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86076. * default is FLOAT
  86077. */
  86078. attribyteType: number;
  86079. /**
  86080. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86081. */
  86082. normalized: boolean;
  86083. /**
  86084. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86085. */
  86086. offset: number;
  86087. /**
  86088. * Name of the GLSL attribute, for debugging purpose only
  86089. */
  86090. attributeName: string;
  86091. }
  86092. /**
  86093. * Define options used to create a depth texture
  86094. */
  86095. export class DepthTextureCreationOptions {
  86096. /** Specifies whether or not a stencil should be allocated in the texture */
  86097. generateStencil?: boolean;
  86098. /** Specifies whether or not bilinear filtering is enable on the texture */
  86099. bilinearFiltering?: boolean;
  86100. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86101. comparisonFunction?: number;
  86102. /** Specifies if the created texture is a cube texture */
  86103. isCube?: boolean;
  86104. }
  86105. /**
  86106. * Class used to describe the capabilities of the engine relatively to the current browser
  86107. */
  86108. export class EngineCapabilities {
  86109. /** Maximum textures units per fragment shader */
  86110. maxTexturesImageUnits: number;
  86111. /** Maximum texture units per vertex shader */
  86112. maxVertexTextureImageUnits: number;
  86113. /** Maximum textures units in the entire pipeline */
  86114. maxCombinedTexturesImageUnits: number;
  86115. /** Maximum texture size */
  86116. maxTextureSize: number;
  86117. /** Maximum cube texture size */
  86118. maxCubemapTextureSize: number;
  86119. /** Maximum render texture size */
  86120. maxRenderTextureSize: number;
  86121. /** Maximum number of vertex attributes */
  86122. maxVertexAttribs: number;
  86123. /** Maximum number of varyings */
  86124. maxVaryingVectors: number;
  86125. /** Maximum number of uniforms per vertex shader */
  86126. maxVertexUniformVectors: number;
  86127. /** Maximum number of uniforms per fragment shader */
  86128. maxFragmentUniformVectors: number;
  86129. /** Defines if standard derivates (dx/dy) are supported */
  86130. standardDerivatives: boolean;
  86131. /** Defines if s3tc texture compression is supported */
  86132. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86133. /** Defines if pvrtc texture compression is supported */
  86134. pvrtc: any;
  86135. /** Defines if etc1 texture compression is supported */
  86136. etc1: any;
  86137. /** Defines if etc2 texture compression is supported */
  86138. etc2: any;
  86139. /** Defines if astc texture compression is supported */
  86140. astc: any;
  86141. /** Defines if float textures are supported */
  86142. textureFloat: boolean;
  86143. /** Defines if vertex array objects are supported */
  86144. vertexArrayObject: boolean;
  86145. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86146. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86147. /** Gets the maximum level of anisotropy supported */
  86148. maxAnisotropy: number;
  86149. /** Defines if instancing is supported */
  86150. instancedArrays: boolean;
  86151. /** Defines if 32 bits indices are supported */
  86152. uintIndices: boolean;
  86153. /** Defines if high precision shaders are supported */
  86154. highPrecisionShaderSupported: boolean;
  86155. /** Defines if depth reading in the fragment shader is supported */
  86156. fragmentDepthSupported: boolean;
  86157. /** Defines if float texture linear filtering is supported*/
  86158. textureFloatLinearFiltering: boolean;
  86159. /** Defines if rendering to float textures is supported */
  86160. textureFloatRender: boolean;
  86161. /** Defines if half float textures are supported*/
  86162. textureHalfFloat: boolean;
  86163. /** Defines if half float texture linear filtering is supported*/
  86164. textureHalfFloatLinearFiltering: boolean;
  86165. /** Defines if rendering to half float textures is supported */
  86166. textureHalfFloatRender: boolean;
  86167. /** Defines if textureLOD shader command is supported */
  86168. textureLOD: boolean;
  86169. /** Defines if draw buffers extension is supported */
  86170. drawBuffersExtension: boolean;
  86171. /** Defines if depth textures are supported */
  86172. depthTextureExtension: boolean;
  86173. /** Defines if float color buffer are supported */
  86174. colorBufferFloat: boolean;
  86175. /** Gets disjoint timer query extension (null if not supported) */
  86176. timerQuery: EXT_disjoint_timer_query;
  86177. /** Defines if timestamp can be used with timer query */
  86178. canUseTimestampForTimerQuery: boolean;
  86179. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86180. multiview: any;
  86181. /** Function used to let the system compiles shaders in background */
  86182. parallelShaderCompile: {
  86183. COMPLETION_STATUS_KHR: number;
  86184. };
  86185. }
  86186. /** Interface defining initialization parameters for Engine class */
  86187. export interface EngineOptions extends WebGLContextAttributes {
  86188. /**
  86189. * Defines if the engine should no exceed a specified device ratio
  86190. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86191. */
  86192. limitDeviceRatio?: number;
  86193. /**
  86194. * Defines if webvr should be enabled automatically
  86195. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86196. */
  86197. autoEnableWebVR?: boolean;
  86198. /**
  86199. * Defines if webgl2 should be turned off even if supported
  86200. * @see http://doc.babylonjs.com/features/webgl2
  86201. */
  86202. disableWebGL2Support?: boolean;
  86203. /**
  86204. * Defines if webaudio should be initialized as well
  86205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86206. */
  86207. audioEngine?: boolean;
  86208. /**
  86209. * Defines if animations should run using a deterministic lock step
  86210. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86211. */
  86212. deterministicLockstep?: boolean;
  86213. /** Defines the maximum steps to use with deterministic lock step mode */
  86214. lockstepMaxSteps?: number;
  86215. /**
  86216. * Defines that engine should ignore context lost events
  86217. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86218. */
  86219. doNotHandleContextLost?: boolean;
  86220. /**
  86221. * Defines that engine should ignore modifying touch action attribute and style
  86222. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86223. */
  86224. doNotHandleTouchAction?: boolean;
  86225. /**
  86226. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86227. */
  86228. useHighPrecisionFloats?: boolean;
  86229. }
  86230. /**
  86231. * Defines the interface used by display changed events
  86232. */
  86233. export interface IDisplayChangedEventArgs {
  86234. /** Gets the vrDisplay object (if any) */
  86235. vrDisplay: Nullable<any>;
  86236. /** Gets a boolean indicating if webVR is supported */
  86237. vrSupported: boolean;
  86238. }
  86239. /**
  86240. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86241. */
  86242. export class Engine {
  86243. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86244. static ExceptionList: ({
  86245. key: string;
  86246. capture: string;
  86247. captureConstraint: number;
  86248. targets: string[];
  86249. } | {
  86250. key: string;
  86251. capture: null;
  86252. captureConstraint: null;
  86253. targets: string[];
  86254. })[];
  86255. /** Gets the list of created engines */
  86256. static readonly Instances: Engine[];
  86257. /**
  86258. * Gets the latest created engine
  86259. */
  86260. static readonly LastCreatedEngine: Nullable<Engine>;
  86261. /**
  86262. * Gets the latest created scene
  86263. */
  86264. static readonly LastCreatedScene: Nullable<Scene>;
  86265. /**
  86266. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86267. * @param flag defines which part of the materials must be marked as dirty
  86268. * @param predicate defines a predicate used to filter which materials should be affected
  86269. */
  86270. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86271. /**
  86272. * Hidden
  86273. */
  86274. static _TextureLoaders: IInternalTextureLoader[];
  86275. /** Defines that alpha blending is disabled */
  86276. static readonly ALPHA_DISABLE: number;
  86277. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86278. static readonly ALPHA_ADD: number;
  86279. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86280. static readonly ALPHA_COMBINE: number;
  86281. /** Defines that alpha blending to DEST - SRC * DEST */
  86282. static readonly ALPHA_SUBTRACT: number;
  86283. /** Defines that alpha blending to SRC * DEST */
  86284. static readonly ALPHA_MULTIPLY: number;
  86285. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86286. static readonly ALPHA_MAXIMIZED: number;
  86287. /** Defines that alpha blending to SRC + DEST */
  86288. static readonly ALPHA_ONEONE: number;
  86289. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86290. static readonly ALPHA_PREMULTIPLIED: number;
  86291. /**
  86292. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86293. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86294. */
  86295. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86296. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86297. static readonly ALPHA_INTERPOLATE: number;
  86298. /**
  86299. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86300. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86301. */
  86302. static readonly ALPHA_SCREENMODE: number;
  86303. /** Defines that the ressource is not delayed*/
  86304. static readonly DELAYLOADSTATE_NONE: number;
  86305. /** Defines that the ressource was successfully delay loaded */
  86306. static readonly DELAYLOADSTATE_LOADED: number;
  86307. /** Defines that the ressource is currently delay loading */
  86308. static readonly DELAYLOADSTATE_LOADING: number;
  86309. /** Defines that the ressource is delayed and has not started loading */
  86310. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86311. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86312. static readonly NEVER: number;
  86313. /** 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 */
  86314. static readonly ALWAYS: number;
  86315. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86316. static readonly LESS: number;
  86317. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86318. static readonly EQUAL: number;
  86319. /** 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 */
  86320. static readonly LEQUAL: number;
  86321. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86322. static readonly GREATER: number;
  86323. /** 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 */
  86324. static readonly GEQUAL: number;
  86325. /** 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 */
  86326. static readonly NOTEQUAL: number;
  86327. /** Passed to stencilOperation to specify that stencil value must be kept */
  86328. static readonly KEEP: number;
  86329. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86330. static readonly REPLACE: number;
  86331. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86332. static readonly INCR: number;
  86333. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86334. static readonly DECR: number;
  86335. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86336. static readonly INVERT: number;
  86337. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86338. static readonly INCR_WRAP: number;
  86339. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86340. static readonly DECR_WRAP: number;
  86341. /** Texture is not repeating outside of 0..1 UVs */
  86342. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86343. /** Texture is repeating outside of 0..1 UVs */
  86344. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86345. /** Texture is repeating and mirrored */
  86346. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86347. /** ALPHA */
  86348. static readonly TEXTUREFORMAT_ALPHA: number;
  86349. /** LUMINANCE */
  86350. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86351. /** LUMINANCE_ALPHA */
  86352. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86353. /** RGB */
  86354. static readonly TEXTUREFORMAT_RGB: number;
  86355. /** RGBA */
  86356. static readonly TEXTUREFORMAT_RGBA: number;
  86357. /** RED */
  86358. static readonly TEXTUREFORMAT_RED: number;
  86359. /** RED (2nd reference) */
  86360. static readonly TEXTUREFORMAT_R: number;
  86361. /** RG */
  86362. static readonly TEXTUREFORMAT_RG: number;
  86363. /** RED_INTEGER */
  86364. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86365. /** RED_INTEGER (2nd reference) */
  86366. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86367. /** RG_INTEGER */
  86368. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86369. /** RGB_INTEGER */
  86370. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86371. /** RGBA_INTEGER */
  86372. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86373. /** UNSIGNED_BYTE */
  86374. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86375. /** UNSIGNED_BYTE (2nd reference) */
  86376. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86377. /** FLOAT */
  86378. static readonly TEXTURETYPE_FLOAT: number;
  86379. /** HALF_FLOAT */
  86380. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86381. /** BYTE */
  86382. static readonly TEXTURETYPE_BYTE: number;
  86383. /** SHORT */
  86384. static readonly TEXTURETYPE_SHORT: number;
  86385. /** UNSIGNED_SHORT */
  86386. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86387. /** INT */
  86388. static readonly TEXTURETYPE_INT: number;
  86389. /** UNSIGNED_INT */
  86390. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86391. /** UNSIGNED_SHORT_4_4_4_4 */
  86392. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86393. /** UNSIGNED_SHORT_5_5_5_1 */
  86394. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86395. /** UNSIGNED_SHORT_5_6_5 */
  86396. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86397. /** UNSIGNED_INT_2_10_10_10_REV */
  86398. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86399. /** UNSIGNED_INT_24_8 */
  86400. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86401. /** UNSIGNED_INT_10F_11F_11F_REV */
  86402. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86403. /** UNSIGNED_INT_5_9_9_9_REV */
  86404. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86405. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86406. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86407. /** nearest is mag = nearest and min = nearest and mip = linear */
  86408. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86409. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86410. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86411. /** Trilinear is mag = linear and min = linear and mip = linear */
  86412. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86413. /** nearest is mag = nearest and min = nearest and mip = linear */
  86414. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86415. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86416. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86417. /** Trilinear is mag = linear and min = linear and mip = linear */
  86418. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86419. /** mag = nearest and min = nearest and mip = nearest */
  86420. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86421. /** mag = nearest and min = linear and mip = nearest */
  86422. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86423. /** mag = nearest and min = linear and mip = linear */
  86424. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86425. /** mag = nearest and min = linear and mip = none */
  86426. static readonly TEXTURE_NEAREST_LINEAR: number;
  86427. /** mag = nearest and min = nearest and mip = none */
  86428. static readonly TEXTURE_NEAREST_NEAREST: number;
  86429. /** mag = linear and min = nearest and mip = nearest */
  86430. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86431. /** mag = linear and min = nearest and mip = linear */
  86432. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86433. /** mag = linear and min = linear and mip = none */
  86434. static readonly TEXTURE_LINEAR_LINEAR: number;
  86435. /** mag = linear and min = nearest and mip = none */
  86436. static readonly TEXTURE_LINEAR_NEAREST: number;
  86437. /** Explicit coordinates mode */
  86438. static readonly TEXTURE_EXPLICIT_MODE: number;
  86439. /** Spherical coordinates mode */
  86440. static readonly TEXTURE_SPHERICAL_MODE: number;
  86441. /** Planar coordinates mode */
  86442. static readonly TEXTURE_PLANAR_MODE: number;
  86443. /** Cubic coordinates mode */
  86444. static readonly TEXTURE_CUBIC_MODE: number;
  86445. /** Projection coordinates mode */
  86446. static readonly TEXTURE_PROJECTION_MODE: number;
  86447. /** Skybox coordinates mode */
  86448. static readonly TEXTURE_SKYBOX_MODE: number;
  86449. /** Inverse Cubic coordinates mode */
  86450. static readonly TEXTURE_INVCUBIC_MODE: number;
  86451. /** Equirectangular coordinates mode */
  86452. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86453. /** Equirectangular Fixed coordinates mode */
  86454. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86455. /** Equirectangular Fixed Mirrored coordinates mode */
  86456. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86457. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86458. static readonly SCALEMODE_FLOOR: number;
  86459. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86460. static readonly SCALEMODE_NEAREST: number;
  86461. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86462. static readonly SCALEMODE_CEILING: number;
  86463. /**
  86464. * Returns the current npm package of the sdk
  86465. */
  86466. static readonly NpmPackage: string;
  86467. /**
  86468. * Returns the current version of the framework
  86469. */
  86470. static readonly Version: string;
  86471. /**
  86472. * Returns a string describing the current engine
  86473. */
  86474. readonly description: string;
  86475. /**
  86476. * Gets or sets the epsilon value used by collision engine
  86477. */
  86478. static CollisionsEpsilon: number;
  86479. /**
  86480. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86481. */
  86482. static ShadersRepository: string;
  86483. /**
  86484. * Method called to create the default loading screen.
  86485. * This can be overriden in your own app.
  86486. * @param canvas The rendering canvas element
  86487. * @returns The loading screen
  86488. */
  86489. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86490. /**
  86491. * Method called to create the default rescale post process on each engine.
  86492. */
  86493. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86494. /**
  86495. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86496. */
  86497. forcePOTTextures: boolean;
  86498. /**
  86499. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86500. */
  86501. isFullscreen: boolean;
  86502. /**
  86503. * Gets a boolean indicating if the pointer is currently locked
  86504. */
  86505. isPointerLock: boolean;
  86506. /**
  86507. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86508. */
  86509. cullBackFaces: boolean;
  86510. /**
  86511. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86512. */
  86513. renderEvenInBackground: boolean;
  86514. /**
  86515. * Gets or sets a boolean indicating that cache can be kept between frames
  86516. */
  86517. preventCacheWipeBetweenFrames: boolean;
  86518. /**
  86519. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86520. **/
  86521. enableOfflineSupport: boolean;
  86522. /**
  86523. * 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)
  86524. **/
  86525. disableManifestCheck: boolean;
  86526. /**
  86527. * Gets the list of created scenes
  86528. */
  86529. scenes: Scene[];
  86530. /**
  86531. * Event raised when a new scene is created
  86532. */
  86533. onNewSceneAddedObservable: Observable<Scene>;
  86534. /**
  86535. * Gets the list of created postprocesses
  86536. */
  86537. postProcesses: PostProcess[];
  86538. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86539. validateShaderPrograms: boolean;
  86540. /**
  86541. * Observable event triggered each time the rendering canvas is resized
  86542. */
  86543. onResizeObservable: Observable<Engine>;
  86544. /**
  86545. * Observable event triggered each time the canvas loses focus
  86546. */
  86547. onCanvasBlurObservable: Observable<Engine>;
  86548. /**
  86549. * Observable event triggered each time the canvas gains focus
  86550. */
  86551. onCanvasFocusObservable: Observable<Engine>;
  86552. /**
  86553. * Observable event triggered each time the canvas receives pointerout event
  86554. */
  86555. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86556. /**
  86557. * Observable event triggered before each texture is initialized
  86558. */
  86559. onBeforeTextureInitObservable: Observable<Texture>;
  86560. private _vrDisplay;
  86561. private _vrSupported;
  86562. private _oldSize;
  86563. private _oldHardwareScaleFactor;
  86564. private _vrExclusivePointerMode;
  86565. private _webVRInitPromise;
  86566. /**
  86567. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86568. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86569. */
  86570. readonly isInVRExclusivePointerMode: boolean;
  86571. /**
  86572. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86573. */
  86574. disableUniformBuffers: boolean;
  86575. /** @hidden */
  86576. _uniformBuffers: UniformBuffer[];
  86577. /**
  86578. * Gets a boolean indicating that the engine supports uniform buffers
  86579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86580. */
  86581. readonly supportsUniformBuffers: boolean;
  86582. /**
  86583. * Observable raised when the engine begins a new frame
  86584. */
  86585. onBeginFrameObservable: Observable<Engine>;
  86586. /**
  86587. * If set, will be used to request the next animation frame for the render loop
  86588. */
  86589. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86590. /**
  86591. * Observable raised when the engine ends the current frame
  86592. */
  86593. onEndFrameObservable: Observable<Engine>;
  86594. /**
  86595. * Observable raised when the engine is about to compile a shader
  86596. */
  86597. onBeforeShaderCompilationObservable: Observable<Engine>;
  86598. /**
  86599. * Observable raised when the engine has jsut compiled a shader
  86600. */
  86601. onAfterShaderCompilationObservable: Observable<Engine>;
  86602. /** @hidden */
  86603. _gl: WebGLRenderingContext;
  86604. private _renderingCanvas;
  86605. private _windowIsBackground;
  86606. private _webGLVersion;
  86607. protected _highPrecisionShadersAllowed: boolean;
  86608. /** @hidden */
  86609. readonly _shouldUseHighPrecisionShader: boolean;
  86610. /**
  86611. * Gets a boolean indicating that only power of 2 textures are supported
  86612. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86613. */
  86614. readonly needPOTTextures: boolean;
  86615. /** @hidden */
  86616. _badOS: boolean;
  86617. /** @hidden */
  86618. _badDesktopOS: boolean;
  86619. /**
  86620. * Gets or sets a value indicating if we want to disable texture binding optimization.
  86621. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  86622. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  86623. */
  86624. disableTextureBindingOptimization: boolean;
  86625. /**
  86626. * Gets the audio engine
  86627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86628. * @ignorenaming
  86629. */
  86630. static audioEngine: IAudioEngine;
  86631. /**
  86632. * Default AudioEngine factory responsible of creating the Audio Engine.
  86633. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86634. */
  86635. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86636. /**
  86637. * Default offline support factory responsible of creating a tool used to store data locally.
  86638. * By default, this will create a Database object if the workload has been embedded.
  86639. */
  86640. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86641. private _onFocus;
  86642. private _onBlur;
  86643. private _onCanvasPointerOut;
  86644. private _onCanvasBlur;
  86645. private _onCanvasFocus;
  86646. private _onFullscreenChange;
  86647. private _onPointerLockChange;
  86648. private _onVRDisplayPointerRestricted;
  86649. private _onVRDisplayPointerUnrestricted;
  86650. private _onVrDisplayConnect;
  86651. private _onVrDisplayDisconnect;
  86652. private _onVrDisplayPresentChange;
  86653. /**
  86654. * Observable signaled when VR display mode changes
  86655. */
  86656. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86657. /**
  86658. * Observable signaled when VR request present is complete
  86659. */
  86660. onVRRequestPresentComplete: Observable<boolean>;
  86661. /**
  86662. * Observable signaled when VR request present starts
  86663. */
  86664. onVRRequestPresentStart: Observable<Engine>;
  86665. private _hardwareScalingLevel;
  86666. /** @hidden */
  86667. protected _caps: EngineCapabilities;
  86668. private _pointerLockRequested;
  86669. private _isStencilEnable;
  86670. private _colorWrite;
  86671. private _loadingScreen;
  86672. /** @hidden */
  86673. _drawCalls: PerfCounter;
  86674. /** @hidden */
  86675. _textureCollisions: PerfCounter;
  86676. private _glVersion;
  86677. private _glRenderer;
  86678. private _glVendor;
  86679. private _videoTextureSupported;
  86680. private _renderingQueueLaunched;
  86681. private _activeRenderLoops;
  86682. private _deterministicLockstep;
  86683. private _lockstepMaxSteps;
  86684. /**
  86685. * Observable signaled when a context lost event is raised
  86686. */
  86687. onContextLostObservable: Observable<Engine>;
  86688. /**
  86689. * Observable signaled when a context restored event is raised
  86690. */
  86691. onContextRestoredObservable: Observable<Engine>;
  86692. private _onContextLost;
  86693. private _onContextRestored;
  86694. private _contextWasLost;
  86695. private _doNotHandleContextLost;
  86696. /**
  86697. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86699. */
  86700. doNotHandleContextLost: boolean;
  86701. private _performanceMonitor;
  86702. private _fps;
  86703. private _deltaTime;
  86704. /**
  86705. * Turn this value on if you want to pause FPS computation when in background
  86706. */
  86707. disablePerformanceMonitorInBackground: boolean;
  86708. /**
  86709. * Gets the performance monitor attached to this engine
  86710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86711. */
  86712. readonly performanceMonitor: PerformanceMonitor;
  86713. /**
  86714. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86715. */
  86716. disableVertexArrayObjects: boolean;
  86717. /** @hidden */
  86718. protected _depthCullingState: _DepthCullingState;
  86719. /** @hidden */
  86720. protected _stencilState: _StencilState;
  86721. /** @hidden */
  86722. protected _alphaState: _AlphaState;
  86723. /** @hidden */
  86724. protected _alphaMode: number;
  86725. protected _internalTexturesCache: InternalTexture[];
  86726. /** @hidden */
  86727. protected _activeChannel: number;
  86728. private _currentTextureChannel;
  86729. /** @hidden */
  86730. protected _boundTexturesCache: {
  86731. [key: string]: Nullable<InternalTexture>;
  86732. };
  86733. /** @hidden */
  86734. protected _currentEffect: Nullable<Effect>;
  86735. /** @hidden */
  86736. protected _currentProgram: Nullable<WebGLProgram>;
  86737. private _compiledEffects;
  86738. private _vertexAttribArraysEnabled;
  86739. /** @hidden */
  86740. protected _cachedViewport: Nullable<Viewport>;
  86741. private _cachedVertexArrayObject;
  86742. /** @hidden */
  86743. protected _cachedVertexBuffers: any;
  86744. /** @hidden */
  86745. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86746. /** @hidden */
  86747. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86748. /** @hidden */
  86749. protected _currentRenderTarget: Nullable<InternalTexture>;
  86750. private _uintIndicesCurrentlySet;
  86751. private _currentBoundBuffer;
  86752. /** @hidden */
  86753. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86754. private _currentBufferPointers;
  86755. private _currentInstanceLocations;
  86756. private _currentInstanceBuffers;
  86757. private _textureUnits;
  86758. private _firstBoundInternalTextureTracker;
  86759. private _lastBoundInternalTextureTracker;
  86760. private _workingCanvas;
  86761. private _workingContext;
  86762. private _rescalePostProcess;
  86763. private _dummyFramebuffer;
  86764. private _externalData;
  86765. private _bindedRenderFunction;
  86766. private _vaoRecordInProgress;
  86767. private _mustWipeVertexAttributes;
  86768. private _emptyTexture;
  86769. private _emptyCubeTexture;
  86770. private _emptyTexture3D;
  86771. /** @hidden */
  86772. _frameHandler: number;
  86773. private _nextFreeTextureSlots;
  86774. private _maxSimultaneousTextures;
  86775. private _activeRequests;
  86776. private _texturesSupported;
  86777. private _textureFormatInUse;
  86778. /**
  86779. * Gets the list of texture formats supported
  86780. */
  86781. readonly texturesSupported: Array<string>;
  86782. /**
  86783. * Gets the list of texture formats in use
  86784. */
  86785. readonly textureFormatInUse: Nullable<string>;
  86786. /**
  86787. * Gets the current viewport
  86788. */
  86789. readonly currentViewport: Nullable<Viewport>;
  86790. /**
  86791. * Gets the default empty texture
  86792. */
  86793. readonly emptyTexture: InternalTexture;
  86794. /**
  86795. * Gets the default empty 3D texture
  86796. */
  86797. readonly emptyTexture3D: InternalTexture;
  86798. /**
  86799. * Gets the default empty cube texture
  86800. */
  86801. readonly emptyCubeTexture: InternalTexture;
  86802. /**
  86803. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86804. */
  86805. readonly premultipliedAlpha: boolean;
  86806. /**
  86807. * Creates a new engine
  86808. * @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
  86809. * @param antialias defines enable antialiasing (default: false)
  86810. * @param options defines further options to be sent to the getContext() function
  86811. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86812. */
  86813. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86814. private _disableTouchAction;
  86815. private _rebuildInternalTextures;
  86816. private _rebuildEffects;
  86817. /**
  86818. * Gets a boolean indicating if all created effects are ready
  86819. * @returns true if all effects are ready
  86820. */
  86821. areAllEffectsReady(): boolean;
  86822. private _rebuildBuffers;
  86823. private _initGLContext;
  86824. /**
  86825. * Gets version of the current webGL context
  86826. */
  86827. readonly webGLVersion: number;
  86828. /**
  86829. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86830. */
  86831. readonly isStencilEnable: boolean;
  86832. private _prepareWorkingCanvas;
  86833. /**
  86834. * Reset the texture cache to empty state
  86835. */
  86836. resetTextureCache(): void;
  86837. /**
  86838. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86839. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86840. * @returns true if engine is in deterministic lock step mode
  86841. */
  86842. isDeterministicLockStep(): boolean;
  86843. /**
  86844. * Gets the max steps when engine is running in deterministic lock step
  86845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86846. * @returns the max steps
  86847. */
  86848. getLockstepMaxSteps(): number;
  86849. /**
  86850. * Gets an object containing information about the current webGL context
  86851. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86852. */
  86853. getGlInfo(): {
  86854. vendor: string;
  86855. renderer: string;
  86856. version: string;
  86857. };
  86858. /**
  86859. * Gets current aspect ratio
  86860. * @param camera defines the camera to use to get the aspect ratio
  86861. * @param useScreen defines if screen size must be used (or the current render target if any)
  86862. * @returns a number defining the aspect ratio
  86863. */
  86864. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86865. /**
  86866. * Gets current screen aspect ratio
  86867. * @returns a number defining the aspect ratio
  86868. */
  86869. getScreenAspectRatio(): number;
  86870. /**
  86871. * Gets the current render width
  86872. * @param useScreen defines if screen size must be used (or the current render target if any)
  86873. * @returns a number defining the current render width
  86874. */
  86875. getRenderWidth(useScreen?: boolean): number;
  86876. /**
  86877. * Gets the current render height
  86878. * @param useScreen defines if screen size must be used (or the current render target if any)
  86879. * @returns a number defining the current render height
  86880. */
  86881. getRenderHeight(useScreen?: boolean): number;
  86882. /**
  86883. * Gets the HTML canvas attached with the current webGL context
  86884. * @returns a HTML canvas
  86885. */
  86886. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86887. /**
  86888. * Gets the client rect of the HTML canvas attached with the current webGL context
  86889. * @returns a client rectanglee
  86890. */
  86891. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86892. /**
  86893. * Defines the hardware scaling level.
  86894. * By default the hardware scaling level is computed from the window device ratio.
  86895. * 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.
  86896. * @param level defines the level to use
  86897. */
  86898. setHardwareScalingLevel(level: number): void;
  86899. /**
  86900. * Gets the current hardware scaling level.
  86901. * By default the hardware scaling level is computed from the window device ratio.
  86902. * 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.
  86903. * @returns a number indicating the current hardware scaling level
  86904. */
  86905. getHardwareScalingLevel(): number;
  86906. /**
  86907. * Gets the list of loaded textures
  86908. * @returns an array containing all loaded textures
  86909. */
  86910. getLoadedTexturesCache(): InternalTexture[];
  86911. /**
  86912. * Gets the object containing all engine capabilities
  86913. * @returns the EngineCapabilities object
  86914. */
  86915. getCaps(): EngineCapabilities;
  86916. /**
  86917. * Gets the current depth function
  86918. * @returns a number defining the depth function
  86919. */
  86920. getDepthFunction(): Nullable<number>;
  86921. /**
  86922. * Sets the current depth function
  86923. * @param depthFunc defines the function to use
  86924. */
  86925. setDepthFunction(depthFunc: number): void;
  86926. /**
  86927. * Sets the current depth function to GREATER
  86928. */
  86929. setDepthFunctionToGreater(): void;
  86930. /**
  86931. * Sets the current depth function to GEQUAL
  86932. */
  86933. setDepthFunctionToGreaterOrEqual(): void;
  86934. /**
  86935. * Sets the current depth function to LESS
  86936. */
  86937. setDepthFunctionToLess(): void;
  86938. private _cachedStencilBuffer;
  86939. private _cachedStencilFunction;
  86940. private _cachedStencilMask;
  86941. private _cachedStencilOperationPass;
  86942. private _cachedStencilOperationFail;
  86943. private _cachedStencilOperationDepthFail;
  86944. private _cachedStencilReference;
  86945. /**
  86946. * Caches the the state of the stencil buffer
  86947. */
  86948. cacheStencilState(): void;
  86949. /**
  86950. * Restores the state of the stencil buffer
  86951. */
  86952. restoreStencilState(): void;
  86953. /**
  86954. * Sets the current depth function to LEQUAL
  86955. */
  86956. setDepthFunctionToLessOrEqual(): void;
  86957. /**
  86958. * Gets a boolean indicating if stencil buffer is enabled
  86959. * @returns the current stencil buffer state
  86960. */
  86961. getStencilBuffer(): boolean;
  86962. /**
  86963. * Enable or disable the stencil buffer
  86964. * @param enable defines if the stencil buffer must be enabled or disabled
  86965. */
  86966. setStencilBuffer(enable: boolean): void;
  86967. /**
  86968. * Gets the current stencil mask
  86969. * @returns a number defining the new stencil mask to use
  86970. */
  86971. getStencilMask(): number;
  86972. /**
  86973. * Sets the current stencil mask
  86974. * @param mask defines the new stencil mask to use
  86975. */
  86976. setStencilMask(mask: number): void;
  86977. /**
  86978. * Gets the current stencil function
  86979. * @returns a number defining the stencil function to use
  86980. */
  86981. getStencilFunction(): number;
  86982. /**
  86983. * Gets the current stencil reference value
  86984. * @returns a number defining the stencil reference value to use
  86985. */
  86986. getStencilFunctionReference(): number;
  86987. /**
  86988. * Gets the current stencil mask
  86989. * @returns a number defining the stencil mask to use
  86990. */
  86991. getStencilFunctionMask(): number;
  86992. /**
  86993. * Sets the current stencil function
  86994. * @param stencilFunc defines the new stencil function to use
  86995. */
  86996. setStencilFunction(stencilFunc: number): void;
  86997. /**
  86998. * Sets the current stencil reference
  86999. * @param reference defines the new stencil reference to use
  87000. */
  87001. setStencilFunctionReference(reference: number): void;
  87002. /**
  87003. * Sets the current stencil mask
  87004. * @param mask defines the new stencil mask to use
  87005. */
  87006. setStencilFunctionMask(mask: number): void;
  87007. /**
  87008. * Gets the current stencil operation when stencil fails
  87009. * @returns a number defining stencil operation to use when stencil fails
  87010. */
  87011. getStencilOperationFail(): number;
  87012. /**
  87013. * Gets the current stencil operation when depth fails
  87014. * @returns a number defining stencil operation to use when depth fails
  87015. */
  87016. getStencilOperationDepthFail(): number;
  87017. /**
  87018. * Gets the current stencil operation when stencil passes
  87019. * @returns a number defining stencil operation to use when stencil passes
  87020. */
  87021. getStencilOperationPass(): number;
  87022. /**
  87023. * Sets the stencil operation to use when stencil fails
  87024. * @param operation defines the stencil operation to use when stencil fails
  87025. */
  87026. setStencilOperationFail(operation: number): void;
  87027. /**
  87028. * Sets the stencil operation to use when depth fails
  87029. * @param operation defines the stencil operation to use when depth fails
  87030. */
  87031. setStencilOperationDepthFail(operation: number): void;
  87032. /**
  87033. * Sets the stencil operation to use when stencil passes
  87034. * @param operation defines the stencil operation to use when stencil passes
  87035. */
  87036. setStencilOperationPass(operation: number): void;
  87037. /**
  87038. * Sets a boolean indicating if the dithering state is enabled or disabled
  87039. * @param value defines the dithering state
  87040. */
  87041. setDitheringState(value: boolean): void;
  87042. /**
  87043. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87044. * @param value defines the rasterizer state
  87045. */
  87046. setRasterizerState(value: boolean): void;
  87047. /**
  87048. * stop executing a render loop function and remove it from the execution array
  87049. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87050. */
  87051. stopRenderLoop(renderFunction?: () => void): void;
  87052. /** @hidden */
  87053. _renderLoop(): void;
  87054. /**
  87055. * Register and execute a render loop. The engine can have more than one render function
  87056. * @param renderFunction defines the function to continuously execute
  87057. */
  87058. runRenderLoop(renderFunction: () => void): void;
  87059. /**
  87060. * Toggle full screen mode
  87061. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87062. */
  87063. switchFullscreen(requestPointerLock: boolean): void;
  87064. /**
  87065. * Enters full screen mode
  87066. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87067. */
  87068. enterFullscreen(requestPointerLock: boolean): void;
  87069. /**
  87070. * Exits full screen mode
  87071. */
  87072. exitFullscreen(): void;
  87073. /**
  87074. * Clear the current render buffer or the current render target (if any is set up)
  87075. * @param color defines the color to use
  87076. * @param backBuffer defines if the back buffer must be cleared
  87077. * @param depth defines if the depth buffer must be cleared
  87078. * @param stencil defines if the stencil buffer must be cleared
  87079. */
  87080. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87081. /**
  87082. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87083. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87084. * @param y defines the y-coordinate of the corner of the clear rectangle
  87085. * @param width defines the width of the clear rectangle
  87086. * @param height defines the height of the clear rectangle
  87087. * @param clearColor defines the clear color
  87088. */
  87089. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87090. /**
  87091. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87092. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87093. * @param y defines the y-coordinate of the corner of the clear rectangle
  87094. * @param width defines the width of the clear rectangle
  87095. * @param height defines the height of the clear rectangle
  87096. */
  87097. enableScissor(x: number, y: number, width: number, height: number): void;
  87098. /**
  87099. * Disable previously set scissor test rectangle
  87100. */
  87101. disableScissor(): void;
  87102. private _viewportCached;
  87103. /** @hidden */
  87104. _viewport(x: number, y: number, width: number, height: number): void;
  87105. /**
  87106. * Set the WebGL's viewport
  87107. * @param viewport defines the viewport element to be used
  87108. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87109. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87110. */
  87111. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87112. /**
  87113. * Directly set the WebGL Viewport
  87114. * @param x defines the x coordinate of the viewport (in screen space)
  87115. * @param y defines the y coordinate of the viewport (in screen space)
  87116. * @param width defines the width of the viewport (in screen space)
  87117. * @param height defines the height of the viewport (in screen space)
  87118. * @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
  87119. */
  87120. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87121. /**
  87122. * Begin a new frame
  87123. */
  87124. beginFrame(): void;
  87125. /**
  87126. * Enf the current frame
  87127. */
  87128. endFrame(): void;
  87129. /**
  87130. * Resize the view according to the canvas' size
  87131. */
  87132. resize(): void;
  87133. /**
  87134. * Force a specific size of the canvas
  87135. * @param width defines the new canvas' width
  87136. * @param height defines the new canvas' height
  87137. */
  87138. setSize(width: number, height: number): void;
  87139. /**
  87140. * Gets a boolean indicating if a webVR device was detected
  87141. * @returns true if a webVR device was detected
  87142. */
  87143. isVRDevicePresent(): boolean;
  87144. /**
  87145. * Gets the current webVR device
  87146. * @returns the current webVR device (or null)
  87147. */
  87148. getVRDevice(): any;
  87149. /**
  87150. * Initializes a webVR display and starts listening to display change events
  87151. * The onVRDisplayChangedObservable will be notified upon these changes
  87152. * @returns The onVRDisplayChangedObservable
  87153. */
  87154. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87155. /**
  87156. * Initializes a webVR display and starts listening to display change events
  87157. * The onVRDisplayChangedObservable will be notified upon these changes
  87158. * @returns A promise containing a VRDisplay and if vr is supported
  87159. */
  87160. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87161. /**
  87162. * Call this function to switch to webVR mode
  87163. * Will do nothing if webVR is not supported or if there is no webVR device
  87164. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87165. */
  87166. enableVR(): void;
  87167. /**
  87168. * Call this function to leave webVR mode
  87169. * Will do nothing if webVR is not supported or if there is no webVR device
  87170. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87171. */
  87172. disableVR(): void;
  87173. private _onVRFullScreenTriggered;
  87174. private _getVRDisplaysAsync;
  87175. /**
  87176. * Binds the frame buffer to the specified texture.
  87177. * @param texture The texture to render to or null for the default canvas
  87178. * @param faceIndex The face of the texture to render to in case of cube texture
  87179. * @param requiredWidth The width of the target to render to
  87180. * @param requiredHeight The height of the target to render to
  87181. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87182. * @param depthStencilTexture The depth stencil texture to use to render
  87183. * @param lodLevel defines le lod level to bind to the frame buffer
  87184. */
  87185. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87186. private bindUnboundFramebuffer;
  87187. /**
  87188. * Unbind the current render target texture from the webGL context
  87189. * @param texture defines the render target texture to unbind
  87190. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87191. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87192. */
  87193. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87194. /**
  87195. * Unbind a list of render target textures from the webGL context
  87196. * This is used only when drawBuffer extension or webGL2 are active
  87197. * @param textures defines the render target textures to unbind
  87198. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87199. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87200. */
  87201. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87202. /**
  87203. * Force the mipmap generation for the given render target texture
  87204. * @param texture defines the render target texture to use
  87205. */
  87206. generateMipMapsForCubemap(texture: InternalTexture): void;
  87207. /**
  87208. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87209. */
  87210. flushFramebuffer(): void;
  87211. /**
  87212. * Unbind the current render target and bind the default framebuffer
  87213. */
  87214. restoreDefaultFramebuffer(): void;
  87215. /**
  87216. * Create an uniform buffer
  87217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87218. * @param elements defines the content of the uniform buffer
  87219. * @returns the webGL uniform buffer
  87220. */
  87221. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87222. /**
  87223. * Create a dynamic uniform buffer
  87224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87225. * @param elements defines the content of the uniform buffer
  87226. * @returns the webGL uniform buffer
  87227. */
  87228. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87229. /**
  87230. * Update an existing uniform buffer
  87231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87232. * @param uniformBuffer defines the target uniform buffer
  87233. * @param elements defines the content to update
  87234. * @param offset defines the offset in the uniform buffer where update should start
  87235. * @param count defines the size of the data to update
  87236. */
  87237. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87238. private _resetVertexBufferBinding;
  87239. /**
  87240. * Creates a vertex buffer
  87241. * @param data the data for the vertex buffer
  87242. * @returns the new WebGL static buffer
  87243. */
  87244. createVertexBuffer(data: DataArray): WebGLBuffer;
  87245. /**
  87246. * Creates a dynamic vertex buffer
  87247. * @param data the data for the dynamic vertex buffer
  87248. * @returns the new WebGL dynamic buffer
  87249. */
  87250. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87251. /**
  87252. * Update a dynamic index buffer
  87253. * @param indexBuffer defines the target index buffer
  87254. * @param indices defines the data to update
  87255. * @param offset defines the offset in the target index buffer where update should start
  87256. */
  87257. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87258. /**
  87259. * Updates a dynamic vertex buffer.
  87260. * @param vertexBuffer the vertex buffer to update
  87261. * @param data the data used to update the vertex buffer
  87262. * @param byteOffset the byte offset of the data
  87263. * @param byteLength the byte length of the data
  87264. */
  87265. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87266. private _resetIndexBufferBinding;
  87267. /**
  87268. * Creates a new index buffer
  87269. * @param indices defines the content of the index buffer
  87270. * @param updatable defines if the index buffer must be updatable
  87271. * @returns a new webGL buffer
  87272. */
  87273. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87274. /**
  87275. * Bind a webGL buffer to the webGL context
  87276. * @param buffer defines the buffer to bind
  87277. */
  87278. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87279. /**
  87280. * Bind an uniform buffer to the current webGL context
  87281. * @param buffer defines the buffer to bind
  87282. */
  87283. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87284. /**
  87285. * Bind a buffer to the current webGL context at a given location
  87286. * @param buffer defines the buffer to bind
  87287. * @param location defines the index where to bind the buffer
  87288. */
  87289. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87290. /**
  87291. * Bind a specific block at a given index in a specific shader program
  87292. * @param shaderProgram defines the shader program
  87293. * @param blockName defines the block name
  87294. * @param index defines the index where to bind the block
  87295. */
  87296. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87297. private bindIndexBuffer;
  87298. private bindBuffer;
  87299. /**
  87300. * update the bound buffer with the given data
  87301. * @param data defines the data to update
  87302. */
  87303. updateArrayBuffer(data: Float32Array): void;
  87304. private _vertexAttribPointer;
  87305. private _bindIndexBufferWithCache;
  87306. private _bindVertexBuffersAttributes;
  87307. /**
  87308. * Records a vertex array object
  87309. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87310. * @param vertexBuffers defines the list of vertex buffers to store
  87311. * @param indexBuffer defines the index buffer to store
  87312. * @param effect defines the effect to store
  87313. * @returns the new vertex array object
  87314. */
  87315. recordVertexArrayObject(vertexBuffers: {
  87316. [key: string]: VertexBuffer;
  87317. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87318. /**
  87319. * Bind a specific vertex array object
  87320. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87321. * @param vertexArrayObject defines the vertex array object to bind
  87322. * @param indexBuffer defines the index buffer to bind
  87323. */
  87324. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87325. /**
  87326. * Bind webGl buffers directly to the webGL context
  87327. * @param vertexBuffer defines the vertex buffer to bind
  87328. * @param indexBuffer defines the index buffer to bind
  87329. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87330. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87331. * @param effect defines the effect associated with the vertex buffer
  87332. */
  87333. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87334. private _unbindVertexArrayObject;
  87335. /**
  87336. * Bind a list of vertex buffers to the webGL context
  87337. * @param vertexBuffers defines the list of vertex buffers to bind
  87338. * @param indexBuffer defines the index buffer to bind
  87339. * @param effect defines the effect associated with the vertex buffers
  87340. */
  87341. bindBuffers(vertexBuffers: {
  87342. [key: string]: Nullable<VertexBuffer>;
  87343. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87344. /**
  87345. * Unbind all instance attributes
  87346. */
  87347. unbindInstanceAttributes(): void;
  87348. /**
  87349. * Release and free the memory of a vertex array object
  87350. * @param vao defines the vertex array object to delete
  87351. */
  87352. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87353. /** @hidden */
  87354. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87355. /**
  87356. * Creates a webGL buffer to use with instanciation
  87357. * @param capacity defines the size of the buffer
  87358. * @returns the webGL buffer
  87359. */
  87360. createInstancesBuffer(capacity: number): WebGLBuffer;
  87361. /**
  87362. * Delete a webGL buffer used with instanciation
  87363. * @param buffer defines the webGL buffer to delete
  87364. */
  87365. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87366. /**
  87367. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87368. * @param instancesBuffer defines the webGL buffer to update and bind
  87369. * @param data defines the data to store in the buffer
  87370. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87371. */
  87372. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87373. /**
  87374. * Apply all cached states (depth, culling, stencil and alpha)
  87375. */
  87376. applyStates(): void;
  87377. /**
  87378. * Send a draw order
  87379. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87380. * @param indexStart defines the starting index
  87381. * @param indexCount defines the number of index to draw
  87382. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87383. */
  87384. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87385. /**
  87386. * Draw a list of points
  87387. * @param verticesStart defines the index of first vertex to draw
  87388. * @param verticesCount defines the count of vertices to draw
  87389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87390. */
  87391. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87392. /**
  87393. * Draw a list of unindexed primitives
  87394. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87395. * @param verticesStart defines the index of first vertex to draw
  87396. * @param verticesCount defines the count of vertices to draw
  87397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87398. */
  87399. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87400. /**
  87401. * Draw a list of indexed primitives
  87402. * @param fillMode defines the primitive to use
  87403. * @param indexStart defines the starting index
  87404. * @param indexCount defines the number of index to draw
  87405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87406. */
  87407. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87408. /**
  87409. * Draw a list of unindexed primitives
  87410. * @param fillMode defines the primitive to use
  87411. * @param verticesStart defines the index of first vertex to draw
  87412. * @param verticesCount defines the count of vertices to draw
  87413. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87414. */
  87415. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87416. private _drawMode;
  87417. /** @hidden */
  87418. _releaseEffect(effect: Effect): void;
  87419. /** @hidden */
  87420. _deleteProgram(program: WebGLProgram): void;
  87421. /**
  87422. * Create a new effect (used to store vertex/fragment shaders)
  87423. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87424. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87425. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87426. * @param samplers defines an array of string used to represent textures
  87427. * @param defines defines the string containing the defines to use to compile the shaders
  87428. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87429. * @param onCompiled defines a function to call when the effect creation is successful
  87430. * @param onError defines a function to call when the effect creation has failed
  87431. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87432. * @returns the new Effect
  87433. */
  87434. 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;
  87435. private _compileShader;
  87436. private _compileRawShader;
  87437. /**
  87438. * Directly creates a webGL program
  87439. * @param vertexCode defines the vertex shader code to use
  87440. * @param fragmentCode defines the fragment shader code to use
  87441. * @param context defines the webGL context to use (if not set, the current one will be used)
  87442. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87443. * @returns the new webGL program
  87444. */
  87445. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87446. /**
  87447. * Creates a webGL program
  87448. * @param vertexCode defines the vertex shader code to use
  87449. * @param fragmentCode defines the fragment shader code to use
  87450. * @param defines defines the string containing the defines to use to compile the shaders
  87451. * @param context defines the webGL context to use (if not set, the current one will be used)
  87452. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87453. * @returns the new webGL program
  87454. */
  87455. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87456. private _createShaderProgram;
  87457. private _finalizeProgram;
  87458. /** @hidden */
  87459. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87460. /** @hidden */
  87461. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87462. /**
  87463. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87464. * @param shaderProgram defines the webGL program to use
  87465. * @param uniformsNames defines the list of uniform names
  87466. * @returns an array of webGL uniform locations
  87467. */
  87468. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87469. /**
  87470. * Gets the lsit of active attributes for a given webGL program
  87471. * @param shaderProgram defines the webGL program to use
  87472. * @param attributesNames defines the list of attribute names to get
  87473. * @returns an array of indices indicating the offset of each attribute
  87474. */
  87475. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87476. /**
  87477. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87478. * @param effect defines the effect to activate
  87479. */
  87480. enableEffect(effect: Nullable<Effect>): void;
  87481. /**
  87482. * Set the value of an uniform to an array of int32
  87483. * @param uniform defines the webGL uniform location where to store the value
  87484. * @param array defines the array of int32 to store
  87485. */
  87486. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87487. /**
  87488. * Set the value of an uniform to an array of int32 (stored as vec2)
  87489. * @param uniform defines the webGL uniform location where to store the value
  87490. * @param array defines the array of int32 to store
  87491. */
  87492. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87493. /**
  87494. * Set the value of an uniform to an array of int32 (stored as vec3)
  87495. * @param uniform defines the webGL uniform location where to store the value
  87496. * @param array defines the array of int32 to store
  87497. */
  87498. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87499. /**
  87500. * Set the value of an uniform to an array of int32 (stored as vec4)
  87501. * @param uniform defines the webGL uniform location where to store the value
  87502. * @param array defines the array of int32 to store
  87503. */
  87504. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87505. /**
  87506. * Set the value of an uniform to an array of float32
  87507. * @param uniform defines the webGL uniform location where to store the value
  87508. * @param array defines the array of float32 to store
  87509. */
  87510. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87511. /**
  87512. * Set the value of an uniform to an array of float32 (stored as vec2)
  87513. * @param uniform defines the webGL uniform location where to store the value
  87514. * @param array defines the array of float32 to store
  87515. */
  87516. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87517. /**
  87518. * Set the value of an uniform to an array of float32 (stored as vec3)
  87519. * @param uniform defines the webGL uniform location where to store the value
  87520. * @param array defines the array of float32 to store
  87521. */
  87522. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87523. /**
  87524. * Set the value of an uniform to an array of float32 (stored as vec4)
  87525. * @param uniform defines the webGL uniform location where to store the value
  87526. * @param array defines the array of float32 to store
  87527. */
  87528. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87529. /**
  87530. * Set the value of an uniform to an array of number
  87531. * @param uniform defines the webGL uniform location where to store the value
  87532. * @param array defines the array of number to store
  87533. */
  87534. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87535. /**
  87536. * Set the value of an uniform to an array of number (stored as vec2)
  87537. * @param uniform defines the webGL uniform location where to store the value
  87538. * @param array defines the array of number to store
  87539. */
  87540. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87541. /**
  87542. * Set the value of an uniform to an array of number (stored as vec3)
  87543. * @param uniform defines the webGL uniform location where to store the value
  87544. * @param array defines the array of number to store
  87545. */
  87546. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87547. /**
  87548. * Set the value of an uniform to an array of number (stored as vec4)
  87549. * @param uniform defines the webGL uniform location where to store the value
  87550. * @param array defines the array of number to store
  87551. */
  87552. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87553. /**
  87554. * Set the value of an uniform to an array of float32 (stored as matrices)
  87555. * @param uniform defines the webGL uniform location where to store the value
  87556. * @param matrices defines the array of float32 to store
  87557. */
  87558. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87559. /**
  87560. * Set the value of an uniform to a matrix
  87561. * @param uniform defines the webGL uniform location where to store the value
  87562. * @param matrix defines the matrix to store
  87563. */
  87564. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87565. /**
  87566. * Set the value of an uniform to a matrix (3x3)
  87567. * @param uniform defines the webGL uniform location where to store the value
  87568. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87569. */
  87570. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87571. /**
  87572. * Set the value of an uniform to a matrix (2x2)
  87573. * @param uniform defines the webGL uniform location where to store the value
  87574. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87575. */
  87576. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87577. /**
  87578. * Set the value of an uniform to a number (int)
  87579. * @param uniform defines the webGL uniform location where to store the value
  87580. * @param value defines the int number to store
  87581. */
  87582. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87583. /**
  87584. * Set the value of an uniform to a number (float)
  87585. * @param uniform defines the webGL uniform location where to store the value
  87586. * @param value defines the float number to store
  87587. */
  87588. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87589. /**
  87590. * Set the value of an uniform to a vec2
  87591. * @param uniform defines the webGL uniform location where to store the value
  87592. * @param x defines the 1st component of the value
  87593. * @param y defines the 2nd component of the value
  87594. */
  87595. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87596. /**
  87597. * Set the value of an uniform to a vec3
  87598. * @param uniform defines the webGL uniform location where to store the value
  87599. * @param x defines the 1st component of the value
  87600. * @param y defines the 2nd component of the value
  87601. * @param z defines the 3rd component of the value
  87602. */
  87603. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87604. /**
  87605. * Set the value of an uniform to a boolean
  87606. * @param uniform defines the webGL uniform location where to store the value
  87607. * @param bool defines the boolean to store
  87608. */
  87609. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87610. /**
  87611. * Set the value of an uniform to a vec4
  87612. * @param uniform defines the webGL uniform location where to store the value
  87613. * @param x defines the 1st component of the value
  87614. * @param y defines the 2nd component of the value
  87615. * @param z defines the 3rd component of the value
  87616. * @param w defines the 4th component of the value
  87617. */
  87618. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87619. /**
  87620. * Set the value of an uniform to a Color3
  87621. * @param uniform defines the webGL uniform location where to store the value
  87622. * @param color3 defines the color to store
  87623. */
  87624. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87625. /**
  87626. * Set the value of an uniform to a Color3 and an alpha value
  87627. * @param uniform defines the webGL uniform location where to store the value
  87628. * @param color3 defines the color to store
  87629. * @param alpha defines the alpha component to store
  87630. */
  87631. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87632. /**
  87633. * Sets a Color4 on a uniform variable
  87634. * @param uniform defines the uniform location
  87635. * @param color4 defines the value to be set
  87636. */
  87637. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87638. /**
  87639. * Set various states to the webGL context
  87640. * @param culling defines backface culling state
  87641. * @param zOffset defines the value to apply to zOffset (0 by default)
  87642. * @param force defines if states must be applied even if cache is up to date
  87643. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87644. */
  87645. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87646. /**
  87647. * Set the z offset to apply to current rendering
  87648. * @param value defines the offset to apply
  87649. */
  87650. setZOffset(value: number): void;
  87651. /**
  87652. * Gets the current value of the zOffset
  87653. * @returns the current zOffset state
  87654. */
  87655. getZOffset(): number;
  87656. /**
  87657. * Enable or disable depth buffering
  87658. * @param enable defines the state to set
  87659. */
  87660. setDepthBuffer(enable: boolean): void;
  87661. /**
  87662. * Gets a boolean indicating if depth writing is enabled
  87663. * @returns the current depth writing state
  87664. */
  87665. getDepthWrite(): boolean;
  87666. /**
  87667. * Enable or disable depth writing
  87668. * @param enable defines the state to set
  87669. */
  87670. setDepthWrite(enable: boolean): void;
  87671. /**
  87672. * Enable or disable color writing
  87673. * @param enable defines the state to set
  87674. */
  87675. setColorWrite(enable: boolean): void;
  87676. /**
  87677. * Gets a boolean indicating if color writing is enabled
  87678. * @returns the current color writing state
  87679. */
  87680. getColorWrite(): boolean;
  87681. /**
  87682. * Sets alpha constants used by some alpha blending modes
  87683. * @param r defines the red component
  87684. * @param g defines the green component
  87685. * @param b defines the blue component
  87686. * @param a defines the alpha component
  87687. */
  87688. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87689. /**
  87690. * Sets the current alpha mode
  87691. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87692. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87694. */
  87695. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87696. /**
  87697. * Gets the current alpha mode
  87698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87699. * @returns the current alpha mode
  87700. */
  87701. getAlphaMode(): number;
  87702. /**
  87703. * Clears the list of texture accessible through engine.
  87704. * This can help preventing texture load conflict due to name collision.
  87705. */
  87706. clearInternalTexturesCache(): void;
  87707. /**
  87708. * Force the entire cache to be cleared
  87709. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87710. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87711. */
  87712. wipeCaches(bruteForce?: boolean): void;
  87713. /**
  87714. * Set the compressed texture format to use, based on the formats you have, and the formats
  87715. * supported by the hardware / browser.
  87716. *
  87717. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87718. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87719. * to API arguments needed to compressed textures. This puts the burden on the container
  87720. * generator to house the arcane code for determining these for current & future formats.
  87721. *
  87722. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87723. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87724. *
  87725. * Note: The result of this call is not taken into account when a texture is base64.
  87726. *
  87727. * @param formatsAvailable defines the list of those format families you have created
  87728. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87729. *
  87730. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87731. * @returns The extension selected.
  87732. */
  87733. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87734. private _getSamplingParameters;
  87735. private _partialLoadImg;
  87736. private _cascadeLoadImgs;
  87737. /** @hidden */
  87738. _createTexture(): WebGLTexture;
  87739. /**
  87740. * Usually called from Texture.ts.
  87741. * Passed information to create a WebGLTexture
  87742. * @param urlArg defines a value which contains one of the following:
  87743. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87744. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87745. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87746. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87747. * @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)
  87748. * @param scene needed for loading to the correct scene
  87749. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87750. * @param onLoad optional callback to be called upon successful completion
  87751. * @param onError optional callback to be called upon failure
  87752. * @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
  87753. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87754. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87755. * @param forcedExtension defines the extension to use to pick the right loader
  87756. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87757. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87758. */
  87759. 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;
  87760. private _rescaleTexture;
  87761. /**
  87762. * Update a raw texture
  87763. * @param texture defines the texture to update
  87764. * @param data defines the data to store in the texture
  87765. * @param format defines the format of the data
  87766. * @param invertY defines if data must be stored with Y axis inverted
  87767. * @param compression defines the compression used (null by default)
  87768. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87769. */
  87770. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87771. /**
  87772. * Creates a raw texture
  87773. * @param data defines the data to store in the texture
  87774. * @param width defines the width of the texture
  87775. * @param height defines the height of the texture
  87776. * @param format defines the format of the data
  87777. * @param generateMipMaps defines if the engine should generate the mip levels
  87778. * @param invertY defines if data must be stored with Y axis inverted
  87779. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87780. * @param compression defines the compression used (null by default)
  87781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87782. * @returns the raw texture inside an InternalTexture
  87783. */
  87784. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87785. private _unpackFlipYCached;
  87786. /**
  87787. * In case you are sharing the context with other applications, it might
  87788. * be interested to not cache the unpack flip y state to ensure a consistent
  87789. * value would be set.
  87790. */
  87791. enableUnpackFlipYCached: boolean;
  87792. /** @hidden */
  87793. _unpackFlipY(value: boolean): void;
  87794. /** @hidden */
  87795. _getUnpackAlignement(): number;
  87796. /**
  87797. * Creates a dynamic texture
  87798. * @param width defines the width of the texture
  87799. * @param height defines the height of the texture
  87800. * @param generateMipMaps defines if the engine should generate the mip levels
  87801. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87802. * @returns the dynamic texture inside an InternalTexture
  87803. */
  87804. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87805. /**
  87806. * Update the sampling mode of a given texture
  87807. * @param samplingMode defines the required sampling mode
  87808. * @param texture defines the texture to update
  87809. */
  87810. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87811. /**
  87812. * Update the content of a dynamic texture
  87813. * @param texture defines the texture to update
  87814. * @param canvas defines the canvas containing the source
  87815. * @param invertY defines if data must be stored with Y axis inverted
  87816. * @param premulAlpha defines if alpha is stored as premultiplied
  87817. * @param format defines the format of the data
  87818. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87819. */
  87820. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87821. /**
  87822. * Update a video texture
  87823. * @param texture defines the texture to update
  87824. * @param video defines the video element to use
  87825. * @param invertY defines if data must be stored with Y axis inverted
  87826. */
  87827. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87828. /**
  87829. * Updates a depth texture Comparison Mode and Function.
  87830. * If the comparison Function is equal to 0, the mode will be set to none.
  87831. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87832. * @param texture The texture to set the comparison function for
  87833. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87834. */
  87835. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87836. private _setupDepthStencilTexture;
  87837. /**
  87838. * Creates a depth stencil texture.
  87839. * This is only available in WebGL 2 or with the depth texture extension available.
  87840. * @param size The size of face edge in the texture.
  87841. * @param options The options defining the texture.
  87842. * @returns The texture
  87843. */
  87844. createDepthStencilTexture(size: number | {
  87845. width: number;
  87846. height: number;
  87847. }, options: DepthTextureCreationOptions): InternalTexture;
  87848. /**
  87849. * Creates a depth stencil texture.
  87850. * This is only available in WebGL 2 or with the depth texture extension available.
  87851. * @param size The size of face edge in the texture.
  87852. * @param options The options defining the texture.
  87853. * @returns The texture
  87854. */
  87855. private _createDepthStencilTexture;
  87856. /**
  87857. * Creates a depth stencil cube texture.
  87858. * This is only available in WebGL 2.
  87859. * @param size The size of face edge in the cube texture.
  87860. * @param options The options defining the cube texture.
  87861. * @returns The cube texture
  87862. */
  87863. private _createDepthStencilCubeTexture;
  87864. /**
  87865. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87866. * @param renderTarget The render target to set the frame buffer for
  87867. */
  87868. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87869. /**
  87870. * Creates a new render target texture
  87871. * @param size defines the size of the texture
  87872. * @param options defines the options used to create the texture
  87873. * @returns a new render target texture stored in an InternalTexture
  87874. */
  87875. createRenderTargetTexture(size: number | {
  87876. width: number;
  87877. height: number;
  87878. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87879. /**
  87880. * Create a multi render target texture
  87881. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87882. * @param size defines the size of the texture
  87883. * @param options defines the creation options
  87884. * @returns the cube texture as an InternalTexture
  87885. */
  87886. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87887. private _setupFramebufferDepthAttachments;
  87888. /**
  87889. * Updates the sample count of a render target texture
  87890. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87891. * @param texture defines the texture to update
  87892. * @param samples defines the sample count to set
  87893. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87894. */
  87895. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87896. /**
  87897. * Update the sample count for a given multiple render target texture
  87898. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87899. * @param textures defines the textures to update
  87900. * @param samples defines the sample count to set
  87901. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87902. */
  87903. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87904. /** @hidden */
  87905. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87906. /** @hidden */
  87907. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87908. /** @hidden */
  87909. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87910. /** @hidden */
  87911. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87912. /**
  87913. * Creates a new render target cube texture
  87914. * @param size defines the size of the texture
  87915. * @param options defines the options used to create the texture
  87916. * @returns a new render target cube texture stored in an InternalTexture
  87917. */
  87918. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87919. /**
  87920. * Creates a cube texture
  87921. * @param rootUrl defines the url where the files to load is located
  87922. * @param scene defines the current scene
  87923. * @param files defines the list of files to load (1 per face)
  87924. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87925. * @param onLoad defines an optional callback raised when the texture is loaded
  87926. * @param onError defines an optional callback raised if there is an issue to load the texture
  87927. * @param format defines the format of the data
  87928. * @param forcedExtension defines the extension to use to pick the right loader
  87929. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87932. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87933. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87934. * @returns the cube texture as an InternalTexture
  87935. */
  87936. 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;
  87937. /**
  87938. * @hidden
  87939. */
  87940. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87941. /**
  87942. * Update a raw cube texture
  87943. * @param texture defines the texture to udpdate
  87944. * @param data defines the data to store
  87945. * @param format defines the data format
  87946. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87947. * @param invertY defines if data must be stored with Y axis inverted
  87948. * @param compression defines the compression used (null by default)
  87949. * @param level defines which level of the texture to update
  87950. */
  87951. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87952. /**
  87953. * Creates a new raw cube texture
  87954. * @param data defines the array of data to use to create each face
  87955. * @param size defines the size of the textures
  87956. * @param format defines the format of the data
  87957. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87958. * @param generateMipMaps defines if the engine should generate the mip levels
  87959. * @param invertY defines if data must be stored with Y axis inverted
  87960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87961. * @param compression defines the compression used (null by default)
  87962. * @returns the cube texture as an InternalTexture
  87963. */
  87964. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87965. /**
  87966. * Creates a new raw cube texture from a specified url
  87967. * @param url defines the url where the data is located
  87968. * @param scene defines the current scene
  87969. * @param size defines the size of the textures
  87970. * @param format defines the format of the data
  87971. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87972. * @param noMipmap defines if the engine should avoid generating the mip levels
  87973. * @param callback defines a callback used to extract texture data from loaded data
  87974. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87975. * @param onLoad defines a callback called when texture is loaded
  87976. * @param onError defines a callback called if there is an error
  87977. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87978. * @param invertY defines if data must be stored with Y axis inverted
  87979. * @returns the cube texture as an InternalTexture
  87980. */
  87981. 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;
  87982. /**
  87983. * Update a raw 3D texture
  87984. * @param texture defines the texture to update
  87985. * @param data defines the data to store
  87986. * @param format defines the data format
  87987. * @param invertY defines if data must be stored with Y axis inverted
  87988. * @param compression defines the used compression (can be null)
  87989. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87990. */
  87991. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87992. /**
  87993. * Creates a new raw 3D texture
  87994. * @param data defines the data used to create the texture
  87995. * @param width defines the width of the texture
  87996. * @param height defines the height of the texture
  87997. * @param depth defines the depth of the texture
  87998. * @param format defines the format of the texture
  87999. * @param generateMipMaps defines if the engine must generate mip levels
  88000. * @param invertY defines if data must be stored with Y axis inverted
  88001. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88002. * @param compression defines the compressed used (can be null)
  88003. * @param textureType defines the compressed used (can be null)
  88004. * @returns a new raw 3D texture (stored in an InternalTexture)
  88005. */
  88006. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  88007. private _prepareWebGLTextureContinuation;
  88008. private _prepareWebGLTexture;
  88009. private _convertRGBtoRGBATextureData;
  88010. /** @hidden */
  88011. _releaseFramebufferObjects(texture: InternalTexture): void;
  88012. /** @hidden */
  88013. _releaseTexture(texture: InternalTexture): void;
  88014. private setProgram;
  88015. private _boundUniforms;
  88016. /**
  88017. * Binds an effect to the webGL context
  88018. * @param effect defines the effect to bind
  88019. */
  88020. bindSamplers(effect: Effect): void;
  88021. private _moveBoundTextureOnTop;
  88022. private _getCorrectTextureChannel;
  88023. private _linkTrackers;
  88024. private _removeDesignatedSlot;
  88025. private _activateCurrentTexture;
  88026. /** @hidden */
  88027. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88028. /** @hidden */
  88029. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88030. /**
  88031. * Sets a texture to the webGL context from a postprocess
  88032. * @param channel defines the channel to use
  88033. * @param postProcess defines the source postprocess
  88034. */
  88035. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88036. /**
  88037. * Binds the output of the passed in post process to the texture channel specified
  88038. * @param channel The channel the texture should be bound to
  88039. * @param postProcess The post process which's output should be bound
  88040. */
  88041. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88042. /**
  88043. * Unbind all textures from the webGL context
  88044. */
  88045. unbindAllTextures(): void;
  88046. /**
  88047. * Sets a texture to the according uniform.
  88048. * @param channel The texture channel
  88049. * @param uniform The uniform to set
  88050. * @param texture The texture to apply
  88051. */
  88052. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88053. /**
  88054. * Sets a depth stencil texture from a render target to the according uniform.
  88055. * @param channel The texture channel
  88056. * @param uniform The uniform to set
  88057. * @param texture The render target texture containing the depth stencil texture to apply
  88058. */
  88059. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88060. private _bindSamplerUniformToChannel;
  88061. private _getTextureWrapMode;
  88062. private _setTexture;
  88063. /**
  88064. * Sets an array of texture to the webGL context
  88065. * @param channel defines the channel where the texture array must be set
  88066. * @param uniform defines the associated uniform location
  88067. * @param textures defines the array of textures to bind
  88068. */
  88069. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88070. /** @hidden */
  88071. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88072. private _setTextureParameterFloat;
  88073. private _setTextureParameterInteger;
  88074. /**
  88075. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88076. * @param x defines the x coordinate of the rectangle where pixels must be read
  88077. * @param y defines the y coordinate of the rectangle where pixels must be read
  88078. * @param width defines the width of the rectangle where pixels must be read
  88079. * @param height defines the height of the rectangle where pixels must be read
  88080. * @returns a Uint8Array containing RGBA colors
  88081. */
  88082. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88083. /**
  88084. * Add an externaly attached data from its key.
  88085. * This method call will fail and return false, if such key already exists.
  88086. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88087. * @param key the unique key that identifies the data
  88088. * @param data the data object to associate to the key for this Engine instance
  88089. * @return true if no such key were already present and the data was added successfully, false otherwise
  88090. */
  88091. addExternalData<T>(key: string, data: T): boolean;
  88092. /**
  88093. * Get an externaly attached data from its key
  88094. * @param key the unique key that identifies the data
  88095. * @return the associated data, if present (can be null), or undefined if not present
  88096. */
  88097. getExternalData<T>(key: string): T;
  88098. /**
  88099. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88100. * @param key the unique key that identifies the data
  88101. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88102. * @return the associated data, can be null if the factory returned null.
  88103. */
  88104. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88105. /**
  88106. * Remove an externaly attached data from the Engine instance
  88107. * @param key the unique key that identifies the data
  88108. * @return true if the data was successfully removed, false if it doesn't exist
  88109. */
  88110. removeExternalData(key: string): boolean;
  88111. /**
  88112. * Unbind all vertex attributes from the webGL context
  88113. */
  88114. unbindAllAttributes(): void;
  88115. /**
  88116. * 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
  88117. */
  88118. releaseEffects(): void;
  88119. /**
  88120. * Dispose and release all associated resources
  88121. */
  88122. dispose(): void;
  88123. /**
  88124. * Display the loading screen
  88125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88126. */
  88127. displayLoadingUI(): void;
  88128. /**
  88129. * Hide the loading screen
  88130. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88131. */
  88132. hideLoadingUI(): void;
  88133. /**
  88134. * Gets the current loading screen object
  88135. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88136. */
  88137. /**
  88138. * Sets the current loading screen object
  88139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88140. */
  88141. loadingScreen: ILoadingScreen;
  88142. /**
  88143. * Sets the current loading screen text
  88144. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88145. */
  88146. loadingUIText: string;
  88147. /**
  88148. * Sets the current loading screen background color
  88149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88150. */
  88151. loadingUIBackgroundColor: string;
  88152. /**
  88153. * Attach a new callback raised when context lost event is fired
  88154. * @param callback defines the callback to call
  88155. */
  88156. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88157. /**
  88158. * Attach a new callback raised when context restored event is fired
  88159. * @param callback defines the callback to call
  88160. */
  88161. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88162. /**
  88163. * Gets the source code of the vertex shader associated with a specific webGL program
  88164. * @param program defines the program to use
  88165. * @returns a string containing the source code of the vertex shader associated with the program
  88166. */
  88167. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88168. /**
  88169. * Gets the source code of the fragment shader associated with a specific webGL program
  88170. * @param program defines the program to use
  88171. * @returns a string containing the source code of the fragment shader associated with the program
  88172. */
  88173. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88174. /**
  88175. * Get the current error code of the webGL context
  88176. * @returns the error code
  88177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88178. */
  88179. getError(): number;
  88180. /**
  88181. * Gets the current framerate
  88182. * @returns a number representing the framerate
  88183. */
  88184. getFps(): number;
  88185. /**
  88186. * Gets the time spent between current and previous frame
  88187. * @returns a number representing the delta time in ms
  88188. */
  88189. getDeltaTime(): number;
  88190. private _measureFps;
  88191. /** @hidden */
  88192. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88193. private _canRenderToFloatFramebuffer;
  88194. private _canRenderToHalfFloatFramebuffer;
  88195. private _canRenderToFramebuffer;
  88196. /** @hidden */
  88197. _getWebGLTextureType(type: number): number;
  88198. private _getInternalFormat;
  88199. /** @hidden */
  88200. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88201. /** @hidden */
  88202. _getRGBAMultiSampleBufferFormat(type: number): number;
  88203. /** @hidden */
  88204. _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;
  88205. /** @hidden */
  88206. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88207. private _partialLoadFile;
  88208. private _cascadeLoadFiles;
  88209. /**
  88210. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88211. * @returns true if the engine can be created
  88212. * @ignorenaming
  88213. */
  88214. static isSupported(): boolean;
  88215. }
  88216. }
  88217. declare module BABYLON {
  88218. /**
  88219. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88220. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88221. */
  88222. export class EffectFallbacks {
  88223. private _defines;
  88224. private _currentRank;
  88225. private _maxRank;
  88226. private _mesh;
  88227. /**
  88228. * Removes the fallback from the bound mesh.
  88229. */
  88230. unBindMesh(): void;
  88231. /**
  88232. * Adds a fallback on the specified property.
  88233. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88234. * @param define The name of the define in the shader
  88235. */
  88236. addFallback(rank: number, define: string): void;
  88237. /**
  88238. * Sets the mesh to use CPU skinning when needing to fallback.
  88239. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88240. * @param mesh The mesh to use the fallbacks.
  88241. */
  88242. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88243. /**
  88244. * Checks to see if more fallbacks are still availible.
  88245. */
  88246. readonly isMoreFallbacks: boolean;
  88247. /**
  88248. * Removes the defines that shoould be removed when falling back.
  88249. * @param currentDefines defines the current define statements for the shader.
  88250. * @param effect defines the current effect we try to compile
  88251. * @returns The resulting defines with defines of the current rank removed.
  88252. */
  88253. reduce(currentDefines: string, effect: Effect): string;
  88254. }
  88255. /**
  88256. * Options to be used when creating an effect.
  88257. */
  88258. export class EffectCreationOptions {
  88259. /**
  88260. * Atrributes that will be used in the shader.
  88261. */
  88262. attributes: string[];
  88263. /**
  88264. * Uniform varible names that will be set in the shader.
  88265. */
  88266. uniformsNames: string[];
  88267. /**
  88268. * Uniform buffer varible names that will be set in the shader.
  88269. */
  88270. uniformBuffersNames: string[];
  88271. /**
  88272. * Sampler texture variable names that will be set in the shader.
  88273. */
  88274. samplers: string[];
  88275. /**
  88276. * Define statements that will be set in the shader.
  88277. */
  88278. defines: any;
  88279. /**
  88280. * Possible fallbacks for this effect to improve performance when needed.
  88281. */
  88282. fallbacks: Nullable<EffectFallbacks>;
  88283. /**
  88284. * Callback that will be called when the shader is compiled.
  88285. */
  88286. onCompiled: Nullable<(effect: Effect) => void>;
  88287. /**
  88288. * Callback that will be called if an error occurs during shader compilation.
  88289. */
  88290. onError: Nullable<(effect: Effect, errors: string) => void>;
  88291. /**
  88292. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88293. */
  88294. indexParameters: any;
  88295. /**
  88296. * Max number of lights that can be used in the shader.
  88297. */
  88298. maxSimultaneousLights: number;
  88299. /**
  88300. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88301. */
  88302. transformFeedbackVaryings: Nullable<string[]>;
  88303. }
  88304. /**
  88305. * Effect containing vertex and fragment shader that can be executed on an object.
  88306. */
  88307. export class Effect {
  88308. /**
  88309. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88310. */
  88311. static ShadersRepository: string;
  88312. /**
  88313. * Name of the effect.
  88314. */
  88315. name: any;
  88316. /**
  88317. * String container all the define statements that should be set on the shader.
  88318. */
  88319. defines: string;
  88320. /**
  88321. * Callback that will be called when the shader is compiled.
  88322. */
  88323. onCompiled: Nullable<(effect: Effect) => void>;
  88324. /**
  88325. * Callback that will be called if an error occurs during shader compilation.
  88326. */
  88327. onError: Nullable<(effect: Effect, errors: string) => void>;
  88328. /**
  88329. * Callback that will be called when effect is bound.
  88330. */
  88331. onBind: Nullable<(effect: Effect) => void>;
  88332. /**
  88333. * Unique ID of the effect.
  88334. */
  88335. uniqueId: number;
  88336. /**
  88337. * Observable that will be called when the shader is compiled.
  88338. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88339. */
  88340. onCompileObservable: Observable<Effect>;
  88341. /**
  88342. * Observable that will be called if an error occurs during shader compilation.
  88343. */
  88344. onErrorObservable: Observable<Effect>;
  88345. /** @hidden */
  88346. _onBindObservable: Nullable<Observable<Effect>>;
  88347. /**
  88348. * Observable that will be called when effect is bound.
  88349. */
  88350. readonly onBindObservable: Observable<Effect>;
  88351. /** @hidden */
  88352. _bonesComputationForcedToCPU: boolean;
  88353. private static _uniqueIdSeed;
  88354. private _engine;
  88355. private _uniformBuffersNames;
  88356. private _uniformsNames;
  88357. private _samplers;
  88358. private _isReady;
  88359. private _compilationError;
  88360. private _attributesNames;
  88361. private _attributes;
  88362. private _uniforms;
  88363. /**
  88364. * Key for the effect.
  88365. * @hidden
  88366. */
  88367. _key: string;
  88368. private _indexParameters;
  88369. private _fallbacks;
  88370. private _vertexSourceCode;
  88371. private _fragmentSourceCode;
  88372. private _vertexSourceCodeOverride;
  88373. private _fragmentSourceCodeOverride;
  88374. private _transformFeedbackVaryings;
  88375. /**
  88376. * Compiled shader to webGL program.
  88377. * @hidden
  88378. */
  88379. _program: WebGLProgram;
  88380. private _valueCache;
  88381. private static _baseCache;
  88382. /**
  88383. * Instantiates an effect.
  88384. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88385. * @param baseName Name of the effect.
  88386. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88387. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88388. * @param samplers List of sampler variables that will be passed to the shader.
  88389. * @param engine Engine to be used to render the effect
  88390. * @param defines Define statements to be added to the shader.
  88391. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88392. * @param onCompiled Callback that will be called when the shader is compiled.
  88393. * @param onError Callback that will be called if an error occurs during shader compilation.
  88394. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88395. */
  88396. 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);
  88397. /**
  88398. * Unique key for this effect
  88399. */
  88400. readonly key: string;
  88401. /**
  88402. * If the effect has been compiled and prepared.
  88403. * @returns if the effect is compiled and prepared.
  88404. */
  88405. isReady(): boolean;
  88406. /**
  88407. * The engine the effect was initialized with.
  88408. * @returns the engine.
  88409. */
  88410. getEngine(): Engine;
  88411. /**
  88412. * The compiled webGL program for the effect
  88413. * @returns the webGL program.
  88414. */
  88415. getProgram(): WebGLProgram;
  88416. /**
  88417. * The set of names of attribute variables for the shader.
  88418. * @returns An array of attribute names.
  88419. */
  88420. getAttributesNames(): string[];
  88421. /**
  88422. * Returns the attribute at the given index.
  88423. * @param index The index of the attribute.
  88424. * @returns The location of the attribute.
  88425. */
  88426. getAttributeLocation(index: number): number;
  88427. /**
  88428. * Returns the attribute based on the name of the variable.
  88429. * @param name of the attribute to look up.
  88430. * @returns the attribute location.
  88431. */
  88432. getAttributeLocationByName(name: string): number;
  88433. /**
  88434. * The number of attributes.
  88435. * @returns the numnber of attributes.
  88436. */
  88437. getAttributesCount(): number;
  88438. /**
  88439. * Gets the index of a uniform variable.
  88440. * @param uniformName of the uniform to look up.
  88441. * @returns the index.
  88442. */
  88443. getUniformIndex(uniformName: string): number;
  88444. /**
  88445. * Returns the attribute based on the name of the variable.
  88446. * @param uniformName of the uniform to look up.
  88447. * @returns the location of the uniform.
  88448. */
  88449. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88450. /**
  88451. * Returns an array of sampler variable names
  88452. * @returns The array of sampler variable neames.
  88453. */
  88454. getSamplers(): string[];
  88455. /**
  88456. * The error from the last compilation.
  88457. * @returns the error string.
  88458. */
  88459. getCompilationError(): string;
  88460. /**
  88461. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88462. * @param func The callback to be used.
  88463. */
  88464. executeWhenCompiled(func: (effect: Effect) => void): void;
  88465. private _checkIsReady;
  88466. /** @hidden */
  88467. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88468. /** @hidden */
  88469. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88470. /** @hidden */
  88471. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88472. private _processShaderConversion;
  88473. private _processIncludes;
  88474. private _processPrecision;
  88475. /**
  88476. * Recompiles the webGL program
  88477. * @param vertexSourceCode The source code for the vertex shader.
  88478. * @param fragmentSourceCode The source code for the fragment shader.
  88479. * @param onCompiled Callback called when completed.
  88480. * @param onError Callback called on error.
  88481. * @hidden
  88482. */
  88483. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88484. /**
  88485. * Gets the uniform locations of the the specified variable names
  88486. * @param names THe names of the variables to lookup.
  88487. * @returns Array of locations in the same order as variable names.
  88488. */
  88489. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88490. /**
  88491. * Prepares the effect
  88492. * @hidden
  88493. */
  88494. _prepareEffect(): void;
  88495. /**
  88496. * Checks if the effect is supported. (Must be called after compilation)
  88497. */
  88498. readonly isSupported: boolean;
  88499. /**
  88500. * Binds a texture to the engine to be used as output of the shader.
  88501. * @param channel Name of the output variable.
  88502. * @param texture Texture to bind.
  88503. * @hidden
  88504. */
  88505. _bindTexture(channel: string, texture: InternalTexture): void;
  88506. /**
  88507. * Sets a texture on the engine to be used in the shader.
  88508. * @param channel Name of the sampler variable.
  88509. * @param texture Texture to set.
  88510. */
  88511. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88512. /**
  88513. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88514. * @param channel Name of the sampler variable.
  88515. * @param texture Texture to set.
  88516. */
  88517. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88518. /**
  88519. * Sets an array of textures on the engine to be used in the shader.
  88520. * @param channel Name of the variable.
  88521. * @param textures Textures to set.
  88522. */
  88523. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88524. /**
  88525. * 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)
  88526. * @param channel Name of the sampler variable.
  88527. * @param postProcess Post process to get the input texture from.
  88528. */
  88529. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88530. /**
  88531. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88532. * 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)
  88533. * @param channel Name of the sampler variable.
  88534. * @param postProcess Post process to get the output texture from.
  88535. */
  88536. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88537. /** @hidden */
  88538. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88539. /** @hidden */
  88540. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88541. /** @hidden */
  88542. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88543. /** @hidden */
  88544. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88545. /**
  88546. * Binds a buffer to a uniform.
  88547. * @param buffer Buffer to bind.
  88548. * @param name Name of the uniform variable to bind to.
  88549. */
  88550. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88551. /**
  88552. * Binds block to a uniform.
  88553. * @param blockName Name of the block to bind.
  88554. * @param index Index to bind.
  88555. */
  88556. bindUniformBlock(blockName: string, index: number): void;
  88557. /**
  88558. * Sets an interger value on a uniform variable.
  88559. * @param uniformName Name of the variable.
  88560. * @param value Value to be set.
  88561. * @returns this effect.
  88562. */
  88563. setInt(uniformName: string, value: number): Effect;
  88564. /**
  88565. * Sets an int array on a uniform variable.
  88566. * @param uniformName Name of the variable.
  88567. * @param array array to be set.
  88568. * @returns this effect.
  88569. */
  88570. setIntArray(uniformName: string, array: Int32Array): Effect;
  88571. /**
  88572. * 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)
  88573. * @param uniformName Name of the variable.
  88574. * @param array array to be set.
  88575. * @returns this effect.
  88576. */
  88577. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88578. /**
  88579. * 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)
  88580. * @param uniformName Name of the variable.
  88581. * @param array array to be set.
  88582. * @returns this effect.
  88583. */
  88584. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88585. /**
  88586. * 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)
  88587. * @param uniformName Name of the variable.
  88588. * @param array array to be set.
  88589. * @returns this effect.
  88590. */
  88591. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88592. /**
  88593. * Sets an float array on a uniform variable.
  88594. * @param uniformName Name of the variable.
  88595. * @param array array to be set.
  88596. * @returns this effect.
  88597. */
  88598. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88599. /**
  88600. * 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)
  88601. * @param uniformName Name of the variable.
  88602. * @param array array to be set.
  88603. * @returns this effect.
  88604. */
  88605. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88606. /**
  88607. * 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)
  88608. * @param uniformName Name of the variable.
  88609. * @param array array to be set.
  88610. * @returns this effect.
  88611. */
  88612. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88613. /**
  88614. * 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)
  88615. * @param uniformName Name of the variable.
  88616. * @param array array to be set.
  88617. * @returns this effect.
  88618. */
  88619. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88620. /**
  88621. * Sets an array on a uniform variable.
  88622. * @param uniformName Name of the variable.
  88623. * @param array array to be set.
  88624. * @returns this effect.
  88625. */
  88626. setArray(uniformName: string, array: number[]): Effect;
  88627. /**
  88628. * 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)
  88629. * @param uniformName Name of the variable.
  88630. * @param array array to be set.
  88631. * @returns this effect.
  88632. */
  88633. setArray2(uniformName: string, array: number[]): Effect;
  88634. /**
  88635. * 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)
  88636. * @param uniformName Name of the variable.
  88637. * @param array array to be set.
  88638. * @returns this effect.
  88639. */
  88640. setArray3(uniformName: string, array: number[]): Effect;
  88641. /**
  88642. * 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)
  88643. * @param uniformName Name of the variable.
  88644. * @param array array to be set.
  88645. * @returns this effect.
  88646. */
  88647. setArray4(uniformName: string, array: number[]): Effect;
  88648. /**
  88649. * Sets matrices on a uniform variable.
  88650. * @param uniformName Name of the variable.
  88651. * @param matrices matrices to be set.
  88652. * @returns this effect.
  88653. */
  88654. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88655. /**
  88656. * Sets matrix on a uniform variable.
  88657. * @param uniformName Name of the variable.
  88658. * @param matrix matrix to be set.
  88659. * @returns this effect.
  88660. */
  88661. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88662. /**
  88663. * 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)
  88664. * @param uniformName Name of the variable.
  88665. * @param matrix matrix to be set.
  88666. * @returns this effect.
  88667. */
  88668. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88669. /**
  88670. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88671. * @param uniformName Name of the variable.
  88672. * @param matrix matrix to be set.
  88673. * @returns this effect.
  88674. */
  88675. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88676. /**
  88677. * Sets a float on a uniform variable.
  88678. * @param uniformName Name of the variable.
  88679. * @param value value to be set.
  88680. * @returns this effect.
  88681. */
  88682. setFloat(uniformName: string, value: number): Effect;
  88683. /**
  88684. * Sets a boolean on a uniform variable.
  88685. * @param uniformName Name of the variable.
  88686. * @param bool value to be set.
  88687. * @returns this effect.
  88688. */
  88689. setBool(uniformName: string, bool: boolean): Effect;
  88690. /**
  88691. * Sets a Vector2 on a uniform variable.
  88692. * @param uniformName Name of the variable.
  88693. * @param vector2 vector2 to be set.
  88694. * @returns this effect.
  88695. */
  88696. setVector2(uniformName: string, vector2: Vector2): Effect;
  88697. /**
  88698. * Sets a float2 on a uniform variable.
  88699. * @param uniformName Name of the variable.
  88700. * @param x First float in float2.
  88701. * @param y Second float in float2.
  88702. * @returns this effect.
  88703. */
  88704. setFloat2(uniformName: string, x: number, y: number): Effect;
  88705. /**
  88706. * Sets a Vector3 on a uniform variable.
  88707. * @param uniformName Name of the variable.
  88708. * @param vector3 Value to be set.
  88709. * @returns this effect.
  88710. */
  88711. setVector3(uniformName: string, vector3: Vector3): Effect;
  88712. /**
  88713. * Sets a float3 on a uniform variable.
  88714. * @param uniformName Name of the variable.
  88715. * @param x First float in float3.
  88716. * @param y Second float in float3.
  88717. * @param z Third float in float3.
  88718. * @returns this effect.
  88719. */
  88720. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88721. /**
  88722. * Sets a Vector4 on a uniform variable.
  88723. * @param uniformName Name of the variable.
  88724. * @param vector4 Value to be set.
  88725. * @returns this effect.
  88726. */
  88727. setVector4(uniformName: string, vector4: Vector4): Effect;
  88728. /**
  88729. * Sets a float4 on a uniform variable.
  88730. * @param uniformName Name of the variable.
  88731. * @param x First float in float4.
  88732. * @param y Second float in float4.
  88733. * @param z Third float in float4.
  88734. * @param w Fourth float in float4.
  88735. * @returns this effect.
  88736. */
  88737. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88738. /**
  88739. * Sets a Color3 on a uniform variable.
  88740. * @param uniformName Name of the variable.
  88741. * @param color3 Value to be set.
  88742. * @returns this effect.
  88743. */
  88744. setColor3(uniformName: string, color3: Color3): Effect;
  88745. /**
  88746. * Sets a Color4 on a uniform variable.
  88747. * @param uniformName Name of the variable.
  88748. * @param color3 Value to be set.
  88749. * @param alpha Alpha value to be set.
  88750. * @returns this effect.
  88751. */
  88752. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88753. /**
  88754. * Sets a Color4 on a uniform variable
  88755. * @param uniformName defines the name of the variable
  88756. * @param color4 defines the value to be set
  88757. * @returns this effect.
  88758. */
  88759. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88760. /**
  88761. * This function will add a new shader to the shader store
  88762. * @param name the name of the shader
  88763. * @param pixelShader optional pixel shader content
  88764. * @param vertexShader optional vertex shader content
  88765. */
  88766. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88767. /**
  88768. * Store of each shader (The can be looked up using effect.key)
  88769. */
  88770. static ShadersStore: {
  88771. [key: string]: string;
  88772. };
  88773. /**
  88774. * Store of each included file for a shader (The can be looked up using effect.key)
  88775. */
  88776. static IncludesShadersStore: {
  88777. [key: string]: string;
  88778. };
  88779. /**
  88780. * Resets the cache of effects.
  88781. */
  88782. static ResetCache(): void;
  88783. }
  88784. }
  88785. declare module BABYLON {
  88786. /**
  88787. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88788. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88789. * 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;
  88790. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88791. */
  88792. export class ColorCurves {
  88793. private _dirty;
  88794. private _tempColor;
  88795. private _globalCurve;
  88796. private _highlightsCurve;
  88797. private _midtonesCurve;
  88798. private _shadowsCurve;
  88799. private _positiveCurve;
  88800. private _negativeCurve;
  88801. private _globalHue;
  88802. private _globalDensity;
  88803. private _globalSaturation;
  88804. private _globalExposure;
  88805. /**
  88806. * Gets the global Hue value.
  88807. * 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).
  88808. */
  88809. /**
  88810. * Sets the global Hue value.
  88811. * 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).
  88812. */
  88813. globalHue: number;
  88814. /**
  88815. * Gets the global Density value.
  88816. * 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.
  88817. * Values less than zero provide a filter of opposite hue.
  88818. */
  88819. /**
  88820. * Sets the global Density value.
  88821. * 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.
  88822. * Values less than zero provide a filter of opposite hue.
  88823. */
  88824. globalDensity: number;
  88825. /**
  88826. * Gets the global Saturation value.
  88827. * 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.
  88828. */
  88829. /**
  88830. * Sets the global Saturation value.
  88831. * 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.
  88832. */
  88833. globalSaturation: number;
  88834. /**
  88835. * Gets the global Exposure value.
  88836. * 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.
  88837. */
  88838. /**
  88839. * Sets the global Exposure value.
  88840. * 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.
  88841. */
  88842. globalExposure: number;
  88843. private _highlightsHue;
  88844. private _highlightsDensity;
  88845. private _highlightsSaturation;
  88846. private _highlightsExposure;
  88847. /**
  88848. * Gets the highlights Hue value.
  88849. * 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).
  88850. */
  88851. /**
  88852. * Sets the highlights Hue value.
  88853. * 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).
  88854. */
  88855. highlightsHue: number;
  88856. /**
  88857. * Gets the highlights Density value.
  88858. * 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.
  88859. * Values less than zero provide a filter of opposite hue.
  88860. */
  88861. /**
  88862. * Sets the highlights Density value.
  88863. * 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.
  88864. * Values less than zero provide a filter of opposite hue.
  88865. */
  88866. highlightsDensity: number;
  88867. /**
  88868. * Gets the highlights Saturation value.
  88869. * 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.
  88870. */
  88871. /**
  88872. * Sets the highlights Saturation value.
  88873. * 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.
  88874. */
  88875. highlightsSaturation: number;
  88876. /**
  88877. * Gets the highlights Exposure value.
  88878. * 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.
  88879. */
  88880. /**
  88881. * Sets the highlights Exposure value.
  88882. * 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.
  88883. */
  88884. highlightsExposure: number;
  88885. private _midtonesHue;
  88886. private _midtonesDensity;
  88887. private _midtonesSaturation;
  88888. private _midtonesExposure;
  88889. /**
  88890. * Gets the midtones Hue value.
  88891. * 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).
  88892. */
  88893. /**
  88894. * Sets the midtones Hue value.
  88895. * 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).
  88896. */
  88897. midtonesHue: number;
  88898. /**
  88899. * Gets the midtones Density value.
  88900. * 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.
  88901. * Values less than zero provide a filter of opposite hue.
  88902. */
  88903. /**
  88904. * Sets the midtones Density value.
  88905. * 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.
  88906. * Values less than zero provide a filter of opposite hue.
  88907. */
  88908. midtonesDensity: number;
  88909. /**
  88910. * Gets the midtones Saturation value.
  88911. * 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.
  88912. */
  88913. /**
  88914. * Sets the midtones Saturation value.
  88915. * 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.
  88916. */
  88917. midtonesSaturation: number;
  88918. /**
  88919. * Gets the midtones Exposure value.
  88920. * 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.
  88921. */
  88922. /**
  88923. * Sets the midtones Exposure value.
  88924. * 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.
  88925. */
  88926. midtonesExposure: number;
  88927. private _shadowsHue;
  88928. private _shadowsDensity;
  88929. private _shadowsSaturation;
  88930. private _shadowsExposure;
  88931. /**
  88932. * Gets the shadows Hue value.
  88933. * 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).
  88934. */
  88935. /**
  88936. * Sets the shadows Hue value.
  88937. * 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).
  88938. */
  88939. shadowsHue: number;
  88940. /**
  88941. * Gets the shadows Density value.
  88942. * 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.
  88943. * Values less than zero provide a filter of opposite hue.
  88944. */
  88945. /**
  88946. * Sets the shadows Density value.
  88947. * 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.
  88948. * Values less than zero provide a filter of opposite hue.
  88949. */
  88950. shadowsDensity: number;
  88951. /**
  88952. * Gets the shadows Saturation value.
  88953. * 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.
  88954. */
  88955. /**
  88956. * Sets the shadows Saturation value.
  88957. * 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.
  88958. */
  88959. shadowsSaturation: number;
  88960. /**
  88961. * Gets the shadows Exposure value.
  88962. * 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.
  88963. */
  88964. /**
  88965. * Sets the shadows Exposure value.
  88966. * 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.
  88967. */
  88968. shadowsExposure: number;
  88969. /**
  88970. * Returns the class name
  88971. * @returns The class name
  88972. */
  88973. getClassName(): string;
  88974. /**
  88975. * Binds the color curves to the shader.
  88976. * @param colorCurves The color curve to bind
  88977. * @param effect The effect to bind to
  88978. * @param positiveUniform The positive uniform shader parameter
  88979. * @param neutralUniform The neutral uniform shader parameter
  88980. * @param negativeUniform The negative uniform shader parameter
  88981. */
  88982. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88983. /**
  88984. * Prepare the list of uniforms associated with the ColorCurves effects.
  88985. * @param uniformsList The list of uniforms used in the effect
  88986. */
  88987. static PrepareUniforms(uniformsList: string[]): void;
  88988. /**
  88989. * Returns color grading data based on a hue, density, saturation and exposure value.
  88990. * @param filterHue The hue of the color filter.
  88991. * @param filterDensity The density of the color filter.
  88992. * @param saturation The saturation.
  88993. * @param exposure The exposure.
  88994. * @param result The result data container.
  88995. */
  88996. private getColorGradingDataToRef;
  88997. /**
  88998. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88999. * @param value The input slider value in range [-100,100].
  89000. * @returns Adjusted value.
  89001. */
  89002. private static applyColorGradingSliderNonlinear;
  89003. /**
  89004. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89005. * @param hue The hue (H) input.
  89006. * @param saturation The saturation (S) input.
  89007. * @param brightness The brightness (B) input.
  89008. * @result An RGBA color represented as Vector4.
  89009. */
  89010. private static fromHSBToRef;
  89011. /**
  89012. * Returns a value clamped between min and max
  89013. * @param value The value to clamp
  89014. * @param min The minimum of value
  89015. * @param max The maximum of value
  89016. * @returns The clamped value.
  89017. */
  89018. private static clamp;
  89019. /**
  89020. * Clones the current color curve instance.
  89021. * @return The cloned curves
  89022. */
  89023. clone(): ColorCurves;
  89024. /**
  89025. * Serializes the current color curve instance to a json representation.
  89026. * @return a JSON representation
  89027. */
  89028. serialize(): any;
  89029. /**
  89030. * Parses the color curve from a json representation.
  89031. * @param source the JSON source to parse
  89032. * @return The parsed curves
  89033. */
  89034. static Parse(source: any): ColorCurves;
  89035. }
  89036. }
  89037. declare module BABYLON {
  89038. /**
  89039. * Interface to follow in your material defines to integrate easily the
  89040. * Image proccessing functions.
  89041. * @hidden
  89042. */
  89043. export interface IImageProcessingConfigurationDefines {
  89044. IMAGEPROCESSING: boolean;
  89045. VIGNETTE: boolean;
  89046. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89047. VIGNETTEBLENDMODEOPAQUE: boolean;
  89048. TONEMAPPING: boolean;
  89049. TONEMAPPING_ACES: boolean;
  89050. CONTRAST: boolean;
  89051. EXPOSURE: boolean;
  89052. COLORCURVES: boolean;
  89053. COLORGRADING: boolean;
  89054. COLORGRADING3D: boolean;
  89055. SAMPLER3DGREENDEPTH: boolean;
  89056. SAMPLER3DBGRMAP: boolean;
  89057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89058. }
  89059. /**
  89060. * @hidden
  89061. */
  89062. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89063. IMAGEPROCESSING: boolean;
  89064. VIGNETTE: boolean;
  89065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89066. VIGNETTEBLENDMODEOPAQUE: boolean;
  89067. TONEMAPPING: boolean;
  89068. TONEMAPPING_ACES: boolean;
  89069. CONTRAST: boolean;
  89070. COLORCURVES: boolean;
  89071. COLORGRADING: boolean;
  89072. COLORGRADING3D: boolean;
  89073. SAMPLER3DGREENDEPTH: boolean;
  89074. SAMPLER3DBGRMAP: boolean;
  89075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89076. EXPOSURE: boolean;
  89077. constructor();
  89078. }
  89079. /**
  89080. * This groups together the common properties used for image processing either in direct forward pass
  89081. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89082. * or not.
  89083. */
  89084. export class ImageProcessingConfiguration {
  89085. /**
  89086. * Default tone mapping applied in BabylonJS.
  89087. */
  89088. static readonly TONEMAPPING_STANDARD: number;
  89089. /**
  89090. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89091. * to other engines rendering to increase portability.
  89092. */
  89093. static readonly TONEMAPPING_ACES: number;
  89094. /**
  89095. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89096. */
  89097. colorCurves: Nullable<ColorCurves>;
  89098. private _colorCurvesEnabled;
  89099. /**
  89100. * Gets wether the color curves effect is enabled.
  89101. */
  89102. /**
  89103. * Sets wether the color curves effect is enabled.
  89104. */
  89105. colorCurvesEnabled: boolean;
  89106. private _colorGradingTexture;
  89107. /**
  89108. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89109. */
  89110. /**
  89111. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89112. */
  89113. colorGradingTexture: Nullable<BaseTexture>;
  89114. private _colorGradingEnabled;
  89115. /**
  89116. * Gets wether the color grading effect is enabled.
  89117. */
  89118. /**
  89119. * Sets wether the color grading effect is enabled.
  89120. */
  89121. colorGradingEnabled: boolean;
  89122. private _colorGradingWithGreenDepth;
  89123. /**
  89124. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89125. */
  89126. /**
  89127. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89128. */
  89129. colorGradingWithGreenDepth: boolean;
  89130. private _colorGradingBGR;
  89131. /**
  89132. * Gets wether the color grading texture contains BGR values.
  89133. */
  89134. /**
  89135. * Sets wether the color grading texture contains BGR values.
  89136. */
  89137. colorGradingBGR: boolean;
  89138. /** @hidden */
  89139. _exposure: number;
  89140. /**
  89141. * Gets the Exposure used in the effect.
  89142. */
  89143. /**
  89144. * Sets the Exposure used in the effect.
  89145. */
  89146. exposure: number;
  89147. private _toneMappingEnabled;
  89148. /**
  89149. * Gets wether the tone mapping effect is enabled.
  89150. */
  89151. /**
  89152. * Sets wether the tone mapping effect is enabled.
  89153. */
  89154. toneMappingEnabled: boolean;
  89155. private _toneMappingType;
  89156. /**
  89157. * Gets the type of tone mapping effect.
  89158. */
  89159. /**
  89160. * Sets the type of tone mapping effect used in BabylonJS.
  89161. */
  89162. toneMappingType: number;
  89163. protected _contrast: number;
  89164. /**
  89165. * Gets the contrast used in the effect.
  89166. */
  89167. /**
  89168. * Sets the contrast used in the effect.
  89169. */
  89170. contrast: number;
  89171. /**
  89172. * Vignette stretch size.
  89173. */
  89174. vignetteStretch: number;
  89175. /**
  89176. * Vignette centre X Offset.
  89177. */
  89178. vignetteCentreX: number;
  89179. /**
  89180. * Vignette centre Y Offset.
  89181. */
  89182. vignetteCentreY: number;
  89183. /**
  89184. * Vignette weight or intensity of the vignette effect.
  89185. */
  89186. vignetteWeight: number;
  89187. /**
  89188. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89189. * if vignetteEnabled is set to true.
  89190. */
  89191. vignetteColor: Color4;
  89192. /**
  89193. * Camera field of view used by the Vignette effect.
  89194. */
  89195. vignetteCameraFov: number;
  89196. private _vignetteBlendMode;
  89197. /**
  89198. * Gets the vignette blend mode allowing different kind of effect.
  89199. */
  89200. /**
  89201. * Sets the vignette blend mode allowing different kind of effect.
  89202. */
  89203. vignetteBlendMode: number;
  89204. private _vignetteEnabled;
  89205. /**
  89206. * Gets wether the vignette effect is enabled.
  89207. */
  89208. /**
  89209. * Sets wether the vignette effect is enabled.
  89210. */
  89211. vignetteEnabled: boolean;
  89212. private _applyByPostProcess;
  89213. /**
  89214. * Gets wether the image processing is applied through a post process or not.
  89215. */
  89216. /**
  89217. * Sets wether the image processing is applied through a post process or not.
  89218. */
  89219. applyByPostProcess: boolean;
  89220. private _isEnabled;
  89221. /**
  89222. * Gets wether the image processing is enabled or not.
  89223. */
  89224. /**
  89225. * Sets wether the image processing is enabled or not.
  89226. */
  89227. isEnabled: boolean;
  89228. /**
  89229. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89230. */
  89231. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89232. /**
  89233. * Method called each time the image processing information changes requires to recompile the effect.
  89234. */
  89235. protected _updateParameters(): void;
  89236. /**
  89237. * Gets the current class name.
  89238. * @return "ImageProcessingConfiguration"
  89239. */
  89240. getClassName(): string;
  89241. /**
  89242. * Prepare the list of uniforms associated with the Image Processing effects.
  89243. * @param uniforms The list of uniforms used in the effect
  89244. * @param defines the list of defines currently in use
  89245. */
  89246. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89247. /**
  89248. * Prepare the list of samplers associated with the Image Processing effects.
  89249. * @param samplersList The list of uniforms used in the effect
  89250. * @param defines the list of defines currently in use
  89251. */
  89252. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89253. /**
  89254. * Prepare the list of defines associated to the shader.
  89255. * @param defines the list of defines to complete
  89256. * @param forPostProcess Define if we are currently in post process mode or not
  89257. */
  89258. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89259. /**
  89260. * Returns true if all the image processing information are ready.
  89261. * @returns True if ready, otherwise, false
  89262. */
  89263. isReady(): boolean;
  89264. /**
  89265. * Binds the image processing to the shader.
  89266. * @param effect The effect to bind to
  89267. * @param aspectRatio Define the current aspect ratio of the effect
  89268. */
  89269. bind(effect: Effect, aspectRatio?: number): void;
  89270. /**
  89271. * Clones the current image processing instance.
  89272. * @return The cloned image processing
  89273. */
  89274. clone(): ImageProcessingConfiguration;
  89275. /**
  89276. * Serializes the current image processing instance to a json representation.
  89277. * @return a JSON representation
  89278. */
  89279. serialize(): any;
  89280. /**
  89281. * Parses the image processing from a json representation.
  89282. * @param source the JSON source to parse
  89283. * @return The parsed image processing
  89284. */
  89285. static Parse(source: any): ImageProcessingConfiguration;
  89286. private static _VIGNETTEMODE_MULTIPLY;
  89287. private static _VIGNETTEMODE_OPAQUE;
  89288. /**
  89289. * Used to apply the vignette as a mix with the pixel color.
  89290. */
  89291. static readonly VIGNETTEMODE_MULTIPLY: number;
  89292. /**
  89293. * Used to apply the vignette as a replacement of the pixel color.
  89294. */
  89295. static readonly VIGNETTEMODE_OPAQUE: number;
  89296. }
  89297. }
  89298. declare module BABYLON {
  89299. /**
  89300. * This represents all the required information to add a fresnel effect on a material:
  89301. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89302. */
  89303. export class FresnelParameters {
  89304. private _isEnabled;
  89305. /**
  89306. * Define if the fresnel effect is enable or not.
  89307. */
  89308. isEnabled: boolean;
  89309. /**
  89310. * Define the color used on edges (grazing angle)
  89311. */
  89312. leftColor: Color3;
  89313. /**
  89314. * Define the color used on center
  89315. */
  89316. rightColor: Color3;
  89317. /**
  89318. * Define bias applied to computed fresnel term
  89319. */
  89320. bias: number;
  89321. /**
  89322. * Defined the power exponent applied to fresnel term
  89323. */
  89324. power: number;
  89325. /**
  89326. * Clones the current fresnel and its valuues
  89327. * @returns a clone fresnel configuration
  89328. */
  89329. clone(): FresnelParameters;
  89330. /**
  89331. * Serializes the current fresnel parameters to a JSON representation.
  89332. * @return the JSON serialization
  89333. */
  89334. serialize(): any;
  89335. /**
  89336. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89337. * @param parsedFresnelParameters Define the JSON representation
  89338. * @returns the parsed parameters
  89339. */
  89340. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89341. }
  89342. }
  89343. declare module BABYLON {
  89344. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89345. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89346. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89347. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89348. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89349. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89350. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89351. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89352. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89353. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89354. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89355. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89356. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89357. /**
  89358. * Decorator used to define property that can be serialized as reference to a camera
  89359. * @param sourceName defines the name of the property to decorate
  89360. */
  89361. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89362. /**
  89363. * Class used to help serialization objects
  89364. */
  89365. export class SerializationHelper {
  89366. /** hidden */
  89367. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89368. /** hidden */
  89369. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89370. /** hidden */
  89371. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89372. /** hidden */
  89373. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89374. /**
  89375. * Appends the serialized animations from the source animations
  89376. * @param source Source containing the animations
  89377. * @param destination Target to store the animations
  89378. */
  89379. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89380. /**
  89381. * Static function used to serialized a specific entity
  89382. * @param entity defines the entity to serialize
  89383. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89384. * @returns a JSON compatible object representing the serialization of the entity
  89385. */
  89386. static Serialize<T>(entity: T, serializationObject?: any): any;
  89387. /**
  89388. * Creates a new entity from a serialization data object
  89389. * @param creationFunction defines a function used to instanciated the new entity
  89390. * @param source defines the source serialization data
  89391. * @param scene defines the hosting scene
  89392. * @param rootUrl defines the root url for resources
  89393. * @returns a new entity
  89394. */
  89395. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89396. /**
  89397. * Clones an object
  89398. * @param creationFunction defines the function used to instanciate the new object
  89399. * @param source defines the source object
  89400. * @returns the cloned object
  89401. */
  89402. static Clone<T>(creationFunction: () => T, source: T): T;
  89403. /**
  89404. * Instanciates a new object based on a source one (some data will be shared between both object)
  89405. * @param creationFunction defines the function used to instanciate the new object
  89406. * @param source defines the source object
  89407. * @returns the new object
  89408. */
  89409. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89410. }
  89411. }
  89412. declare module BABYLON {
  89413. /**
  89414. * This is the base class of all the camera used in the application.
  89415. * @see http://doc.babylonjs.com/features/cameras
  89416. */
  89417. export class Camera extends Node {
  89418. /** @hidden */
  89419. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89420. /**
  89421. * This is the default projection mode used by the cameras.
  89422. * It helps recreating a feeling of perspective and better appreciate depth.
  89423. * This is the best way to simulate real life cameras.
  89424. */
  89425. static readonly PERSPECTIVE_CAMERA: number;
  89426. /**
  89427. * This helps creating camera with an orthographic mode.
  89428. * 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.
  89429. */
  89430. static readonly ORTHOGRAPHIC_CAMERA: number;
  89431. /**
  89432. * This is the default FOV mode for perspective cameras.
  89433. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89434. */
  89435. static readonly FOVMODE_VERTICAL_FIXED: number;
  89436. /**
  89437. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89438. */
  89439. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89440. /**
  89441. * This specifies ther is no need for a camera rig.
  89442. * Basically only one eye is rendered corresponding to the camera.
  89443. */
  89444. static readonly RIG_MODE_NONE: number;
  89445. /**
  89446. * Simulates a camera Rig with one blue eye and one red eye.
  89447. * This can be use with 3d blue and red glasses.
  89448. */
  89449. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89450. /**
  89451. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89452. */
  89453. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89454. /**
  89455. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89456. */
  89457. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89458. /**
  89459. * Defines that both eyes of the camera will be rendered over under each other.
  89460. */
  89461. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89462. /**
  89463. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89464. */
  89465. static readonly RIG_MODE_VR: number;
  89466. /**
  89467. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89468. */
  89469. static readonly RIG_MODE_WEBVR: number;
  89470. /**
  89471. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89472. */
  89473. static readonly RIG_MODE_CUSTOM: number;
  89474. /**
  89475. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89476. */
  89477. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89478. /**
  89479. * Define the input manager associated with the camera.
  89480. */
  89481. inputs: CameraInputsManager<Camera>;
  89482. /** @hidden */
  89483. _position: Vector3;
  89484. /**
  89485. * Define the current local position of the camera in the scene
  89486. */
  89487. position: Vector3;
  89488. /**
  89489. * The vector the camera should consider as up.
  89490. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89491. */
  89492. upVector: Vector3;
  89493. /**
  89494. * Define the current limit on the left side for an orthographic camera
  89495. * In scene unit
  89496. */
  89497. orthoLeft: Nullable<number>;
  89498. /**
  89499. * Define the current limit on the right side for an orthographic camera
  89500. * In scene unit
  89501. */
  89502. orthoRight: Nullable<number>;
  89503. /**
  89504. * Define the current limit on the bottom side for an orthographic camera
  89505. * In scene unit
  89506. */
  89507. orthoBottom: Nullable<number>;
  89508. /**
  89509. * Define the current limit on the top side for an orthographic camera
  89510. * In scene unit
  89511. */
  89512. orthoTop: Nullable<number>;
  89513. /**
  89514. * Field Of View is set in Radians. (default is 0.8)
  89515. */
  89516. fov: number;
  89517. /**
  89518. * Define the minimum distance the camera can see from.
  89519. * This is important to note that the depth buffer are not infinite and the closer it starts
  89520. * the more your scene might encounter depth fighting issue.
  89521. */
  89522. minZ: number;
  89523. /**
  89524. * Define the maximum distance the camera can see to.
  89525. * This is important to note that the depth buffer are not infinite and the further it end
  89526. * the more your scene might encounter depth fighting issue.
  89527. */
  89528. maxZ: number;
  89529. /**
  89530. * Define the default inertia of the camera.
  89531. * This helps giving a smooth feeling to the camera movement.
  89532. */
  89533. inertia: number;
  89534. /**
  89535. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89536. */
  89537. mode: number;
  89538. /**
  89539. * Define wether the camera is intermediate.
  89540. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89541. */
  89542. isIntermediate: boolean;
  89543. /**
  89544. * Define the viewport of the camera.
  89545. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89546. */
  89547. viewport: Viewport;
  89548. /**
  89549. * Restricts the camera to viewing objects with the same layerMask.
  89550. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89551. */
  89552. layerMask: number;
  89553. /**
  89554. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89555. */
  89556. fovMode: number;
  89557. /**
  89558. * Rig mode of the camera.
  89559. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89560. * This is normally controlled byt the camera themselves as internal use.
  89561. */
  89562. cameraRigMode: number;
  89563. /**
  89564. * Defines the distance between both "eyes" in case of a RIG
  89565. */
  89566. interaxialDistance: number;
  89567. /**
  89568. * Defines if stereoscopic rendering is done side by side or over under.
  89569. */
  89570. isStereoscopicSideBySide: boolean;
  89571. /**
  89572. * 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
  89573. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89574. * else in the scene.
  89575. */
  89576. customRenderTargets: RenderTargetTexture[];
  89577. /**
  89578. * When set, the camera will render to this render target instead of the default canvas
  89579. */
  89580. outputRenderTarget: Nullable<RenderTargetTexture>;
  89581. /**
  89582. * Observable triggered when the camera view matrix has changed.
  89583. */
  89584. onViewMatrixChangedObservable: Observable<Camera>;
  89585. /**
  89586. * Observable triggered when the camera Projection matrix has changed.
  89587. */
  89588. onProjectionMatrixChangedObservable: Observable<Camera>;
  89589. /**
  89590. * Observable triggered when the inputs have been processed.
  89591. */
  89592. onAfterCheckInputsObservable: Observable<Camera>;
  89593. /**
  89594. * Observable triggered when reset has been called and applied to the camera.
  89595. */
  89596. onRestoreStateObservable: Observable<Camera>;
  89597. /** @hidden */
  89598. _cameraRigParams: any;
  89599. /** @hidden */
  89600. _rigCameras: Camera[];
  89601. /** @hidden */
  89602. _rigPostProcess: Nullable<PostProcess>;
  89603. protected _webvrViewMatrix: Matrix;
  89604. /** @hidden */
  89605. _skipRendering: boolean;
  89606. /** @hidden */
  89607. _projectionMatrix: Matrix;
  89608. /** @hidden */
  89609. _postProcesses: Nullable<PostProcess>[];
  89610. /** @hidden */
  89611. _activeMeshes: SmartArray<AbstractMesh>;
  89612. protected _globalPosition: Vector3;
  89613. /** hidden */
  89614. _computedViewMatrix: Matrix;
  89615. private _doNotComputeProjectionMatrix;
  89616. private _transformMatrix;
  89617. private _frustumPlanes;
  89618. private _refreshFrustumPlanes;
  89619. private _storedFov;
  89620. private _stateStored;
  89621. /**
  89622. * Instantiates a new camera object.
  89623. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89624. * @see http://doc.babylonjs.com/features/cameras
  89625. * @param name Defines the name of the camera in the scene
  89626. * @param position Defines the position of the camera
  89627. * @param scene Defines the scene the camera belongs too
  89628. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89629. */
  89630. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89631. /**
  89632. * Store current camera state (fov, position, etc..)
  89633. * @returns the camera
  89634. */
  89635. storeState(): Camera;
  89636. /**
  89637. * Restores the camera state values if it has been stored. You must call storeState() first
  89638. */
  89639. protected _restoreStateValues(): boolean;
  89640. /**
  89641. * Restored camera state. You must call storeState() first.
  89642. * @returns true if restored and false otherwise
  89643. */
  89644. restoreState(): boolean;
  89645. /**
  89646. * Gets the class name of the camera.
  89647. * @returns the class name
  89648. */
  89649. getClassName(): string;
  89650. /** @hidden */
  89651. readonly _isCamera: boolean;
  89652. /**
  89653. * Gets a string representation of the camera useful for debug purpose.
  89654. * @param fullDetails Defines that a more verboe level of logging is required
  89655. * @returns the string representation
  89656. */
  89657. toString(fullDetails?: boolean): string;
  89658. /**
  89659. * Gets the current world space position of the camera.
  89660. */
  89661. readonly globalPosition: Vector3;
  89662. /**
  89663. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89664. * @returns the active meshe list
  89665. */
  89666. getActiveMeshes(): SmartArray<AbstractMesh>;
  89667. /**
  89668. * Check wether a mesh is part of the current active mesh list of the camera
  89669. * @param mesh Defines the mesh to check
  89670. * @returns true if active, false otherwise
  89671. */
  89672. isActiveMesh(mesh: Mesh): boolean;
  89673. /**
  89674. * Is this camera ready to be used/rendered
  89675. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89676. * @return true if the camera is ready
  89677. */
  89678. isReady(completeCheck?: boolean): boolean;
  89679. /** @hidden */
  89680. _initCache(): void;
  89681. /** @hidden */
  89682. _updateCache(ignoreParentClass?: boolean): void;
  89683. /** @hidden */
  89684. _isSynchronized(): boolean;
  89685. /** @hidden */
  89686. _isSynchronizedViewMatrix(): boolean;
  89687. /** @hidden */
  89688. _isSynchronizedProjectionMatrix(): boolean;
  89689. /**
  89690. * Attach the input controls to a specific dom element to get the input from.
  89691. * @param element Defines the element the controls should be listened from
  89692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89693. */
  89694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89695. /**
  89696. * Detach the current controls from the specified dom element.
  89697. * @param element Defines the element to stop listening the inputs from
  89698. */
  89699. detachControl(element: HTMLElement): void;
  89700. /**
  89701. * Update the camera state according to the different inputs gathered during the frame.
  89702. */
  89703. update(): void;
  89704. /** @hidden */
  89705. _checkInputs(): void;
  89706. /** @hidden */
  89707. readonly rigCameras: Camera[];
  89708. /**
  89709. * Gets the post process used by the rig cameras
  89710. */
  89711. readonly rigPostProcess: Nullable<PostProcess>;
  89712. /**
  89713. * Internal, gets the first post proces.
  89714. * @returns the first post process to be run on this camera.
  89715. */
  89716. _getFirstPostProcess(): Nullable<PostProcess>;
  89717. private _cascadePostProcessesToRigCams;
  89718. /**
  89719. * Attach a post process to the camera.
  89720. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89721. * @param postProcess The post process to attach to the camera
  89722. * @param insertAt The position of the post process in case several of them are in use in the scene
  89723. * @returns the position the post process has been inserted at
  89724. */
  89725. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89726. /**
  89727. * Detach a post process to the camera.
  89728. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89729. * @param postProcess The post process to detach from the camera
  89730. */
  89731. detachPostProcess(postProcess: PostProcess): void;
  89732. /**
  89733. * Gets the current world matrix of the camera
  89734. */
  89735. getWorldMatrix(): Matrix;
  89736. /** @hidden */
  89737. _getViewMatrix(): Matrix;
  89738. /**
  89739. * Gets the current view matrix of the camera.
  89740. * @param force forces the camera to recompute the matrix without looking at the cached state
  89741. * @returns the view matrix
  89742. */
  89743. getViewMatrix(force?: boolean): Matrix;
  89744. /**
  89745. * Freeze the projection matrix.
  89746. * It will prevent the cache check of the camera projection compute and can speed up perf
  89747. * if no parameter of the camera are meant to change
  89748. * @param projection Defines manually a projection if necessary
  89749. */
  89750. freezeProjectionMatrix(projection?: Matrix): void;
  89751. /**
  89752. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89753. */
  89754. unfreezeProjectionMatrix(): void;
  89755. /**
  89756. * Gets the current projection matrix of the camera.
  89757. * @param force forces the camera to recompute the matrix without looking at the cached state
  89758. * @returns the projection matrix
  89759. */
  89760. getProjectionMatrix(force?: boolean): Matrix;
  89761. /**
  89762. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89763. * @returns a Matrix
  89764. */
  89765. getTransformationMatrix(): Matrix;
  89766. private _updateFrustumPlanes;
  89767. /**
  89768. * Checks if a cullable object (mesh...) is in the camera frustum
  89769. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89770. * @param target The object to check
  89771. * @returns true if the object is in frustum otherwise false
  89772. */
  89773. isInFrustum(target: ICullable): boolean;
  89774. /**
  89775. * Checks if a cullable object (mesh...) is in the camera frustum
  89776. * Unlike isInFrustum this cheks the full bounding box
  89777. * @param target The object to check
  89778. * @returns true if the object is in frustum otherwise false
  89779. */
  89780. isCompletelyInFrustum(target: ICullable): boolean;
  89781. /**
  89782. * Gets a ray in the forward direction from the camera.
  89783. * @param length Defines the length of the ray to create
  89784. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89785. * @param origin Defines the start point of the ray which defaults to the camera position
  89786. * @returns the forward ray
  89787. */
  89788. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89789. /**
  89790. * Releases resources associated with this node.
  89791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89793. */
  89794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89795. /** @hidden */
  89796. _isLeftCamera: boolean;
  89797. /**
  89798. * Gets the left camera of a rig setup in case of Rigged Camera
  89799. */
  89800. readonly isLeftCamera: boolean;
  89801. /** @hidden */
  89802. _isRightCamera: boolean;
  89803. /**
  89804. * Gets the right camera of a rig setup in case of Rigged Camera
  89805. */
  89806. readonly isRightCamera: boolean;
  89807. /**
  89808. * Gets the left camera of a rig setup in case of Rigged Camera
  89809. */
  89810. readonly leftCamera: Nullable<FreeCamera>;
  89811. /**
  89812. * Gets the right camera of a rig setup in case of Rigged Camera
  89813. */
  89814. readonly rightCamera: Nullable<FreeCamera>;
  89815. /**
  89816. * Gets the left camera target of a rig setup in case of Rigged Camera
  89817. * @returns the target position
  89818. */
  89819. getLeftTarget(): Nullable<Vector3>;
  89820. /**
  89821. * Gets the right camera target of a rig setup in case of Rigged Camera
  89822. * @returns the target position
  89823. */
  89824. getRightTarget(): Nullable<Vector3>;
  89825. /**
  89826. * @hidden
  89827. */
  89828. setCameraRigMode(mode: number, rigParams: any): void;
  89829. /** @hidden */
  89830. static _setStereoscopicRigMode(camera: Camera): void;
  89831. /** @hidden */
  89832. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89833. /** @hidden */
  89834. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89835. /** @hidden */
  89836. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89837. /** @hidden */
  89838. _getVRProjectionMatrix(): Matrix;
  89839. protected _updateCameraRotationMatrix(): void;
  89840. protected _updateWebVRCameraRotationMatrix(): void;
  89841. /**
  89842. * This function MUST be overwritten by the different WebVR cameras available.
  89843. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89844. * @hidden
  89845. */
  89846. _getWebVRProjectionMatrix(): Matrix;
  89847. /**
  89848. * This function MUST be overwritten by the different WebVR cameras available.
  89849. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89850. * @hidden
  89851. */
  89852. _getWebVRViewMatrix(): Matrix;
  89853. /** @hidden */
  89854. setCameraRigParameter(name: string, value: any): void;
  89855. /**
  89856. * needs to be overridden by children so sub has required properties to be copied
  89857. * @hidden
  89858. */
  89859. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89860. /**
  89861. * May need to be overridden by children
  89862. * @hidden
  89863. */
  89864. _updateRigCameras(): void;
  89865. /** @hidden */
  89866. _setupInputs(): void;
  89867. /**
  89868. * Serialiaze the camera setup to a json represention
  89869. * @returns the JSON representation
  89870. */
  89871. serialize(): any;
  89872. /**
  89873. * Clones the current camera.
  89874. * @param name The cloned camera name
  89875. * @returns the cloned camera
  89876. */
  89877. clone(name: string): Camera;
  89878. /**
  89879. * Gets the direction of the camera relative to a given local axis.
  89880. * @param localAxis Defines the reference axis to provide a relative direction.
  89881. * @return the direction
  89882. */
  89883. getDirection(localAxis: Vector3): Vector3;
  89884. /**
  89885. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89886. * @param localAxis Defines the reference axis to provide a relative direction.
  89887. * @param result Defines the vector to store the result in
  89888. */
  89889. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89890. /**
  89891. * Gets a camera constructor for a given camera type
  89892. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89893. * @param name The name of the camera the result will be able to instantiate
  89894. * @param scene The scene the result will construct the camera in
  89895. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89896. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89897. * @returns a factory method to construc the camera
  89898. */
  89899. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89900. /**
  89901. * Compute the world matrix of the camera.
  89902. * @returns the camera workd matrix
  89903. */
  89904. computeWorldMatrix(): Matrix;
  89905. /**
  89906. * Parse a JSON and creates the camera from the parsed information
  89907. * @param parsedCamera The JSON to parse
  89908. * @param scene The scene to instantiate the camera in
  89909. * @returns the newly constructed camera
  89910. */
  89911. static Parse(parsedCamera: any, scene: Scene): Camera;
  89912. }
  89913. }
  89914. declare module BABYLON {
  89915. /**
  89916. * Interface for any object that can request an animation frame
  89917. */
  89918. export interface ICustomAnimationFrameRequester {
  89919. /**
  89920. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89921. */
  89922. renderFunction?: Function;
  89923. /**
  89924. * Called to request the next frame to render to
  89925. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89926. */
  89927. requestAnimationFrame: Function;
  89928. /**
  89929. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89930. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89931. */
  89932. requestID?: number;
  89933. }
  89934. /**
  89935. * Interface containing an array of animations
  89936. */
  89937. export interface IAnimatable {
  89938. /**
  89939. * Array of animations
  89940. */
  89941. animations: Array<Animation>;
  89942. }
  89943. /** Interface used by value gradients (color, factor, ...) */
  89944. export interface IValueGradient {
  89945. /**
  89946. * Gets or sets the gradient value (between 0 and 1)
  89947. */
  89948. gradient: number;
  89949. }
  89950. /** Class used to store color4 gradient */
  89951. export class ColorGradient implements IValueGradient {
  89952. /**
  89953. * Gets or sets the gradient value (between 0 and 1)
  89954. */
  89955. gradient: number;
  89956. /**
  89957. * Gets or sets first associated color
  89958. */
  89959. color1: Color4;
  89960. /**
  89961. * Gets or sets second associated color
  89962. */
  89963. color2?: Color4;
  89964. /**
  89965. * Will get a color picked randomly between color1 and color2.
  89966. * If color2 is undefined then color1 will be used
  89967. * @param result defines the target Color4 to store the result in
  89968. */
  89969. getColorToRef(result: Color4): void;
  89970. }
  89971. /** Class used to store color 3 gradient */
  89972. export class Color3Gradient implements IValueGradient {
  89973. /**
  89974. * Gets or sets the gradient value (between 0 and 1)
  89975. */
  89976. gradient: number;
  89977. /**
  89978. * Gets or sets the associated color
  89979. */
  89980. color: Color3;
  89981. }
  89982. /** Class used to store factor gradient */
  89983. export class FactorGradient implements IValueGradient {
  89984. /**
  89985. * Gets or sets the gradient value (between 0 and 1)
  89986. */
  89987. gradient: number;
  89988. /**
  89989. * Gets or sets first associated factor
  89990. */
  89991. factor1: number;
  89992. /**
  89993. * Gets or sets second associated factor
  89994. */
  89995. factor2?: number;
  89996. /**
  89997. * Will get a number picked randomly between factor1 and factor2.
  89998. * If factor2 is undefined then factor1 will be used
  89999. * @returns the picked number
  90000. */
  90001. getFactor(): number;
  90002. }
  90003. /**
  90004. * @ignore
  90005. * Application error to support additional information when loading a file
  90006. */
  90007. export class LoadFileError extends Error {
  90008. /** defines the optional web request */
  90009. request?: WebRequest | undefined;
  90010. private static _setPrototypeOf;
  90011. /**
  90012. * Creates a new LoadFileError
  90013. * @param message defines the message of the error
  90014. * @param request defines the optional web request
  90015. */
  90016. constructor(message: string,
  90017. /** defines the optional web request */
  90018. request?: WebRequest | undefined);
  90019. }
  90020. /**
  90021. * Class used to define a retry strategy when error happens while loading assets
  90022. */
  90023. export class RetryStrategy {
  90024. /**
  90025. * Function used to defines an exponential back off strategy
  90026. * @param maxRetries defines the maximum number of retries (3 by default)
  90027. * @param baseInterval defines the interval between retries
  90028. * @returns the strategy function to use
  90029. */
  90030. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90031. }
  90032. /**
  90033. * File request interface
  90034. */
  90035. export interface IFileRequest {
  90036. /**
  90037. * Raised when the request is complete (success or error).
  90038. */
  90039. onCompleteObservable: Observable<IFileRequest>;
  90040. /**
  90041. * Aborts the request for a file.
  90042. */
  90043. abort: () => void;
  90044. }
  90045. /**
  90046. * Class containing a set of static utilities functions
  90047. */
  90048. export class Tools {
  90049. /**
  90050. * Gets or sets the base URL to use to load assets
  90051. */
  90052. static BaseUrl: string;
  90053. /**
  90054. * Enable/Disable Custom HTTP Request Headers globally.
  90055. * default = false
  90056. * @see CustomRequestHeaders
  90057. */
  90058. static UseCustomRequestHeaders: boolean;
  90059. /**
  90060. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90061. * i.e. when loading files, where the server/service expects an Authorization header
  90062. */
  90063. static CustomRequestHeaders: {
  90064. [key: string]: string;
  90065. };
  90066. /**
  90067. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90068. */
  90069. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90070. /**
  90071. * Default behaviour for cors in the application.
  90072. * It can be a string if the expected behavior is identical in the entire app.
  90073. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90074. */
  90075. static CorsBehavior: string | ((url: string | string[]) => string);
  90076. /**
  90077. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90078. * @ignorenaming
  90079. */
  90080. static UseFallbackTexture: boolean;
  90081. /**
  90082. * Use this object to register external classes like custom textures or material
  90083. * to allow the laoders to instantiate them
  90084. */
  90085. static RegisteredExternalClasses: {
  90086. [key: string]: Object;
  90087. };
  90088. /**
  90089. * Texture content used if a texture cannot loaded
  90090. * @ignorenaming
  90091. */
  90092. static fallbackTexture: string;
  90093. /**
  90094. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90095. * @param u defines the coordinate on X axis
  90096. * @param v defines the coordinate on Y axis
  90097. * @param width defines the width of the source data
  90098. * @param height defines the height of the source data
  90099. * @param pixels defines the source byte array
  90100. * @param color defines the output color
  90101. */
  90102. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90103. /**
  90104. * Interpolates between a and b via alpha
  90105. * @param a The lower value (returned when alpha = 0)
  90106. * @param b The upper value (returned when alpha = 1)
  90107. * @param alpha The interpolation-factor
  90108. * @return The mixed value
  90109. */
  90110. static Mix(a: number, b: number, alpha: number): number;
  90111. /**
  90112. * Tries to instantiate a new object from a given class name
  90113. * @param className defines the class name to instantiate
  90114. * @returns the new object or null if the system was not able to do the instantiation
  90115. */
  90116. static Instantiate(className: string): any;
  90117. /**
  90118. * Provides a slice function that will work even on IE
  90119. * @param data defines the array to slice
  90120. * @param start defines the start of the data (optional)
  90121. * @param end defines the end of the data (optional)
  90122. * @returns the new sliced array
  90123. */
  90124. static Slice<T>(data: T, start?: number, end?: number): T;
  90125. /**
  90126. * Polyfill for setImmediate
  90127. * @param action defines the action to execute after the current execution block
  90128. */
  90129. static SetImmediate(action: () => void): void;
  90130. /**
  90131. * Function indicating if a number is an exponent of 2
  90132. * @param value defines the value to test
  90133. * @returns true if the value is an exponent of 2
  90134. */
  90135. static IsExponentOfTwo(value: number): boolean;
  90136. private static _tmpFloatArray;
  90137. /**
  90138. * Returns the nearest 32-bit single precision float representation of a Number
  90139. * @param value A Number. If the parameter is of a different type, it will get converted
  90140. * to a number or to NaN if it cannot be converted
  90141. * @returns number
  90142. */
  90143. static FloatRound(value: number): number;
  90144. /**
  90145. * Find the next highest power of two.
  90146. * @param x Number to start search from.
  90147. * @return Next highest power of two.
  90148. */
  90149. static CeilingPOT(x: number): number;
  90150. /**
  90151. * Find the next lowest power of two.
  90152. * @param x Number to start search from.
  90153. * @return Next lowest power of two.
  90154. */
  90155. static FloorPOT(x: number): number;
  90156. /**
  90157. * Find the nearest power of two.
  90158. * @param x Number to start search from.
  90159. * @return Next nearest power of two.
  90160. */
  90161. static NearestPOT(x: number): number;
  90162. /**
  90163. * Get the closest exponent of two
  90164. * @param value defines the value to approximate
  90165. * @param max defines the maximum value to return
  90166. * @param mode defines how to define the closest value
  90167. * @returns closest exponent of two of the given value
  90168. */
  90169. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90170. /**
  90171. * Extracts the filename from a path
  90172. * @param path defines the path to use
  90173. * @returns the filename
  90174. */
  90175. static GetFilename(path: string): string;
  90176. /**
  90177. * Extracts the "folder" part of a path (everything before the filename).
  90178. * @param uri The URI to extract the info from
  90179. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90180. * @returns The "folder" part of the path
  90181. */
  90182. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90183. /**
  90184. * Extracts text content from a DOM element hierarchy
  90185. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90186. */
  90187. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90188. /**
  90189. * Convert an angle in radians to degrees
  90190. * @param angle defines the angle to convert
  90191. * @returns the angle in degrees
  90192. */
  90193. static ToDegrees(angle: number): number;
  90194. /**
  90195. * Convert an angle in degrees to radians
  90196. * @param angle defines the angle to convert
  90197. * @returns the angle in radians
  90198. */
  90199. static ToRadians(angle: number): number;
  90200. /**
  90201. * Encode a buffer to a base64 string
  90202. * @param buffer defines the buffer to encode
  90203. * @returns the encoded string
  90204. */
  90205. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90206. /**
  90207. * Extracts minimum and maximum values from a list of indexed positions
  90208. * @param positions defines the positions to use
  90209. * @param indices defines the indices to the positions
  90210. * @param indexStart defines the start index
  90211. * @param indexCount defines the end index
  90212. * @param bias defines bias value to add to the result
  90213. * @return minimum and maximum values
  90214. */
  90215. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90216. minimum: Vector3;
  90217. maximum: Vector3;
  90218. };
  90219. /**
  90220. * Extracts minimum and maximum values from a list of positions
  90221. * @param positions defines the positions to use
  90222. * @param start defines the start index in the positions array
  90223. * @param count defines the number of positions to handle
  90224. * @param bias defines bias value to add to the result
  90225. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90226. * @return minimum and maximum values
  90227. */
  90228. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90229. minimum: Vector3;
  90230. maximum: Vector3;
  90231. };
  90232. /**
  90233. * Returns an array if obj is not an array
  90234. * @param obj defines the object to evaluate as an array
  90235. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90236. * @returns either obj directly if obj is an array or a new array containing obj
  90237. */
  90238. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90239. /**
  90240. * Gets the pointer prefix to use
  90241. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90242. */
  90243. static GetPointerPrefix(): string;
  90244. /**
  90245. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90246. * @param func - the function to be called
  90247. * @param requester - the object that will request the next frame. Falls back to window.
  90248. * @returns frame number
  90249. */
  90250. static QueueNewFrame(func: () => void, requester?: any): number;
  90251. /**
  90252. * Ask the browser to promote the current element to fullscreen rendering mode
  90253. * @param element defines the DOM element to promote
  90254. */
  90255. static RequestFullscreen(element: HTMLElement): void;
  90256. /**
  90257. * Asks the browser to exit fullscreen mode
  90258. */
  90259. static ExitFullscreen(): void;
  90260. /**
  90261. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90262. * @param url define the url we are trying
  90263. * @param element define the dom element where to configure the cors policy
  90264. */
  90265. static SetCorsBehavior(url: string | string[], element: {
  90266. crossOrigin: string | null;
  90267. }): void;
  90268. /**
  90269. * Removes unwanted characters from an url
  90270. * @param url defines the url to clean
  90271. * @returns the cleaned url
  90272. */
  90273. static CleanUrl(url: string): string;
  90274. /**
  90275. * Gets or sets a function used to pre-process url before using them to load assets
  90276. */
  90277. static PreprocessUrl: (url: string) => string;
  90278. /**
  90279. * Loads an image as an HTMLImageElement.
  90280. * @param input url string, ArrayBuffer, or Blob to load
  90281. * @param onLoad callback called when the image successfully loads
  90282. * @param onError callback called when the image fails to load
  90283. * @param offlineProvider offline provider for caching
  90284. * @returns the HTMLImageElement of the loaded image
  90285. */
  90286. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90287. /**
  90288. * Loads a file
  90289. * @param url url string, ArrayBuffer, or Blob to load
  90290. * @param onSuccess callback called when the file successfully loads
  90291. * @param onProgress callback called while file is loading (if the server supports this mode)
  90292. * @param offlineProvider defines the offline provider for caching
  90293. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90294. * @param onError callback called when the file fails to load
  90295. * @returns a file request object
  90296. */
  90297. 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;
  90298. /**
  90299. * Load a script (identified by an url). When the url returns, the
  90300. * content of this file is added into a new script element, attached to the DOM (body element)
  90301. * @param scriptUrl defines the url of the script to laod
  90302. * @param onSuccess defines the callback called when the script is loaded
  90303. * @param onError defines the callback to call if an error occurs
  90304. * @param scriptId defines the id of the script element
  90305. */
  90306. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90307. /**
  90308. * Load an asynchronous script (identified by an url). When the url returns, the
  90309. * content of this file is added into a new script element, attached to the DOM (body element)
  90310. * @param scriptUrl defines the url of the script to laod
  90311. * @param scriptId defines the id of the script element
  90312. * @returns a promise request object
  90313. */
  90314. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90315. /**
  90316. * Loads a file from a blob
  90317. * @param fileToLoad defines the blob to use
  90318. * @param callback defines the callback to call when data is loaded
  90319. * @param progressCallback defines the callback to call during loading process
  90320. * @returns a file request object
  90321. */
  90322. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90323. /**
  90324. * Loads a file
  90325. * @param fileToLoad defines the file to load
  90326. * @param callback defines the callback to call when data is loaded
  90327. * @param progressCallBack defines the callback to call during loading process
  90328. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90329. * @returns a file request object
  90330. */
  90331. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90332. /**
  90333. * Creates a data url from a given string content
  90334. * @param content defines the content to convert
  90335. * @returns the new data url link
  90336. */
  90337. static FileAsURL(content: string): string;
  90338. /**
  90339. * Format the given number to a specific decimal format
  90340. * @param value defines the number to format
  90341. * @param decimals defines the number of decimals to use
  90342. * @returns the formatted string
  90343. */
  90344. static Format(value: number, decimals?: number): string;
  90345. /**
  90346. * Checks if a given vector is inside a specific range
  90347. * @param v defines the vector to test
  90348. * @param min defines the minimum range
  90349. * @param max defines the maximum range
  90350. */
  90351. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90352. /**
  90353. * Tries to copy an object by duplicating every property
  90354. * @param source defines the source object
  90355. * @param destination defines the target object
  90356. * @param doNotCopyList defines a list of properties to avoid
  90357. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90358. */
  90359. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90360. /**
  90361. * Gets a boolean indicating if the given object has no own property
  90362. * @param obj defines the object to test
  90363. * @returns true if object has no own property
  90364. */
  90365. static IsEmpty(obj: any): boolean;
  90366. /**
  90367. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90368. * @param str Source string
  90369. * @param suffix Suffix to search for in the source string
  90370. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90371. */
  90372. static EndsWith(str: string, suffix: string): boolean;
  90373. /**
  90374. * Function used to register events at window level
  90375. * @param events defines the events to register
  90376. */
  90377. static RegisterTopRootEvents(events: {
  90378. name: string;
  90379. handler: Nullable<(e: FocusEvent) => any>;
  90380. }[]): void;
  90381. /**
  90382. * Function used to unregister events from window level
  90383. * @param events defines the events to unregister
  90384. */
  90385. static UnregisterTopRootEvents(events: {
  90386. name: string;
  90387. handler: Nullable<(e: FocusEvent) => any>;
  90388. }[]): void;
  90389. /**
  90390. * @ignore
  90391. */
  90392. static _ScreenshotCanvas: HTMLCanvasElement;
  90393. /**
  90394. * Dumps the current bound framebuffer
  90395. * @param width defines the rendering width
  90396. * @param height defines the rendering height
  90397. * @param engine defines the hosting engine
  90398. * @param successCallback defines the callback triggered once the data are available
  90399. * @param mimeType defines the mime type of the result
  90400. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90401. */
  90402. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90403. /**
  90404. * Converts the canvas data to blob.
  90405. * This acts as a polyfill for browsers not supporting the to blob function.
  90406. * @param canvas Defines the canvas to extract the data from
  90407. * @param successCallback Defines the callback triggered once the data are available
  90408. * @param mimeType Defines the mime type of the result
  90409. */
  90410. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90411. /**
  90412. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90413. * @param successCallback defines the callback triggered once the data are available
  90414. * @param mimeType defines the mime type of the result
  90415. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90416. */
  90417. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90418. /**
  90419. * Downloads a blob in the browser
  90420. * @param blob defines the blob to download
  90421. * @param fileName defines the name of the downloaded file
  90422. */
  90423. static Download(blob: Blob, fileName: string): void;
  90424. /**
  90425. * Captures a screenshot of the current rendering
  90426. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90427. * @param engine defines the rendering engine
  90428. * @param camera defines the source camera
  90429. * @param size This parameter can be set to a single number or to an object with the
  90430. * following (optional) properties: precision, width, height. If a single number is passed,
  90431. * it will be used for both width and height. If an object is passed, the screenshot size
  90432. * will be derived from the parameters. The precision property is a multiplier allowing
  90433. * rendering at a higher or lower resolution
  90434. * @param successCallback defines the callback receives a single parameter which contains the
  90435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90436. * src parameter of an <img> to display it
  90437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90438. * Check your browser for supported MIME types
  90439. */
  90440. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90441. /**
  90442. * Generates an image screenshot from the specified camera.
  90443. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90444. * @param engine The engine to use for rendering
  90445. * @param camera The camera to use for rendering
  90446. * @param size This parameter can be set to a single number or to an object with the
  90447. * following (optional) properties: precision, width, height. If a single number is passed,
  90448. * it will be used for both width and height. If an object is passed, the screenshot size
  90449. * will be derived from the parameters. The precision property is a multiplier allowing
  90450. * rendering at a higher or lower resolution
  90451. * @param successCallback The callback receives a single parameter which contains the
  90452. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90453. * src parameter of an <img> to display it
  90454. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90455. * Check your browser for supported MIME types
  90456. * @param samples Texture samples (default: 1)
  90457. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90458. * @param fileName A name for for the downloaded file.
  90459. */
  90460. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90461. /**
  90462. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90463. * Be aware Math.random() could cause collisions, but:
  90464. * "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"
  90465. * @returns a pseudo random id
  90466. */
  90467. static RandomId(): string;
  90468. /**
  90469. * Test if the given uri is a base64 string
  90470. * @param uri The uri to test
  90471. * @return True if the uri is a base64 string or false otherwise
  90472. */
  90473. static IsBase64(uri: string): boolean;
  90474. /**
  90475. * Decode the given base64 uri.
  90476. * @param uri The uri to decode
  90477. * @return The decoded base64 data.
  90478. */
  90479. static DecodeBase64(uri: string): ArrayBuffer;
  90480. /**
  90481. * No log
  90482. */
  90483. static readonly NoneLogLevel: number;
  90484. /**
  90485. * Only message logs
  90486. */
  90487. static readonly MessageLogLevel: number;
  90488. /**
  90489. * Only warning logs
  90490. */
  90491. static readonly WarningLogLevel: number;
  90492. /**
  90493. * Only error logs
  90494. */
  90495. static readonly ErrorLogLevel: number;
  90496. /**
  90497. * All logs
  90498. */
  90499. static readonly AllLogLevel: number;
  90500. /**
  90501. * Gets a value indicating the number of loading errors
  90502. * @ignorenaming
  90503. */
  90504. static readonly errorsCount: number;
  90505. /**
  90506. * Callback called when a new log is added
  90507. */
  90508. static OnNewCacheEntry: (entry: string) => void;
  90509. /**
  90510. * Log a message to the console
  90511. * @param message defines the message to log
  90512. */
  90513. static Log(message: string): void;
  90514. /**
  90515. * Write a warning message to the console
  90516. * @param message defines the message to log
  90517. */
  90518. static Warn(message: string): void;
  90519. /**
  90520. * Write an error message to the console
  90521. * @param message defines the message to log
  90522. */
  90523. static Error(message: string): void;
  90524. /**
  90525. * Gets current log cache (list of logs)
  90526. */
  90527. static readonly LogCache: string;
  90528. /**
  90529. * Clears the log cache
  90530. */
  90531. static ClearLogCache(): void;
  90532. /**
  90533. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90534. */
  90535. static LogLevels: number;
  90536. /**
  90537. * Checks if the loaded document was accessed via `file:`-Protocol.
  90538. * @returns boolean
  90539. */
  90540. static IsFileURL(): boolean;
  90541. /**
  90542. * Checks if the window object exists
  90543. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90544. */
  90545. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90546. /**
  90547. * No performance log
  90548. */
  90549. static readonly PerformanceNoneLogLevel: number;
  90550. /**
  90551. * Use user marks to log performance
  90552. */
  90553. static readonly PerformanceUserMarkLogLevel: number;
  90554. /**
  90555. * Log performance to the console
  90556. */
  90557. static readonly PerformanceConsoleLogLevel: number;
  90558. private static _performance;
  90559. /**
  90560. * Sets the current performance log level
  90561. */
  90562. static PerformanceLogLevel: number;
  90563. private static _StartPerformanceCounterDisabled;
  90564. private static _EndPerformanceCounterDisabled;
  90565. private static _StartUserMark;
  90566. private static _EndUserMark;
  90567. private static _StartPerformanceConsole;
  90568. private static _EndPerformanceConsole;
  90569. /**
  90570. * Starts a performance counter
  90571. */
  90572. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90573. /**
  90574. * Ends a specific performance coutner
  90575. */
  90576. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90577. /**
  90578. * Gets either window.performance.now() if supported or Date.now() else
  90579. */
  90580. static readonly Now: number;
  90581. /**
  90582. * This method will return the name of the class used to create the instance of the given object.
  90583. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90584. * @param object the object to get the class name from
  90585. * @param isType defines if the object is actually a type
  90586. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90587. */
  90588. static GetClassName(object: any, isType?: boolean): string;
  90589. /**
  90590. * Gets the first element of an array satisfying a given predicate
  90591. * @param array defines the array to browse
  90592. * @param predicate defines the predicate to use
  90593. * @returns null if not found or the element
  90594. */
  90595. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90596. /**
  90597. * This method will return the name of the full name of the class, including its owning module (if any).
  90598. * 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).
  90599. * @param object the object to get the class name from
  90600. * @param isType defines if the object is actually a type
  90601. * @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.
  90602. * @ignorenaming
  90603. */
  90604. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90605. /**
  90606. * Returns a promise that resolves after the given amount of time.
  90607. * @param delay Number of milliseconds to delay
  90608. * @returns Promise that resolves after the given amount of time
  90609. */
  90610. static DelayAsync(delay: number): Promise<void>;
  90611. /**
  90612. * Gets the current gradient from an array of IValueGradient
  90613. * @param ratio defines the current ratio to get
  90614. * @param gradients defines the array of IValueGradient
  90615. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90616. */
  90617. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90618. }
  90619. /**
  90620. * This class is used to track a performance counter which is number based.
  90621. * The user has access to many properties which give statistics of different nature.
  90622. *
  90623. * The implementer can track two kinds of Performance Counter: time and count.
  90624. * 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.
  90625. * 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.
  90626. */
  90627. export class PerfCounter {
  90628. /**
  90629. * Gets or sets a global boolean to turn on and off all the counters
  90630. */
  90631. static Enabled: boolean;
  90632. /**
  90633. * Returns the smallest value ever
  90634. */
  90635. readonly min: number;
  90636. /**
  90637. * Returns the biggest value ever
  90638. */
  90639. readonly max: number;
  90640. /**
  90641. * Returns the average value since the performance counter is running
  90642. */
  90643. readonly average: number;
  90644. /**
  90645. * Returns the average value of the last second the counter was monitored
  90646. */
  90647. readonly lastSecAverage: number;
  90648. /**
  90649. * Returns the current value
  90650. */
  90651. readonly current: number;
  90652. /**
  90653. * Gets the accumulated total
  90654. */
  90655. readonly total: number;
  90656. /**
  90657. * Gets the total value count
  90658. */
  90659. readonly count: number;
  90660. /**
  90661. * Creates a new counter
  90662. */
  90663. constructor();
  90664. /**
  90665. * Call this method to start monitoring a new frame.
  90666. * 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.
  90667. */
  90668. fetchNewFrame(): void;
  90669. /**
  90670. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90671. * @param newCount the count value to add to the monitored count
  90672. * @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.
  90673. */
  90674. addCount(newCount: number, fetchResult: boolean): void;
  90675. /**
  90676. * Start monitoring this performance counter
  90677. */
  90678. beginMonitoring(): void;
  90679. /**
  90680. * Compute the time lapsed since the previous beginMonitoring() call.
  90681. * @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
  90682. */
  90683. endMonitoring(newFrame?: boolean): void;
  90684. private _fetchResult;
  90685. private _startMonitoringTime;
  90686. private _min;
  90687. private _max;
  90688. private _average;
  90689. private _current;
  90690. private _totalValueCount;
  90691. private _totalAccumulated;
  90692. private _lastSecAverage;
  90693. private _lastSecAccumulated;
  90694. private _lastSecTime;
  90695. private _lastSecValueCount;
  90696. }
  90697. /**
  90698. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90699. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90700. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90701. * @param name The name of the class, case should be preserved
  90702. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90703. */
  90704. export function className(name: string, module?: string): (target: Object) => void;
  90705. /**
  90706. * An implementation of a loop for asynchronous functions.
  90707. */
  90708. export class AsyncLoop {
  90709. /**
  90710. * Defines the number of iterations for the loop
  90711. */
  90712. iterations: number;
  90713. /**
  90714. * Defines the current index of the loop.
  90715. */
  90716. index: number;
  90717. private _done;
  90718. private _fn;
  90719. private _successCallback;
  90720. /**
  90721. * Constructor.
  90722. * @param iterations the number of iterations.
  90723. * @param func the function to run each iteration
  90724. * @param successCallback the callback that will be called upon succesful execution
  90725. * @param offset starting offset.
  90726. */
  90727. constructor(
  90728. /**
  90729. * Defines the number of iterations for the loop
  90730. */
  90731. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90732. /**
  90733. * Execute the next iteration. Must be called after the last iteration was finished.
  90734. */
  90735. executeNext(): void;
  90736. /**
  90737. * Break the loop and run the success callback.
  90738. */
  90739. breakLoop(): void;
  90740. /**
  90741. * Create and run an async loop.
  90742. * @param iterations the number of iterations.
  90743. * @param fn the function to run each iteration
  90744. * @param successCallback the callback that will be called upon succesful execution
  90745. * @param offset starting offset.
  90746. * @returns the created async loop object
  90747. */
  90748. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90749. /**
  90750. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90751. * @param iterations total number of iterations
  90752. * @param syncedIterations number of synchronous iterations in each async iteration.
  90753. * @param fn the function to call each iteration.
  90754. * @param callback a success call back that will be called when iterating stops.
  90755. * @param breakFunction a break condition (optional)
  90756. * @param timeout timeout settings for the setTimeout function. default - 0.
  90757. * @returns the created async loop object
  90758. */
  90759. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90760. }
  90761. }
  90762. declare module BABYLON {
  90763. /** @hidden */
  90764. export interface ICollisionCoordinator {
  90765. createCollider(): Collider;
  90766. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90767. init(scene: Scene): void;
  90768. }
  90769. /** @hidden */
  90770. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90771. private _scene;
  90772. private _scaledPosition;
  90773. private _scaledVelocity;
  90774. private _finalPosition;
  90775. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90776. createCollider(): Collider;
  90777. init(scene: Scene): void;
  90778. private _collideWithWorld;
  90779. }
  90780. }
  90781. declare module BABYLON {
  90782. /**
  90783. * This class defines the direct association between an animation and a target
  90784. */
  90785. export class TargetedAnimation {
  90786. /**
  90787. * Animation to perform
  90788. */
  90789. animation: Animation;
  90790. /**
  90791. * Target to animate
  90792. */
  90793. target: any;
  90794. }
  90795. /**
  90796. * Use this class to create coordinated animations on multiple targets
  90797. */
  90798. export class AnimationGroup implements IDisposable {
  90799. /** The name of the animation group */
  90800. name: string;
  90801. private _scene;
  90802. private _targetedAnimations;
  90803. private _animatables;
  90804. private _from;
  90805. private _to;
  90806. private _isStarted;
  90807. private _isPaused;
  90808. private _speedRatio;
  90809. /**
  90810. * Gets or sets the unique id of the node
  90811. */
  90812. uniqueId: number;
  90813. /**
  90814. * This observable will notify when one animation have ended
  90815. */
  90816. onAnimationEndObservable: Observable<TargetedAnimation>;
  90817. /**
  90818. * Observer raised when one animation loops
  90819. */
  90820. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90821. /**
  90822. * This observable will notify when all animations have ended.
  90823. */
  90824. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90825. /**
  90826. * This observable will notify when all animations have paused.
  90827. */
  90828. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90829. /**
  90830. * This observable will notify when all animations are playing.
  90831. */
  90832. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90833. /**
  90834. * Gets the first frame
  90835. */
  90836. readonly from: number;
  90837. /**
  90838. * Gets the last frame
  90839. */
  90840. readonly to: number;
  90841. /**
  90842. * Define if the animations are started
  90843. */
  90844. readonly isStarted: boolean;
  90845. /**
  90846. * Gets a value indicating that the current group is playing
  90847. */
  90848. readonly isPlaying: boolean;
  90849. /**
  90850. * Gets or sets the speed ratio to use for all animations
  90851. */
  90852. /**
  90853. * Gets or sets the speed ratio to use for all animations
  90854. */
  90855. speedRatio: number;
  90856. /**
  90857. * Gets the targeted animations for this animation group
  90858. */
  90859. readonly targetedAnimations: Array<TargetedAnimation>;
  90860. /**
  90861. * returning the list of animatables controlled by this animation group.
  90862. */
  90863. readonly animatables: Array<Animatable>;
  90864. /**
  90865. * Instantiates a new Animation Group.
  90866. * This helps managing several animations at once.
  90867. * @see http://doc.babylonjs.com/how_to/group
  90868. * @param name Defines the name of the group
  90869. * @param scene Defines the scene the group belongs to
  90870. */
  90871. constructor(
  90872. /** The name of the animation group */
  90873. name: string, scene?: Nullable<Scene>);
  90874. /**
  90875. * Add an animation (with its target) in the group
  90876. * @param animation defines the animation we want to add
  90877. * @param target defines the target of the animation
  90878. * @returns the TargetedAnimation object
  90879. */
  90880. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90881. /**
  90882. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90883. * It can add constant keys at begin or end
  90884. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90885. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90886. * @returns the animation group
  90887. */
  90888. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90889. /**
  90890. * Start all animations on given targets
  90891. * @param loop defines if animations must loop
  90892. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90893. * @param from defines the from key (optional)
  90894. * @param to defines the to key (optional)
  90895. * @returns the current animation group
  90896. */
  90897. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90898. /**
  90899. * Pause all animations
  90900. * @returns the animation group
  90901. */
  90902. pause(): AnimationGroup;
  90903. /**
  90904. * Play all animations to initial state
  90905. * This function will start() the animations if they were not started or will restart() them if they were paused
  90906. * @param loop defines if animations must loop
  90907. * @returns the animation group
  90908. */
  90909. play(loop?: boolean): AnimationGroup;
  90910. /**
  90911. * Reset all animations to initial state
  90912. * @returns the animation group
  90913. */
  90914. reset(): AnimationGroup;
  90915. /**
  90916. * Restart animations from key 0
  90917. * @returns the animation group
  90918. */
  90919. restart(): AnimationGroup;
  90920. /**
  90921. * Stop all animations
  90922. * @returns the animation group
  90923. */
  90924. stop(): AnimationGroup;
  90925. /**
  90926. * Set animation weight for all animatables
  90927. * @param weight defines the weight to use
  90928. * @return the animationGroup
  90929. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90930. */
  90931. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90932. /**
  90933. * Synchronize and normalize all animatables with a source animatable
  90934. * @param root defines the root animatable to synchronize with
  90935. * @return the animationGroup
  90936. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90937. */
  90938. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90939. /**
  90940. * Goes to a specific frame in this animation group
  90941. * @param frame the frame number to go to
  90942. * @return the animationGroup
  90943. */
  90944. goToFrame(frame: number): AnimationGroup;
  90945. /**
  90946. * Dispose all associated resources
  90947. */
  90948. dispose(): void;
  90949. private _checkAnimationGroupEnded;
  90950. /**
  90951. * Clone the current animation group and returns a copy
  90952. * @param newName defines the name of the new group
  90953. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90954. * @returns the new aniamtion group
  90955. */
  90956. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90957. /**
  90958. * Returns a new AnimationGroup object parsed from the source provided.
  90959. * @param parsedAnimationGroup defines the source
  90960. * @param scene defines the scene that will receive the animationGroup
  90961. * @returns a new AnimationGroup
  90962. */
  90963. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90964. /**
  90965. * Returns the string "AnimationGroup"
  90966. * @returns "AnimationGroup"
  90967. */
  90968. getClassName(): string;
  90969. /**
  90970. * Creates a detailled string about the object
  90971. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90972. * @returns a string representing the object
  90973. */
  90974. toString(fullDetails?: boolean): string;
  90975. }
  90976. }
  90977. declare module BABYLON {
  90978. /**
  90979. * Define an interface for all classes that will hold resources
  90980. */
  90981. export interface IDisposable {
  90982. /**
  90983. * Releases all held resources
  90984. */
  90985. dispose(): void;
  90986. }
  90987. /** Interface defining initialization parameters for Scene class */
  90988. export interface SceneOptions {
  90989. /**
  90990. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90991. * It will improve performance when the number of geometries becomes important.
  90992. */
  90993. useGeometryUniqueIdsMap?: boolean;
  90994. /**
  90995. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90996. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90997. */
  90998. useMaterialMeshMap?: boolean;
  90999. /**
  91000. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91001. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91002. */
  91003. useClonedMeshhMap?: boolean;
  91004. }
  91005. /**
  91006. * Represents a scene to be rendered by the engine.
  91007. * @see http://doc.babylonjs.com/features/scene
  91008. */
  91009. export class Scene extends AbstractScene implements IAnimatable {
  91010. private static _uniqueIdCounter;
  91011. /** The fog is deactivated */
  91012. static readonly FOGMODE_NONE: number;
  91013. /** The fog density is following an exponential function */
  91014. static readonly FOGMODE_EXP: number;
  91015. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91016. static readonly FOGMODE_EXP2: number;
  91017. /** The fog density is following a linear function. */
  91018. static readonly FOGMODE_LINEAR: number;
  91019. /**
  91020. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91021. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91022. */
  91023. static MinDeltaTime: number;
  91024. /**
  91025. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91027. */
  91028. static MaxDeltaTime: number;
  91029. /**
  91030. * Factory used to create the default material.
  91031. * @param name The name of the material to create
  91032. * @param scene The scene to create the material for
  91033. * @returns The default material
  91034. */
  91035. static DefaultMaterialFactory(scene: Scene): Material;
  91036. /**
  91037. * Factory used to create the a collision coordinator.
  91038. * @returns The collision coordinator
  91039. */
  91040. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91041. /** @hidden */
  91042. readonly _isScene: boolean;
  91043. /**
  91044. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91045. */
  91046. autoClear: boolean;
  91047. /**
  91048. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91049. */
  91050. autoClearDepthAndStencil: boolean;
  91051. /**
  91052. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91053. */
  91054. clearColor: Color4;
  91055. /**
  91056. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91057. */
  91058. ambientColor: Color3;
  91059. /**
  91060. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91061. * It should only be one of the following (if not the default embedded one):
  91062. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91063. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91064. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91065. * The material properties need to be setup according to the type of texture in use.
  91066. */
  91067. environmentBRDFTexture: BaseTexture;
  91068. /** @hidden */
  91069. protected _environmentTexture: Nullable<BaseTexture>;
  91070. /**
  91071. * Texture used in all pbr material as the reflection texture.
  91072. * As in the majority of the scene they are the same (exception for multi room and so on),
  91073. * this is easier to reference from here than from all the materials.
  91074. */
  91075. /**
  91076. * Texture used in all pbr material as the reflection texture.
  91077. * As in the majority of the scene they are the same (exception for multi room and so on),
  91078. * this is easier to set here than in all the materials.
  91079. */
  91080. environmentTexture: Nullable<BaseTexture>;
  91081. /** @hidden */
  91082. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91083. /**
  91084. * Default image processing configuration used either in the rendering
  91085. * Forward main pass or through the imageProcessingPostProcess if present.
  91086. * As in the majority of the scene they are the same (exception for multi camera),
  91087. * this is easier to reference from here than from all the materials and post process.
  91088. *
  91089. * No setter as we it is a shared configuration, you can set the values instead.
  91090. */
  91091. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91092. private _forceWireframe;
  91093. /**
  91094. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91095. */
  91096. forceWireframe: boolean;
  91097. private _forcePointsCloud;
  91098. /**
  91099. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91100. */
  91101. forcePointsCloud: boolean;
  91102. /**
  91103. * Gets or sets the active clipplane 1
  91104. */
  91105. clipPlane: Nullable<Plane>;
  91106. /**
  91107. * Gets or sets the active clipplane 2
  91108. */
  91109. clipPlane2: Nullable<Plane>;
  91110. /**
  91111. * Gets or sets the active clipplane 3
  91112. */
  91113. clipPlane3: Nullable<Plane>;
  91114. /**
  91115. * Gets or sets the active clipplane 4
  91116. */
  91117. clipPlane4: Nullable<Plane>;
  91118. /**
  91119. * Gets or sets a boolean indicating if animations are enabled
  91120. */
  91121. animationsEnabled: boolean;
  91122. private _animationPropertiesOverride;
  91123. /**
  91124. * Gets or sets the animation properties override
  91125. */
  91126. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91127. /**
  91128. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91129. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91130. */
  91131. useConstantAnimationDeltaTime: boolean;
  91132. /**
  91133. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91134. * Please note that it requires to run a ray cast through the scene on every frame
  91135. */
  91136. constantlyUpdateMeshUnderPointer: boolean;
  91137. /**
  91138. * Defines the HTML cursor to use when hovering over interactive elements
  91139. */
  91140. hoverCursor: string;
  91141. /**
  91142. * Defines the HTML default cursor to use (empty by default)
  91143. */
  91144. defaultCursor: string;
  91145. /**
  91146. * This is used to call preventDefault() on pointer down
  91147. * in order to block unwanted artifacts like system double clicks
  91148. */
  91149. preventDefaultOnPointerDown: boolean;
  91150. /**
  91151. * This is used to call preventDefault() on pointer up
  91152. * in order to block unwanted artifacts like system double clicks
  91153. */
  91154. preventDefaultOnPointerUp: boolean;
  91155. /**
  91156. * Gets or sets user defined metadata
  91157. */
  91158. metadata: any;
  91159. /**
  91160. * For internal use only. Please do not use.
  91161. */
  91162. reservedDataStore: any;
  91163. /**
  91164. * Gets the name of the plugin used to load this scene (null by default)
  91165. */
  91166. loadingPluginName: string;
  91167. /**
  91168. * Use this array to add regular expressions used to disable offline support for specific urls
  91169. */
  91170. disableOfflineSupportExceptionRules: RegExp[];
  91171. /**
  91172. * An event triggered when the scene is disposed.
  91173. */
  91174. onDisposeObservable: Observable<Scene>;
  91175. private _onDisposeObserver;
  91176. /** Sets a function to be executed when this scene is disposed. */
  91177. onDispose: () => void;
  91178. /**
  91179. * An event triggered before rendering the scene (right after animations and physics)
  91180. */
  91181. onBeforeRenderObservable: Observable<Scene>;
  91182. private _onBeforeRenderObserver;
  91183. /** Sets a function to be executed before rendering this scene */
  91184. beforeRender: Nullable<() => void>;
  91185. /**
  91186. * An event triggered after rendering the scene
  91187. */
  91188. onAfterRenderObservable: Observable<Scene>;
  91189. private _onAfterRenderObserver;
  91190. /** Sets a function to be executed after rendering this scene */
  91191. afterRender: Nullable<() => void>;
  91192. /**
  91193. * An event triggered before animating the scene
  91194. */
  91195. onBeforeAnimationsObservable: Observable<Scene>;
  91196. /**
  91197. * An event triggered after animations processing
  91198. */
  91199. onAfterAnimationsObservable: Observable<Scene>;
  91200. /**
  91201. * An event triggered before draw calls are ready to be sent
  91202. */
  91203. onBeforeDrawPhaseObservable: Observable<Scene>;
  91204. /**
  91205. * An event triggered after draw calls have been sent
  91206. */
  91207. onAfterDrawPhaseObservable: Observable<Scene>;
  91208. /**
  91209. * An event triggered when the scene is ready
  91210. */
  91211. onReadyObservable: Observable<Scene>;
  91212. /**
  91213. * An event triggered before rendering a camera
  91214. */
  91215. onBeforeCameraRenderObservable: Observable<Camera>;
  91216. private _onBeforeCameraRenderObserver;
  91217. /** Sets a function to be executed before rendering a camera*/
  91218. beforeCameraRender: () => void;
  91219. /**
  91220. * An event triggered after rendering a camera
  91221. */
  91222. onAfterCameraRenderObservable: Observable<Camera>;
  91223. private _onAfterCameraRenderObserver;
  91224. /** Sets a function to be executed after rendering a camera*/
  91225. afterCameraRender: () => void;
  91226. /**
  91227. * An event triggered when active meshes evaluation is about to start
  91228. */
  91229. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91230. /**
  91231. * An event triggered when active meshes evaluation is done
  91232. */
  91233. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91234. /**
  91235. * An event triggered when particles rendering is about to start
  91236. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91237. */
  91238. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91239. /**
  91240. * An event triggered when particles rendering is done
  91241. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91242. */
  91243. onAfterParticlesRenderingObservable: Observable<Scene>;
  91244. /**
  91245. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91246. */
  91247. onDataLoadedObservable: Observable<Scene>;
  91248. /**
  91249. * An event triggered when a camera is created
  91250. */
  91251. onNewCameraAddedObservable: Observable<Camera>;
  91252. /**
  91253. * An event triggered when a camera is removed
  91254. */
  91255. onCameraRemovedObservable: Observable<Camera>;
  91256. /**
  91257. * An event triggered when a light is created
  91258. */
  91259. onNewLightAddedObservable: Observable<Light>;
  91260. /**
  91261. * An event triggered when a light is removed
  91262. */
  91263. onLightRemovedObservable: Observable<Light>;
  91264. /**
  91265. * An event triggered when a geometry is created
  91266. */
  91267. onNewGeometryAddedObservable: Observable<Geometry>;
  91268. /**
  91269. * An event triggered when a geometry is removed
  91270. */
  91271. onGeometryRemovedObservable: Observable<Geometry>;
  91272. /**
  91273. * An event triggered when a transform node is created
  91274. */
  91275. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91276. /**
  91277. * An event triggered when a transform node is removed
  91278. */
  91279. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91280. /**
  91281. * An event triggered when a mesh is created
  91282. */
  91283. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91284. /**
  91285. * An event triggered when a mesh is removed
  91286. */
  91287. onMeshRemovedObservable: Observable<AbstractMesh>;
  91288. /**
  91289. * An event triggered when a skeleton is created
  91290. */
  91291. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91292. /**
  91293. * An event triggered when a skeleton is removed
  91294. */
  91295. onSkeletonRemovedObservable: Observable<Skeleton>;
  91296. /**
  91297. * An event triggered when a material is created
  91298. */
  91299. onNewMaterialAddedObservable: Observable<Material>;
  91300. /**
  91301. * An event triggered when a material is removed
  91302. */
  91303. onMaterialRemovedObservable: Observable<Material>;
  91304. /**
  91305. * An event triggered when a texture is created
  91306. */
  91307. onNewTextureAddedObservable: Observable<BaseTexture>;
  91308. /**
  91309. * An event triggered when a texture is removed
  91310. */
  91311. onTextureRemovedObservable: Observable<BaseTexture>;
  91312. /**
  91313. * An event triggered when render targets are about to be rendered
  91314. * Can happen multiple times per frame.
  91315. */
  91316. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91317. /**
  91318. * An event triggered when render targets were rendered.
  91319. * Can happen multiple times per frame.
  91320. */
  91321. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91322. /**
  91323. * An event triggered before calculating deterministic simulation step
  91324. */
  91325. onBeforeStepObservable: Observable<Scene>;
  91326. /**
  91327. * An event triggered after calculating deterministic simulation step
  91328. */
  91329. onAfterStepObservable: Observable<Scene>;
  91330. /**
  91331. * An event triggered when the activeCamera property is updated
  91332. */
  91333. onActiveCameraChanged: Observable<Scene>;
  91334. /**
  91335. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91336. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91337. * 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)
  91338. */
  91339. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91340. /**
  91341. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91342. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91343. * 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)
  91344. */
  91345. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91346. /**
  91347. * This Observable will when a mesh has been imported into the scene.
  91348. */
  91349. onMeshImportedObservable: Observable<AbstractMesh>;
  91350. /**
  91351. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91352. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91353. */
  91354. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91355. /** @hidden */
  91356. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91357. /**
  91358. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91359. */
  91360. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91361. /**
  91362. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91363. */
  91364. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91365. /**
  91366. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91367. */
  91368. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91369. private _onPointerMove;
  91370. private _onPointerDown;
  91371. private _onPointerUp;
  91372. /** Callback called when a pointer move is detected */
  91373. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91374. /** Callback called when a pointer down is detected */
  91375. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91376. /** Callback called when a pointer up is detected */
  91377. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91378. /** Callback called when a pointer pick is detected */
  91379. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91380. /**
  91381. * 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).
  91382. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91383. */
  91384. onPrePointerObservable: Observable<PointerInfoPre>;
  91385. /**
  91386. * Observable event triggered each time an input event is received from the rendering canvas
  91387. */
  91388. onPointerObservable: Observable<PointerInfo>;
  91389. /**
  91390. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91391. */
  91392. readonly unTranslatedPointer: Vector2;
  91393. /** The distance in pixel that you have to move to prevent some events */
  91394. static DragMovementThreshold: number;
  91395. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91396. static LongPressDelay: number;
  91397. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91398. static DoubleClickDelay: number;
  91399. /** If you need to check double click without raising a single click at first click, enable this flag */
  91400. static ExclusiveDoubleClickMode: boolean;
  91401. private _initClickEvent;
  91402. private _initActionManager;
  91403. private _delayedSimpleClick;
  91404. private _delayedSimpleClickTimeout;
  91405. private _previousDelayedSimpleClickTimeout;
  91406. private _meshPickProceed;
  91407. private _previousButtonPressed;
  91408. private _currentPickResult;
  91409. private _previousPickResult;
  91410. private _totalPointersPressed;
  91411. private _doubleClickOccured;
  91412. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91413. cameraToUseForPointers: Nullable<Camera>;
  91414. private _pointerX;
  91415. private _pointerY;
  91416. private _unTranslatedPointerX;
  91417. private _unTranslatedPointerY;
  91418. private _startingPointerPosition;
  91419. private _previousStartingPointerPosition;
  91420. private _startingPointerTime;
  91421. private _previousStartingPointerTime;
  91422. private _pointerCaptures;
  91423. private _timeAccumulator;
  91424. private _currentStepId;
  91425. private _currentInternalStep;
  91426. /** @hidden */
  91427. _mirroredCameraPosition: Nullable<Vector3>;
  91428. /**
  91429. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91430. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91431. */
  91432. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91433. /**
  91434. * Observable event triggered each time an keyboard event is received from the hosting window
  91435. */
  91436. onKeyboardObservable: Observable<KeyboardInfo>;
  91437. private _onKeyDown;
  91438. private _onKeyUp;
  91439. private _onCanvasFocusObserver;
  91440. private _onCanvasBlurObserver;
  91441. private _useRightHandedSystem;
  91442. /**
  91443. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91444. */
  91445. useRightHandedSystem: boolean;
  91446. /**
  91447. * Sets the step Id used by deterministic lock step
  91448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91449. * @param newStepId defines the step Id
  91450. */
  91451. setStepId(newStepId: number): void;
  91452. /**
  91453. * Gets the step Id used by deterministic lock step
  91454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91455. * @returns the step Id
  91456. */
  91457. getStepId(): number;
  91458. /**
  91459. * Gets the internal step used by deterministic lock step
  91460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91461. * @returns the internal step
  91462. */
  91463. getInternalStep(): number;
  91464. private _fogEnabled;
  91465. /**
  91466. * Gets or sets a boolean indicating if fog is enabled on this scene
  91467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91468. * (Default is true)
  91469. */
  91470. fogEnabled: boolean;
  91471. private _fogMode;
  91472. /**
  91473. * Gets or sets the fog mode to use
  91474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91475. * | mode | value |
  91476. * | --- | --- |
  91477. * | FOGMODE_NONE | 0 |
  91478. * | FOGMODE_EXP | 1 |
  91479. * | FOGMODE_EXP2 | 2 |
  91480. * | FOGMODE_LINEAR | 3 |
  91481. */
  91482. fogMode: number;
  91483. /**
  91484. * Gets or sets the fog color to use
  91485. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91486. * (Default is Color3(0.2, 0.2, 0.3))
  91487. */
  91488. fogColor: Color3;
  91489. /**
  91490. * Gets or sets the fog density to use
  91491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91492. * (Default is 0.1)
  91493. */
  91494. fogDensity: number;
  91495. /**
  91496. * Gets or sets the fog start distance to use
  91497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91498. * (Default is 0)
  91499. */
  91500. fogStart: number;
  91501. /**
  91502. * Gets or sets the fog end distance to use
  91503. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91504. * (Default is 1000)
  91505. */
  91506. fogEnd: number;
  91507. private _shadowsEnabled;
  91508. /**
  91509. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91510. */
  91511. shadowsEnabled: boolean;
  91512. private _lightsEnabled;
  91513. /**
  91514. * Gets or sets a boolean indicating if lights are enabled on this scene
  91515. */
  91516. lightsEnabled: boolean;
  91517. /** All of the active cameras added to this scene. */
  91518. activeCameras: Camera[];
  91519. /** @hidden */
  91520. _activeCamera: Nullable<Camera>;
  91521. /** Gets or sets the current active camera */
  91522. activeCamera: Nullable<Camera>;
  91523. private _defaultMaterial;
  91524. /** The default material used on meshes when no material is affected */
  91525. /** The default material used on meshes when no material is affected */
  91526. defaultMaterial: Material;
  91527. private _texturesEnabled;
  91528. /**
  91529. * Gets or sets a boolean indicating if textures are enabled on this scene
  91530. */
  91531. texturesEnabled: boolean;
  91532. /**
  91533. * Gets or sets a boolean indicating if particles are enabled on this scene
  91534. */
  91535. particlesEnabled: boolean;
  91536. /**
  91537. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91538. */
  91539. spritesEnabled: boolean;
  91540. private _skeletonsEnabled;
  91541. /**
  91542. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91543. */
  91544. skeletonsEnabled: boolean;
  91545. /**
  91546. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91547. */
  91548. lensFlaresEnabled: boolean;
  91549. /**
  91550. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91552. */
  91553. collisionsEnabled: boolean;
  91554. private _collisionCoordinator;
  91555. /** @hidden */
  91556. readonly collisionCoordinator: ICollisionCoordinator;
  91557. /**
  91558. * Defines the gravity applied to this scene (used only for collisions)
  91559. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91560. */
  91561. gravity: Vector3;
  91562. /**
  91563. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91564. */
  91565. postProcessesEnabled: boolean;
  91566. /**
  91567. * The list of postprocesses added to the scene
  91568. */
  91569. postProcesses: PostProcess[];
  91570. /**
  91571. * Gets the current postprocess manager
  91572. */
  91573. postProcessManager: PostProcessManager;
  91574. /**
  91575. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91576. */
  91577. renderTargetsEnabled: boolean;
  91578. /**
  91579. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91580. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91581. */
  91582. dumpNextRenderTargets: boolean;
  91583. /**
  91584. * The list of user defined render targets added to the scene
  91585. */
  91586. customRenderTargets: RenderTargetTexture[];
  91587. /**
  91588. * Defines if texture loading must be delayed
  91589. * If true, textures will only be loaded when they need to be rendered
  91590. */
  91591. useDelayedTextureLoading: boolean;
  91592. /**
  91593. * Gets the list of meshes imported to the scene through SceneLoader
  91594. */
  91595. importedMeshesFiles: String[];
  91596. /**
  91597. * Gets or sets a boolean indicating if probes are enabled on this scene
  91598. */
  91599. probesEnabled: boolean;
  91600. /**
  91601. * Gets or sets the current offline provider to use to store scene data
  91602. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91603. */
  91604. offlineProvider: IOfflineProvider;
  91605. /**
  91606. * Gets or sets the action manager associated with the scene
  91607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91608. */
  91609. actionManager: AbstractActionManager;
  91610. private _meshesForIntersections;
  91611. /**
  91612. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91613. */
  91614. proceduralTexturesEnabled: boolean;
  91615. private _engine;
  91616. private _totalVertices;
  91617. /** @hidden */
  91618. _activeIndices: PerfCounter;
  91619. /** @hidden */
  91620. _activeParticles: PerfCounter;
  91621. /** @hidden */
  91622. _activeBones: PerfCounter;
  91623. private _animationRatio;
  91624. /** @hidden */
  91625. _animationTimeLast: number;
  91626. /** @hidden */
  91627. _animationTime: number;
  91628. /**
  91629. * Gets or sets a general scale for animation speed
  91630. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91631. */
  91632. animationTimeScale: number;
  91633. /** @hidden */
  91634. _cachedMaterial: Nullable<Material>;
  91635. /** @hidden */
  91636. _cachedEffect: Nullable<Effect>;
  91637. /** @hidden */
  91638. _cachedVisibility: Nullable<number>;
  91639. private _renderId;
  91640. private _frameId;
  91641. private _executeWhenReadyTimeoutId;
  91642. private _intermediateRendering;
  91643. private _viewUpdateFlag;
  91644. private _projectionUpdateFlag;
  91645. /** @hidden */
  91646. _toBeDisposed: Nullable<IDisposable>[];
  91647. private _activeRequests;
  91648. /** @hidden */
  91649. _pendingData: any[];
  91650. private _isDisposed;
  91651. /**
  91652. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91653. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91654. */
  91655. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91656. private _activeMeshes;
  91657. private _processedMaterials;
  91658. private _renderTargets;
  91659. /** @hidden */
  91660. _activeParticleSystems: SmartArray<IParticleSystem>;
  91661. private _activeSkeletons;
  91662. private _softwareSkinnedMeshes;
  91663. private _renderingManager;
  91664. /** @hidden */
  91665. _activeAnimatables: Animatable[];
  91666. private _transformMatrix;
  91667. private _sceneUbo;
  91668. /** @hidden */
  91669. _viewMatrix: Matrix;
  91670. private _projectionMatrix;
  91671. private _wheelEventName;
  91672. /** @hidden */
  91673. _forcedViewPosition: Nullable<Vector3>;
  91674. /** @hidden */
  91675. _frustumPlanes: Plane[];
  91676. /**
  91677. * Gets the list of frustum planes (built from the active camera)
  91678. */
  91679. readonly frustumPlanes: Plane[];
  91680. /**
  91681. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91682. * This is useful if there are more lights that the maximum simulteanous authorized
  91683. */
  91684. requireLightSorting: boolean;
  91685. /** @hidden */
  91686. readonly useMaterialMeshMap: boolean;
  91687. /** @hidden */
  91688. readonly useClonedMeshhMap: boolean;
  91689. private _pointerOverMesh;
  91690. private _pickedDownMesh;
  91691. private _pickedUpMesh;
  91692. private _externalData;
  91693. private _uid;
  91694. /**
  91695. * @hidden
  91696. * Backing store of defined scene components.
  91697. */
  91698. _components: ISceneComponent[];
  91699. /**
  91700. * @hidden
  91701. * Backing store of defined scene components.
  91702. */
  91703. _serializableComponents: ISceneSerializableComponent[];
  91704. /**
  91705. * List of components to register on the next registration step.
  91706. */
  91707. private _transientComponents;
  91708. /**
  91709. * Registers the transient components if needed.
  91710. */
  91711. private _registerTransientComponents;
  91712. /**
  91713. * @hidden
  91714. * Add a component to the scene.
  91715. * Note that the ccomponent could be registered on th next frame if this is called after
  91716. * the register component stage.
  91717. * @param component Defines the component to add to the scene
  91718. */
  91719. _addComponent(component: ISceneComponent): void;
  91720. /**
  91721. * @hidden
  91722. * Gets a component from the scene.
  91723. * @param name defines the name of the component to retrieve
  91724. * @returns the component or null if not present
  91725. */
  91726. _getComponent(name: string): Nullable<ISceneComponent>;
  91727. /**
  91728. * @hidden
  91729. * Defines the actions happening before camera updates.
  91730. */
  91731. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91732. /**
  91733. * @hidden
  91734. * Defines the actions happening before clear the canvas.
  91735. */
  91736. _beforeClearStage: Stage<SimpleStageAction>;
  91737. /**
  91738. * @hidden
  91739. * Defines the actions when collecting render targets for the frame.
  91740. */
  91741. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91742. /**
  91743. * @hidden
  91744. * Defines the actions happening for one camera in the frame.
  91745. */
  91746. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91747. /**
  91748. * @hidden
  91749. * Defines the actions happening during the per mesh ready checks.
  91750. */
  91751. _isReadyForMeshStage: Stage<MeshStageAction>;
  91752. /**
  91753. * @hidden
  91754. * Defines the actions happening before evaluate active mesh checks.
  91755. */
  91756. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91757. /**
  91758. * @hidden
  91759. * Defines the actions happening during the evaluate sub mesh checks.
  91760. */
  91761. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91762. /**
  91763. * @hidden
  91764. * Defines the actions happening during the active mesh stage.
  91765. */
  91766. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91767. /**
  91768. * @hidden
  91769. * Defines the actions happening during the per camera render target step.
  91770. */
  91771. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91772. /**
  91773. * @hidden
  91774. * Defines the actions happening just before the active camera is drawing.
  91775. */
  91776. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91777. /**
  91778. * @hidden
  91779. * Defines the actions happening just before a render target is drawing.
  91780. */
  91781. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91782. /**
  91783. * @hidden
  91784. * Defines the actions happening just before a rendering group is drawing.
  91785. */
  91786. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91787. /**
  91788. * @hidden
  91789. * Defines the actions happening just before a mesh is drawing.
  91790. */
  91791. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91792. /**
  91793. * @hidden
  91794. * Defines the actions happening just after a mesh has been drawn.
  91795. */
  91796. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91797. /**
  91798. * @hidden
  91799. * Defines the actions happening just after a rendering group has been drawn.
  91800. */
  91801. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91802. /**
  91803. * @hidden
  91804. * Defines the actions happening just after the active camera has been drawn.
  91805. */
  91806. _afterCameraDrawStage: Stage<CameraStageAction>;
  91807. /**
  91808. * @hidden
  91809. * Defines the actions happening just after a render target has been drawn.
  91810. */
  91811. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91812. /**
  91813. * @hidden
  91814. * Defines the actions happening just after rendering all cameras and computing intersections.
  91815. */
  91816. _afterRenderStage: Stage<SimpleStageAction>;
  91817. /**
  91818. * @hidden
  91819. * Defines the actions happening when a pointer move event happens.
  91820. */
  91821. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91822. /**
  91823. * @hidden
  91824. * Defines the actions happening when a pointer down event happens.
  91825. */
  91826. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91827. /**
  91828. * @hidden
  91829. * Defines the actions happening when a pointer up event happens.
  91830. */
  91831. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91832. /**
  91833. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91834. */
  91835. private geometriesByUniqueId;
  91836. /**
  91837. * Creates a new Scene
  91838. * @param engine defines the engine to use to render this scene
  91839. * @param options defines the scene options
  91840. */
  91841. constructor(engine: Engine, options?: SceneOptions);
  91842. /**
  91843. * Gets a string idenfifying the name of the class
  91844. * @returns "Scene" string
  91845. */
  91846. getClassName(): string;
  91847. private _defaultMeshCandidates;
  91848. /**
  91849. * @hidden
  91850. */
  91851. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91852. private _defaultSubMeshCandidates;
  91853. /**
  91854. * @hidden
  91855. */
  91856. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91857. /**
  91858. * Sets the default candidate providers for the scene.
  91859. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91860. * and getCollidingSubMeshCandidates to their default function
  91861. */
  91862. setDefaultCandidateProviders(): void;
  91863. /**
  91864. * Gets the mesh that is currently under the pointer
  91865. */
  91866. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91867. /**
  91868. * Gets or sets the current on-screen X position of the pointer
  91869. */
  91870. pointerX: number;
  91871. /**
  91872. * Gets or sets the current on-screen Y position of the pointer
  91873. */
  91874. pointerY: number;
  91875. /**
  91876. * Gets the cached material (ie. the latest rendered one)
  91877. * @returns the cached material
  91878. */
  91879. getCachedMaterial(): Nullable<Material>;
  91880. /**
  91881. * Gets the cached effect (ie. the latest rendered one)
  91882. * @returns the cached effect
  91883. */
  91884. getCachedEffect(): Nullable<Effect>;
  91885. /**
  91886. * Gets the cached visibility state (ie. the latest rendered one)
  91887. * @returns the cached visibility state
  91888. */
  91889. getCachedVisibility(): Nullable<number>;
  91890. /**
  91891. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91892. * @param material defines the current material
  91893. * @param effect defines the current effect
  91894. * @param visibility defines the current visibility state
  91895. * @returns true if one parameter is not cached
  91896. */
  91897. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91898. /**
  91899. * Gets the engine associated with the scene
  91900. * @returns an Engine
  91901. */
  91902. getEngine(): Engine;
  91903. /**
  91904. * Gets the total number of vertices rendered per frame
  91905. * @returns the total number of vertices rendered per frame
  91906. */
  91907. getTotalVertices(): number;
  91908. /**
  91909. * Gets the performance counter for total vertices
  91910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91911. */
  91912. readonly totalVerticesPerfCounter: PerfCounter;
  91913. /**
  91914. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91915. * @returns the total number of active indices rendered per frame
  91916. */
  91917. getActiveIndices(): number;
  91918. /**
  91919. * Gets the performance counter for active indices
  91920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91921. */
  91922. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91923. /**
  91924. * Gets the total number of active particles rendered per frame
  91925. * @returns the total number of active particles rendered per frame
  91926. */
  91927. getActiveParticles(): number;
  91928. /**
  91929. * Gets the performance counter for active particles
  91930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91931. */
  91932. readonly activeParticlesPerfCounter: PerfCounter;
  91933. /**
  91934. * Gets the total number of active bones rendered per frame
  91935. * @returns the total number of active bones rendered per frame
  91936. */
  91937. getActiveBones(): number;
  91938. /**
  91939. * Gets the performance counter for active bones
  91940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91941. */
  91942. readonly activeBonesPerfCounter: PerfCounter;
  91943. /**
  91944. * Gets the array of active meshes
  91945. * @returns an array of AbstractMesh
  91946. */
  91947. getActiveMeshes(): SmartArray<AbstractMesh>;
  91948. /**
  91949. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91950. * @returns a number
  91951. */
  91952. getAnimationRatio(): number;
  91953. /**
  91954. * Gets an unique Id for the current render phase
  91955. * @returns a number
  91956. */
  91957. getRenderId(): number;
  91958. /**
  91959. * Gets an unique Id for the current frame
  91960. * @returns a number
  91961. */
  91962. getFrameId(): number;
  91963. /** Call this function if you want to manually increment the render Id*/
  91964. incrementRenderId(): void;
  91965. private _updatePointerPosition;
  91966. private _createUbo;
  91967. private _setRayOnPointerInfo;
  91968. /**
  91969. * Use this method to simulate a pointer move on a mesh
  91970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91973. * @returns the current scene
  91974. */
  91975. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91976. private _processPointerMove;
  91977. private _checkPrePointerObservable;
  91978. /**
  91979. * Use this method to simulate a pointer down on a mesh
  91980. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91981. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91982. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91983. * @returns the current scene
  91984. */
  91985. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91986. private _processPointerDown;
  91987. /**
  91988. * Use this method to simulate a pointer up on a mesh
  91989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91992. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91993. * @returns the current scene
  91994. */
  91995. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91996. private _processPointerUp;
  91997. /**
  91998. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91999. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92000. * @returns true if the pointer was captured
  92001. */
  92002. isPointerCaptured(pointerId?: number): boolean;
  92003. /** @hidden */
  92004. _isPointerSwiping(): boolean;
  92005. /**
  92006. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92007. * @param attachUp defines if you want to attach events to pointerup
  92008. * @param attachDown defines if you want to attach events to pointerdown
  92009. * @param attachMove defines if you want to attach events to pointermove
  92010. */
  92011. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92012. /** Detaches all event handlers*/
  92013. detachControl(): void;
  92014. /**
  92015. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92016. * Delay loaded resources are not taking in account
  92017. * @return true if all required resources are ready
  92018. */
  92019. isReady(): boolean;
  92020. /** Resets all cached information relative to material (including effect and visibility) */
  92021. resetCachedMaterial(): void;
  92022. /**
  92023. * Registers a function to be called before every frame render
  92024. * @param func defines the function to register
  92025. */
  92026. registerBeforeRender(func: () => void): void;
  92027. /**
  92028. * Unregisters a function called before every frame render
  92029. * @param func defines the function to unregister
  92030. */
  92031. unregisterBeforeRender(func: () => void): void;
  92032. /**
  92033. * Registers a function to be called after every frame render
  92034. * @param func defines the function to register
  92035. */
  92036. registerAfterRender(func: () => void): void;
  92037. /**
  92038. * Unregisters a function called after every frame render
  92039. * @param func defines the function to unregister
  92040. */
  92041. unregisterAfterRender(func: () => void): void;
  92042. private _executeOnceBeforeRender;
  92043. /**
  92044. * The provided function will run before render once and will be disposed afterwards.
  92045. * A timeout delay can be provided so that the function will be executed in N ms.
  92046. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92047. * @param func The function to be executed.
  92048. * @param timeout optional delay in ms
  92049. */
  92050. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92051. /** @hidden */
  92052. _addPendingData(data: any): void;
  92053. /** @hidden */
  92054. _removePendingData(data: any): void;
  92055. /**
  92056. * Returns the number of items waiting to be loaded
  92057. * @returns the number of items waiting to be loaded
  92058. */
  92059. getWaitingItemsCount(): number;
  92060. /**
  92061. * Returns a boolean indicating if the scene is still loading data
  92062. */
  92063. readonly isLoading: boolean;
  92064. /**
  92065. * Registers a function to be executed when the scene is ready
  92066. * @param {Function} func - the function to be executed
  92067. */
  92068. executeWhenReady(func: () => void): void;
  92069. /**
  92070. * Returns a promise that resolves when the scene is ready
  92071. * @returns A promise that resolves when the scene is ready
  92072. */
  92073. whenReadyAsync(): Promise<void>;
  92074. /** @hidden */
  92075. _checkIsReady(): void;
  92076. /**
  92077. * Gets all animatable attached to the scene
  92078. */
  92079. readonly animatables: Animatable[];
  92080. /**
  92081. * Resets the last animation time frame.
  92082. * Useful to override when animations start running when loading a scene for the first time.
  92083. */
  92084. resetLastAnimationTimeFrame(): void;
  92085. /**
  92086. * Gets the current view matrix
  92087. * @returns a Matrix
  92088. */
  92089. getViewMatrix(): Matrix;
  92090. /**
  92091. * Gets the current projection matrix
  92092. * @returns a Matrix
  92093. */
  92094. getProjectionMatrix(): Matrix;
  92095. /**
  92096. * Gets the current transform matrix
  92097. * @returns a Matrix made of View * Projection
  92098. */
  92099. getTransformMatrix(): Matrix;
  92100. /**
  92101. * Sets the current transform matrix
  92102. * @param viewL defines the View matrix to use
  92103. * @param projectionL defines the Projection matrix to use
  92104. * @param viewR defines the right View matrix to use (if provided)
  92105. * @param projectionR defines the right Projection matrix to use (if provided)
  92106. */
  92107. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92108. /**
  92109. * Gets the uniform buffer used to store scene data
  92110. * @returns a UniformBuffer
  92111. */
  92112. getSceneUniformBuffer(): UniformBuffer;
  92113. /**
  92114. * Gets an unique (relatively to the current scene) Id
  92115. * @returns an unique number for the scene
  92116. */
  92117. getUniqueId(): number;
  92118. /**
  92119. * Add a mesh to the list of scene's meshes
  92120. * @param newMesh defines the mesh to add
  92121. * @param recursive if all child meshes should also be added to the scene
  92122. */
  92123. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92124. /**
  92125. * Remove a mesh for the list of scene's meshes
  92126. * @param toRemove defines the mesh to remove
  92127. * @param recursive if all child meshes should also be removed from the scene
  92128. * @returns the index where the mesh was in the mesh list
  92129. */
  92130. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92131. /**
  92132. * Add a transform node to the list of scene's transform nodes
  92133. * @param newTransformNode defines the transform node to add
  92134. */
  92135. addTransformNode(newTransformNode: TransformNode): void;
  92136. /**
  92137. * Remove a transform node for the list of scene's transform nodes
  92138. * @param toRemove defines the transform node to remove
  92139. * @returns the index where the transform node was in the transform node list
  92140. */
  92141. removeTransformNode(toRemove: TransformNode): number;
  92142. /**
  92143. * Remove a skeleton for the list of scene's skeletons
  92144. * @param toRemove defines the skeleton to remove
  92145. * @returns the index where the skeleton was in the skeleton list
  92146. */
  92147. removeSkeleton(toRemove: Skeleton): number;
  92148. /**
  92149. * Remove a morph target for the list of scene's morph targets
  92150. * @param toRemove defines the morph target to remove
  92151. * @returns the index where the morph target was in the morph target list
  92152. */
  92153. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92154. /**
  92155. * Remove a light for the list of scene's lights
  92156. * @param toRemove defines the light to remove
  92157. * @returns the index where the light was in the light list
  92158. */
  92159. removeLight(toRemove: Light): number;
  92160. /**
  92161. * Remove a camera for the list of scene's cameras
  92162. * @param toRemove defines the camera to remove
  92163. * @returns the index where the camera was in the camera list
  92164. */
  92165. removeCamera(toRemove: Camera): number;
  92166. /**
  92167. * Remove a particle system for the list of scene's particle systems
  92168. * @param toRemove defines the particle system to remove
  92169. * @returns the index where the particle system was in the particle system list
  92170. */
  92171. removeParticleSystem(toRemove: IParticleSystem): number;
  92172. /**
  92173. * Remove a animation for the list of scene's animations
  92174. * @param toRemove defines the animation to remove
  92175. * @returns the index where the animation was in the animation list
  92176. */
  92177. removeAnimation(toRemove: Animation): number;
  92178. /**
  92179. * Removes the given animation group from this scene.
  92180. * @param toRemove The animation group to remove
  92181. * @returns The index of the removed animation group
  92182. */
  92183. removeAnimationGroup(toRemove: AnimationGroup): number;
  92184. /**
  92185. * Removes the given multi-material from this scene.
  92186. * @param toRemove The multi-material to remove
  92187. * @returns The index of the removed multi-material
  92188. */
  92189. removeMultiMaterial(toRemove: MultiMaterial): number;
  92190. /**
  92191. * Removes the given material from this scene.
  92192. * @param toRemove The material to remove
  92193. * @returns The index of the removed material
  92194. */
  92195. removeMaterial(toRemove: Material): number;
  92196. /**
  92197. * Removes the given action manager from this scene.
  92198. * @param toRemove The action manager to remove
  92199. * @returns The index of the removed action manager
  92200. */
  92201. removeActionManager(toRemove: AbstractActionManager): number;
  92202. /**
  92203. * Removes the given texture from this scene.
  92204. * @param toRemove The texture to remove
  92205. * @returns The index of the removed texture
  92206. */
  92207. removeTexture(toRemove: BaseTexture): number;
  92208. /**
  92209. * Adds the given light to this scene
  92210. * @param newLight The light to add
  92211. */
  92212. addLight(newLight: Light): void;
  92213. /**
  92214. * Sorts the list list based on light priorities
  92215. */
  92216. sortLightsByPriority(): void;
  92217. /**
  92218. * Adds the given camera to this scene
  92219. * @param newCamera The camera to add
  92220. */
  92221. addCamera(newCamera: Camera): void;
  92222. /**
  92223. * Adds the given skeleton to this scene
  92224. * @param newSkeleton The skeleton to add
  92225. */
  92226. addSkeleton(newSkeleton: Skeleton): void;
  92227. /**
  92228. * Adds the given particle system to this scene
  92229. * @param newParticleSystem The particle system to add
  92230. */
  92231. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92232. /**
  92233. * Adds the given animation to this scene
  92234. * @param newAnimation The animation to add
  92235. */
  92236. addAnimation(newAnimation: Animation): void;
  92237. /**
  92238. * Adds the given animation group to this scene.
  92239. * @param newAnimationGroup The animation group to add
  92240. */
  92241. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92242. /**
  92243. * Adds the given multi-material to this scene
  92244. * @param newMultiMaterial The multi-material to add
  92245. */
  92246. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92247. /**
  92248. * Adds the given material to this scene
  92249. * @param newMaterial The material to add
  92250. */
  92251. addMaterial(newMaterial: Material): void;
  92252. /**
  92253. * Adds the given morph target to this scene
  92254. * @param newMorphTargetManager The morph target to add
  92255. */
  92256. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92257. /**
  92258. * Adds the given geometry to this scene
  92259. * @param newGeometry The geometry to add
  92260. */
  92261. addGeometry(newGeometry: Geometry): void;
  92262. /**
  92263. * Adds the given action manager to this scene
  92264. * @param newActionManager The action manager to add
  92265. */
  92266. addActionManager(newActionManager: AbstractActionManager): void;
  92267. /**
  92268. * Adds the given texture to this scene.
  92269. * @param newTexture The texture to add
  92270. */
  92271. addTexture(newTexture: BaseTexture): void;
  92272. /**
  92273. * Switch active camera
  92274. * @param newCamera defines the new active camera
  92275. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92276. */
  92277. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92278. /**
  92279. * sets the active camera of the scene using its ID
  92280. * @param id defines the camera's ID
  92281. * @return the new active camera or null if none found.
  92282. */
  92283. setActiveCameraByID(id: string): Nullable<Camera>;
  92284. /**
  92285. * sets the active camera of the scene using its name
  92286. * @param name defines the camera's name
  92287. * @returns the new active camera or null if none found.
  92288. */
  92289. setActiveCameraByName(name: string): Nullable<Camera>;
  92290. /**
  92291. * get an animation group using its name
  92292. * @param name defines the material's name
  92293. * @return the animation group or null if none found.
  92294. */
  92295. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92296. /**
  92297. * Get a material using its unique id
  92298. * @param uniqueId defines the material's unique id
  92299. * @return the material or null if none found.
  92300. */
  92301. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92302. /**
  92303. * get a material using its id
  92304. * @param id defines the material's ID
  92305. * @return the material or null if none found.
  92306. */
  92307. getMaterialByID(id: string): Nullable<Material>;
  92308. /**
  92309. * Gets a material using its name
  92310. * @param name defines the material's name
  92311. * @return the material or null if none found.
  92312. */
  92313. getMaterialByName(name: string): Nullable<Material>;
  92314. /**
  92315. * Gets a camera using its id
  92316. * @param id defines the id to look for
  92317. * @returns the camera or null if not found
  92318. */
  92319. getCameraByID(id: string): Nullable<Camera>;
  92320. /**
  92321. * Gets a camera using its unique id
  92322. * @param uniqueId defines the unique id to look for
  92323. * @returns the camera or null if not found
  92324. */
  92325. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92326. /**
  92327. * Gets a camera using its name
  92328. * @param name defines the camera's name
  92329. * @return the camera or null if none found.
  92330. */
  92331. getCameraByName(name: string): Nullable<Camera>;
  92332. /**
  92333. * Gets a bone using its id
  92334. * @param id defines the bone's id
  92335. * @return the bone or null if not found
  92336. */
  92337. getBoneByID(id: string): Nullable<Bone>;
  92338. /**
  92339. * Gets a bone using its id
  92340. * @param name defines the bone's name
  92341. * @return the bone or null if not found
  92342. */
  92343. getBoneByName(name: string): Nullable<Bone>;
  92344. /**
  92345. * Gets a light node using its name
  92346. * @param name defines the the light's name
  92347. * @return the light or null if none found.
  92348. */
  92349. getLightByName(name: string): Nullable<Light>;
  92350. /**
  92351. * Gets a light node using its id
  92352. * @param id defines the light's id
  92353. * @return the light or null if none found.
  92354. */
  92355. getLightByID(id: string): Nullable<Light>;
  92356. /**
  92357. * Gets a light node using its scene-generated unique ID
  92358. * @param uniqueId defines the light's unique id
  92359. * @return the light or null if none found.
  92360. */
  92361. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92362. /**
  92363. * Gets a particle system by id
  92364. * @param id defines the particle system id
  92365. * @return the corresponding system or null if none found
  92366. */
  92367. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92368. /**
  92369. * Gets a geometry using its ID
  92370. * @param id defines the geometry's id
  92371. * @return the geometry or null if none found.
  92372. */
  92373. getGeometryByID(id: string): Nullable<Geometry>;
  92374. private _getGeometryByUniqueID;
  92375. /**
  92376. * Add a new geometry to this scene
  92377. * @param geometry defines the geometry to be added to the scene.
  92378. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92379. * @return a boolean defining if the geometry was added or not
  92380. */
  92381. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92382. /**
  92383. * Removes an existing geometry
  92384. * @param geometry defines the geometry to be removed from the scene
  92385. * @return a boolean defining if the geometry was removed or not
  92386. */
  92387. removeGeometry(geometry: Geometry): boolean;
  92388. /**
  92389. * Gets the list of geometries attached to the scene
  92390. * @returns an array of Geometry
  92391. */
  92392. getGeometries(): Geometry[];
  92393. /**
  92394. * Gets the first added mesh found of a given ID
  92395. * @param id defines the id to search for
  92396. * @return the mesh found or null if not found at all
  92397. */
  92398. getMeshByID(id: string): Nullable<AbstractMesh>;
  92399. /**
  92400. * Gets a list of meshes using their id
  92401. * @param id defines the id to search for
  92402. * @returns a list of meshes
  92403. */
  92404. getMeshesByID(id: string): Array<AbstractMesh>;
  92405. /**
  92406. * Gets the first added transform node found of a given ID
  92407. * @param id defines the id to search for
  92408. * @return the found transform node or null if not found at all.
  92409. */
  92410. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92411. /**
  92412. * Gets a transform node with its auto-generated unique id
  92413. * @param uniqueId efines the unique id to search for
  92414. * @return the found transform node or null if not found at all.
  92415. */
  92416. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92417. /**
  92418. * Gets a list of transform nodes using their id
  92419. * @param id defines the id to search for
  92420. * @returns a list of transform nodes
  92421. */
  92422. getTransformNodesByID(id: string): Array<TransformNode>;
  92423. /**
  92424. * Gets a mesh with its auto-generated unique id
  92425. * @param uniqueId defines the unique id to search for
  92426. * @return the found mesh or null if not found at all.
  92427. */
  92428. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92429. /**
  92430. * Gets a the last added mesh using a given id
  92431. * @param id defines the id to search for
  92432. * @return the found mesh or null if not found at all.
  92433. */
  92434. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92435. /**
  92436. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92437. * @param id defines the id to search for
  92438. * @return the found node or null if not found at all
  92439. */
  92440. getLastEntryByID(id: string): Nullable<Node>;
  92441. /**
  92442. * Gets a node (Mesh, Camera, Light) using a given id
  92443. * @param id defines the id to search for
  92444. * @return the found node or null if not found at all
  92445. */
  92446. getNodeByID(id: string): Nullable<Node>;
  92447. /**
  92448. * Gets a node (Mesh, Camera, Light) using a given name
  92449. * @param name defines the name to search for
  92450. * @return the found node or null if not found at all.
  92451. */
  92452. getNodeByName(name: string): Nullable<Node>;
  92453. /**
  92454. * Gets a mesh using a given name
  92455. * @param name defines the name to search for
  92456. * @return the found mesh or null if not found at all.
  92457. */
  92458. getMeshByName(name: string): Nullable<AbstractMesh>;
  92459. /**
  92460. * Gets a transform node using a given name
  92461. * @param name defines the name to search for
  92462. * @return the found transform node or null if not found at all.
  92463. */
  92464. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92465. /**
  92466. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92467. * @param id defines the id to search for
  92468. * @return the found skeleton or null if not found at all.
  92469. */
  92470. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92471. /**
  92472. * Gets a skeleton using a given auto generated unique id
  92473. * @param uniqueId defines the unique id to search for
  92474. * @return the found skeleton or null if not found at all.
  92475. */
  92476. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92477. /**
  92478. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92479. * @param id defines the id to search for
  92480. * @return the found skeleton or null if not found at all.
  92481. */
  92482. getSkeletonById(id: string): Nullable<Skeleton>;
  92483. /**
  92484. * Gets a skeleton using a given name
  92485. * @param name defines the name to search for
  92486. * @return the found skeleton or null if not found at all.
  92487. */
  92488. getSkeletonByName(name: string): Nullable<Skeleton>;
  92489. /**
  92490. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92491. * @param id defines the id to search for
  92492. * @return the found morph target manager or null if not found at all.
  92493. */
  92494. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92495. /**
  92496. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92497. * @param id defines the id to search for
  92498. * @return the found morph target or null if not found at all.
  92499. */
  92500. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92501. /**
  92502. * Gets a boolean indicating if the given mesh is active
  92503. * @param mesh defines the mesh to look for
  92504. * @returns true if the mesh is in the active list
  92505. */
  92506. isActiveMesh(mesh: AbstractMesh): boolean;
  92507. /**
  92508. * Return a unique id as a string which can serve as an identifier for the scene
  92509. */
  92510. readonly uid: string;
  92511. /**
  92512. * Add an externaly attached data from its key.
  92513. * This method call will fail and return false, if such key already exists.
  92514. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92515. * @param key the unique key that identifies the data
  92516. * @param data the data object to associate to the key for this Engine instance
  92517. * @return true if no such key were already present and the data was added successfully, false otherwise
  92518. */
  92519. addExternalData<T>(key: string, data: T): boolean;
  92520. /**
  92521. * Get an externaly attached data from its key
  92522. * @param key the unique key that identifies the data
  92523. * @return the associated data, if present (can be null), or undefined if not present
  92524. */
  92525. getExternalData<T>(key: string): Nullable<T>;
  92526. /**
  92527. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92528. * @param key the unique key that identifies the data
  92529. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92530. * @return the associated data, can be null if the factory returned null.
  92531. */
  92532. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92533. /**
  92534. * Remove an externaly attached data from the Engine instance
  92535. * @param key the unique key that identifies the data
  92536. * @return true if the data was successfully removed, false if it doesn't exist
  92537. */
  92538. removeExternalData(key: string): boolean;
  92539. private _evaluateSubMesh;
  92540. /**
  92541. * Clear the processed materials smart array preventing retention point in material dispose.
  92542. */
  92543. freeProcessedMaterials(): void;
  92544. private _preventFreeActiveMeshesAndRenderingGroups;
  92545. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92546. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92547. * when disposing several meshes in a row or a hierarchy of meshes.
  92548. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92549. */
  92550. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92551. /**
  92552. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92553. */
  92554. freeActiveMeshes(): void;
  92555. /**
  92556. * Clear the info related to rendering groups preventing retention points during dispose.
  92557. */
  92558. freeRenderingGroups(): void;
  92559. /** @hidden */
  92560. _isInIntermediateRendering(): boolean;
  92561. /**
  92562. * Lambda returning the list of potentially active meshes.
  92563. */
  92564. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92565. /**
  92566. * Lambda returning the list of potentially active sub meshes.
  92567. */
  92568. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92569. /**
  92570. * Lambda returning the list of potentially intersecting sub meshes.
  92571. */
  92572. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92573. /**
  92574. * Lambda returning the list of potentially colliding sub meshes.
  92575. */
  92576. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92577. private _activeMeshesFrozen;
  92578. /**
  92579. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92580. * @returns the current scene
  92581. */
  92582. freezeActiveMeshes(): Scene;
  92583. /**
  92584. * Use this function to restart evaluating active meshes on every frame
  92585. * @returns the current scene
  92586. */
  92587. unfreezeActiveMeshes(): Scene;
  92588. private _evaluateActiveMeshes;
  92589. private _activeMesh;
  92590. /**
  92591. * Update the transform matrix to update from the current active camera
  92592. * @param force defines a boolean used to force the update even if cache is up to date
  92593. */
  92594. updateTransformMatrix(force?: boolean): void;
  92595. private _bindFrameBuffer;
  92596. /** @hidden */
  92597. _allowPostProcessClearColor: boolean;
  92598. /** @hidden */
  92599. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92600. private _processSubCameras;
  92601. private _checkIntersections;
  92602. /** @hidden */
  92603. _advancePhysicsEngineStep(step: number): void;
  92604. /**
  92605. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92606. */
  92607. getDeterministicFrameTime: () => number;
  92608. /** @hidden */
  92609. _animate(): void;
  92610. /**
  92611. * Render the scene
  92612. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92613. */
  92614. render(updateCameras?: boolean): void;
  92615. /**
  92616. * Freeze all materials
  92617. * A frozen material will not be updatable but should be faster to render
  92618. */
  92619. freezeMaterials(): void;
  92620. /**
  92621. * Unfreeze all materials
  92622. * A frozen material will not be updatable but should be faster to render
  92623. */
  92624. unfreezeMaterials(): void;
  92625. /**
  92626. * Releases all held ressources
  92627. */
  92628. dispose(): void;
  92629. /**
  92630. * Gets if the scene is already disposed
  92631. */
  92632. readonly isDisposed: boolean;
  92633. /**
  92634. * Call this function to reduce memory footprint of the scene.
  92635. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92636. */
  92637. clearCachedVertexData(): void;
  92638. /**
  92639. * This function will remove the local cached buffer data from texture.
  92640. * It will save memory but will prevent the texture from being rebuilt
  92641. */
  92642. cleanCachedTextureBuffer(): void;
  92643. /**
  92644. * Get the world extend vectors with an optional filter
  92645. *
  92646. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92647. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92648. */
  92649. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92650. min: Vector3;
  92651. max: Vector3;
  92652. };
  92653. /**
  92654. * Creates a ray that can be used to pick in the scene
  92655. * @param x defines the x coordinate of the origin (on-screen)
  92656. * @param y defines the y coordinate of the origin (on-screen)
  92657. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92658. * @param camera defines the camera to use for the picking
  92659. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92660. * @returns a Ray
  92661. */
  92662. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92663. /**
  92664. * Creates a ray that can be used to pick in the scene
  92665. * @param x defines the x coordinate of the origin (on-screen)
  92666. * @param y defines the y coordinate of the origin (on-screen)
  92667. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92668. * @param result defines the ray where to store the picking ray
  92669. * @param camera defines the camera to use for the picking
  92670. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92671. * @returns the current scene
  92672. */
  92673. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92674. /**
  92675. * Creates a ray that can be used to pick in the scene
  92676. * @param x defines the x coordinate of the origin (on-screen)
  92677. * @param y defines the y coordinate of the origin (on-screen)
  92678. * @param camera defines the camera to use for the picking
  92679. * @returns a Ray
  92680. */
  92681. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92682. /**
  92683. * Creates a ray that can be used to pick in the scene
  92684. * @param x defines the x coordinate of the origin (on-screen)
  92685. * @param y defines the y coordinate of the origin (on-screen)
  92686. * @param result defines the ray where to store the picking ray
  92687. * @param camera defines the camera to use for the picking
  92688. * @returns the current scene
  92689. */
  92690. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92691. /** Launch a ray to try to pick a mesh in the scene
  92692. * @param x position on screen
  92693. * @param y position on screen
  92694. * @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
  92695. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92696. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92697. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92698. * @returns a PickingInfo
  92699. */
  92700. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92701. /** Use the given ray to pick a mesh in the scene
  92702. * @param ray The ray to use to pick meshes
  92703. * @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
  92704. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92705. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92706. * @returns a PickingInfo
  92707. */
  92708. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92709. /**
  92710. * Launch a ray to try to pick a mesh in the scene
  92711. * @param x X position on screen
  92712. * @param y Y position on screen
  92713. * @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
  92714. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92715. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92716. * @returns an array of PickingInfo
  92717. */
  92718. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92719. /**
  92720. * Launch a ray to try to pick a mesh in the scene
  92721. * @param ray Ray to use
  92722. * @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
  92723. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92724. * @returns an array of PickingInfo
  92725. */
  92726. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92727. /**
  92728. * Force the value of meshUnderPointer
  92729. * @param mesh defines the mesh to use
  92730. */
  92731. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92732. /**
  92733. * Gets the mesh under the pointer
  92734. * @returns a Mesh or null if no mesh is under the pointer
  92735. */
  92736. getPointerOverMesh(): Nullable<AbstractMesh>;
  92737. /** @hidden */
  92738. _rebuildGeometries(): void;
  92739. /** @hidden */
  92740. _rebuildTextures(): void;
  92741. private _getByTags;
  92742. /**
  92743. * Get a list of meshes by tags
  92744. * @param tagsQuery defines the tags query to use
  92745. * @param forEach defines a predicate used to filter results
  92746. * @returns an array of Mesh
  92747. */
  92748. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92749. /**
  92750. * Get a list of cameras by tags
  92751. * @param tagsQuery defines the tags query to use
  92752. * @param forEach defines a predicate used to filter results
  92753. * @returns an array of Camera
  92754. */
  92755. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92756. /**
  92757. * Get a list of lights by tags
  92758. * @param tagsQuery defines the tags query to use
  92759. * @param forEach defines a predicate used to filter results
  92760. * @returns an array of Light
  92761. */
  92762. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92763. /**
  92764. * Get a list of materials by tags
  92765. * @param tagsQuery defines the tags query to use
  92766. * @param forEach defines a predicate used to filter results
  92767. * @returns an array of Material
  92768. */
  92769. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92770. /**
  92771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92772. * This allowed control for front to back rendering or reversly depending of the special needs.
  92773. *
  92774. * @param renderingGroupId The rendering group id corresponding to its index
  92775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92778. */
  92779. 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;
  92780. /**
  92781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92782. *
  92783. * @param renderingGroupId The rendering group id corresponding to its index
  92784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92785. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92786. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92787. */
  92788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92789. /**
  92790. * Gets the current auto clear configuration for one rendering group of the rendering
  92791. * manager.
  92792. * @param index the rendering group index to get the information for
  92793. * @returns The auto clear setup for the requested rendering group
  92794. */
  92795. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92796. private _blockMaterialDirtyMechanism;
  92797. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92798. blockMaterialDirtyMechanism: boolean;
  92799. /**
  92800. * Will flag all materials as dirty to trigger new shader compilation
  92801. * @param flag defines the flag used to specify which material part must be marked as dirty
  92802. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92803. */
  92804. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92805. /** @hidden */
  92806. _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;
  92807. /** @hidden */
  92808. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92809. }
  92810. }
  92811. declare module BABYLON {
  92812. /**
  92813. * Set of assets to keep when moving a scene into an asset container.
  92814. */
  92815. export class KeepAssets extends AbstractScene {
  92816. }
  92817. /**
  92818. * Container with a set of assets that can be added or removed from a scene.
  92819. */
  92820. export class AssetContainer extends AbstractScene {
  92821. /**
  92822. * The scene the AssetContainer belongs to.
  92823. */
  92824. scene: Scene;
  92825. /**
  92826. * Instantiates an AssetContainer.
  92827. * @param scene The scene the AssetContainer belongs to.
  92828. */
  92829. constructor(scene: Scene);
  92830. /**
  92831. * Adds all the assets from the container to the scene.
  92832. */
  92833. addAllToScene(): void;
  92834. /**
  92835. * Removes all the assets in the container from the scene
  92836. */
  92837. removeAllFromScene(): void;
  92838. /**
  92839. * Disposes all the assets in the container
  92840. */
  92841. dispose(): void;
  92842. private _moveAssets;
  92843. /**
  92844. * Removes all the assets contained in the scene and adds them to the container.
  92845. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92846. */
  92847. moveAllFromScene(keepAssets?: KeepAssets): void;
  92848. /**
  92849. * 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.
  92850. * @returns the root mesh
  92851. */
  92852. createRootMesh(): Mesh;
  92853. }
  92854. }
  92855. declare module BABYLON {
  92856. /**
  92857. * Defines how the parser contract is defined.
  92858. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92859. */
  92860. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92861. /**
  92862. * Defines how the individual parser contract is defined.
  92863. * These parser can parse an individual asset
  92864. */
  92865. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92866. /**
  92867. * Base class of the scene acting as a container for the different elements composing a scene.
  92868. * This class is dynamically extended by the different components of the scene increasing
  92869. * flexibility and reducing coupling
  92870. */
  92871. export abstract class AbstractScene {
  92872. /**
  92873. * Stores the list of available parsers in the application.
  92874. */
  92875. private static _BabylonFileParsers;
  92876. /**
  92877. * Stores the list of available individual parsers in the application.
  92878. */
  92879. private static _IndividualBabylonFileParsers;
  92880. /**
  92881. * Adds a parser in the list of available ones
  92882. * @param name Defines the name of the parser
  92883. * @param parser Defines the parser to add
  92884. */
  92885. static AddParser(name: string, parser: BabylonFileParser): void;
  92886. /**
  92887. * Gets a general parser from the list of avaialble ones
  92888. * @param name Defines the name of the parser
  92889. * @returns the requested parser or null
  92890. */
  92891. static GetParser(name: string): Nullable<BabylonFileParser>;
  92892. /**
  92893. * Adds n individual parser in the list of available ones
  92894. * @param name Defines the name of the parser
  92895. * @param parser Defines the parser to add
  92896. */
  92897. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92898. /**
  92899. * Gets an individual parser from the list of avaialble ones
  92900. * @param name Defines the name of the parser
  92901. * @returns the requested parser or null
  92902. */
  92903. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92904. /**
  92905. * Parser json data and populate both a scene and its associated container object
  92906. * @param jsonData Defines the data to parse
  92907. * @param scene Defines the scene to parse the data for
  92908. * @param container Defines the container attached to the parsing sequence
  92909. * @param rootUrl Defines the root url of the data
  92910. */
  92911. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92912. /**
  92913. * Gets the list of root nodes (ie. nodes with no parent)
  92914. */
  92915. rootNodes: Node[];
  92916. /** All of the cameras added to this scene
  92917. * @see http://doc.babylonjs.com/babylon101/cameras
  92918. */
  92919. cameras: Camera[];
  92920. /**
  92921. * All of the lights added to this scene
  92922. * @see http://doc.babylonjs.com/babylon101/lights
  92923. */
  92924. lights: Light[];
  92925. /**
  92926. * All of the (abstract) meshes added to this scene
  92927. */
  92928. meshes: AbstractMesh[];
  92929. /**
  92930. * The list of skeletons added to the scene
  92931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92932. */
  92933. skeletons: Skeleton[];
  92934. /**
  92935. * All of the particle systems added to this scene
  92936. * @see http://doc.babylonjs.com/babylon101/particles
  92937. */
  92938. particleSystems: IParticleSystem[];
  92939. /**
  92940. * Gets a list of Animations associated with the scene
  92941. */
  92942. animations: Animation[];
  92943. /**
  92944. * All of the animation groups added to this scene
  92945. * @see http://doc.babylonjs.com/how_to/group
  92946. */
  92947. animationGroups: AnimationGroup[];
  92948. /**
  92949. * All of the multi-materials added to this scene
  92950. * @see http://doc.babylonjs.com/how_to/multi_materials
  92951. */
  92952. multiMaterials: MultiMaterial[];
  92953. /**
  92954. * All of the materials added to this scene
  92955. * In the context of a Scene, it is not supposed to be modified manually.
  92956. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92957. * Note also that the order of the Material wihin the array is not significant and might change.
  92958. * @see http://doc.babylonjs.com/babylon101/materials
  92959. */
  92960. materials: Material[];
  92961. /**
  92962. * The list of morph target managers added to the scene
  92963. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92964. */
  92965. morphTargetManagers: MorphTargetManager[];
  92966. /**
  92967. * The list of geometries used in the scene.
  92968. */
  92969. geometries: Geometry[];
  92970. /**
  92971. * All of the tranform nodes added to this scene
  92972. * In the context of a Scene, it is not supposed to be modified manually.
  92973. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92974. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92975. * @see http://doc.babylonjs.com/how_to/transformnode
  92976. */
  92977. transformNodes: TransformNode[];
  92978. /**
  92979. * ActionManagers available on the scene.
  92980. */
  92981. actionManagers: AbstractActionManager[];
  92982. /**
  92983. * Textures to keep.
  92984. */
  92985. textures: BaseTexture[];
  92986. /**
  92987. * Environment texture for the scene
  92988. */
  92989. environmentTexture: Nullable<BaseTexture>;
  92990. }
  92991. }
  92992. declare module BABYLON {
  92993. /**
  92994. * Defines a sound that can be played in the application.
  92995. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92997. */
  92998. export class Sound {
  92999. /**
  93000. * The name of the sound in the scene.
  93001. */
  93002. name: string;
  93003. /**
  93004. * Does the sound autoplay once loaded.
  93005. */
  93006. autoplay: boolean;
  93007. /**
  93008. * Does the sound loop after it finishes playing once.
  93009. */
  93010. loop: boolean;
  93011. /**
  93012. * Does the sound use a custom attenuation curve to simulate the falloff
  93013. * happening when the source gets further away from the camera.
  93014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93015. */
  93016. useCustomAttenuation: boolean;
  93017. /**
  93018. * The sound track id this sound belongs to.
  93019. */
  93020. soundTrackId: number;
  93021. /**
  93022. * Is this sound currently played.
  93023. */
  93024. isPlaying: boolean;
  93025. /**
  93026. * Is this sound currently paused.
  93027. */
  93028. isPaused: boolean;
  93029. /**
  93030. * Does this sound enables spatial sound.
  93031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93032. */
  93033. spatialSound: boolean;
  93034. /**
  93035. * Define the reference distance the sound should be heard perfectly.
  93036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93037. */
  93038. refDistance: number;
  93039. /**
  93040. * Define the roll off factor of spatial sounds.
  93041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93042. */
  93043. rolloffFactor: number;
  93044. /**
  93045. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93047. */
  93048. maxDistance: number;
  93049. /**
  93050. * Define the distance attenuation model the sound will follow.
  93051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93052. */
  93053. distanceModel: string;
  93054. /**
  93055. * @hidden
  93056. * Back Compat
  93057. **/
  93058. onended: () => any;
  93059. /**
  93060. * Observable event when the current playing sound finishes.
  93061. */
  93062. onEndedObservable: Observable<Sound>;
  93063. private _panningModel;
  93064. private _playbackRate;
  93065. private _streaming;
  93066. private _startTime;
  93067. private _startOffset;
  93068. private _position;
  93069. /** @hidden */
  93070. _positionInEmitterSpace: boolean;
  93071. private _localDirection;
  93072. private _volume;
  93073. private _isReadyToPlay;
  93074. private _isDirectional;
  93075. private _readyToPlayCallback;
  93076. private _audioBuffer;
  93077. private _soundSource;
  93078. private _streamingSource;
  93079. private _soundPanner;
  93080. private _soundGain;
  93081. private _inputAudioNode;
  93082. private _outputAudioNode;
  93083. private _coneInnerAngle;
  93084. private _coneOuterAngle;
  93085. private _coneOuterGain;
  93086. private _scene;
  93087. private _connectedTransformNode;
  93088. private _customAttenuationFunction;
  93089. private _registerFunc;
  93090. private _isOutputConnected;
  93091. private _htmlAudioElement;
  93092. private _urlType;
  93093. /** @hidden */
  93094. static _SceneComponentInitialization: (scene: Scene) => void;
  93095. /**
  93096. * Create a sound and attach it to a scene
  93097. * @param name Name of your sound
  93098. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93099. * @param scene defines the scene the sound belongs to
  93100. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93101. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93102. */
  93103. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93104. /**
  93105. * Release the sound and its associated resources
  93106. */
  93107. dispose(): void;
  93108. /**
  93109. * Gets if the sounds is ready to be played or not.
  93110. * @returns true if ready, otherwise false
  93111. */
  93112. isReady(): boolean;
  93113. private _soundLoaded;
  93114. /**
  93115. * Sets the data of the sound from an audiobuffer
  93116. * @param audioBuffer The audioBuffer containing the data
  93117. */
  93118. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93119. /**
  93120. * Updates the current sounds options such as maxdistance, loop...
  93121. * @param options A JSON object containing values named as the object properties
  93122. */
  93123. updateOptions(options: any): void;
  93124. private _createSpatialParameters;
  93125. private _updateSpatialParameters;
  93126. /**
  93127. * Switch the panning model to HRTF:
  93128. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93130. */
  93131. switchPanningModelToHRTF(): void;
  93132. /**
  93133. * Switch the panning model to Equal Power:
  93134. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93136. */
  93137. switchPanningModelToEqualPower(): void;
  93138. private _switchPanningModel;
  93139. /**
  93140. * Connect this sound to a sound track audio node like gain...
  93141. * @param soundTrackAudioNode the sound track audio node to connect to
  93142. */
  93143. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93144. /**
  93145. * Transform this sound into a directional source
  93146. * @param coneInnerAngle Size of the inner cone in degree
  93147. * @param coneOuterAngle Size of the outer cone in degree
  93148. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93149. */
  93150. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93151. /**
  93152. * Gets or sets the inner angle for the directional cone.
  93153. */
  93154. /**
  93155. * Gets or sets the inner angle for the directional cone.
  93156. */
  93157. directionalConeInnerAngle: number;
  93158. /**
  93159. * Gets or sets the outer angle for the directional cone.
  93160. */
  93161. /**
  93162. * Gets or sets the outer angle for the directional cone.
  93163. */
  93164. directionalConeOuterAngle: number;
  93165. /**
  93166. * Sets the position of the emitter if spatial sound is enabled
  93167. * @param newPosition Defines the new posisiton
  93168. */
  93169. setPosition(newPosition: Vector3): void;
  93170. /**
  93171. * Sets the local direction of the emitter if spatial sound is enabled
  93172. * @param newLocalDirection Defines the new local direction
  93173. */
  93174. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93175. private _updateDirection;
  93176. /** @hidden */
  93177. updateDistanceFromListener(): void;
  93178. /**
  93179. * Sets a new custom attenuation function for the sound.
  93180. * @param callback Defines the function used for the attenuation
  93181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93182. */
  93183. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93184. /**
  93185. * Play the sound
  93186. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93187. * @param offset (optional) Start the sound setting it at a specific time
  93188. */
  93189. play(time?: number, offset?: number): void;
  93190. private _onended;
  93191. /**
  93192. * Stop the sound
  93193. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93194. */
  93195. stop(time?: number): void;
  93196. /**
  93197. * Put the sound in pause
  93198. */
  93199. pause(): void;
  93200. /**
  93201. * Sets a dedicated volume for this sounds
  93202. * @param newVolume Define the new volume of the sound
  93203. * @param time Define in how long the sound should be at this value
  93204. */
  93205. setVolume(newVolume: number, time?: number): void;
  93206. /**
  93207. * Set the sound play back rate
  93208. * @param newPlaybackRate Define the playback rate the sound should be played at
  93209. */
  93210. setPlaybackRate(newPlaybackRate: number): void;
  93211. /**
  93212. * Gets the volume of the sound.
  93213. * @returns the volume of the sound
  93214. */
  93215. getVolume(): number;
  93216. /**
  93217. * Attach the sound to a dedicated mesh
  93218. * @param transformNode The transform node to connect the sound with
  93219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93220. */
  93221. attachToMesh(transformNode: TransformNode): void;
  93222. /**
  93223. * Detach the sound from the previously attached mesh
  93224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93225. */
  93226. detachFromMesh(): void;
  93227. private _onRegisterAfterWorldMatrixUpdate;
  93228. /**
  93229. * Clone the current sound in the scene.
  93230. * @returns the new sound clone
  93231. */
  93232. clone(): Nullable<Sound>;
  93233. /**
  93234. * Gets the current underlying audio buffer containing the data
  93235. * @returns the audio buffer
  93236. */
  93237. getAudioBuffer(): Nullable<AudioBuffer>;
  93238. /**
  93239. * Serializes the Sound in a JSON representation
  93240. * @returns the JSON representation of the sound
  93241. */
  93242. serialize(): any;
  93243. /**
  93244. * Parse a JSON representation of a sound to innstantiate in a given scene
  93245. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93246. * @param scene Define the scene the new parsed sound should be created in
  93247. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93248. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93249. * @returns the newly parsed sound
  93250. */
  93251. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93252. }
  93253. }
  93254. declare module BABYLON {
  93255. /**
  93256. * This defines an action helpful to play a defined sound on a triggered action.
  93257. */
  93258. export class PlaySoundAction extends Action {
  93259. private _sound;
  93260. /**
  93261. * Instantiate the action
  93262. * @param triggerOptions defines the trigger options
  93263. * @param sound defines the sound to play
  93264. * @param condition defines the trigger related conditions
  93265. */
  93266. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93267. /** @hidden */
  93268. _prepare(): void;
  93269. /**
  93270. * Execute the action and play the sound.
  93271. */
  93272. execute(): void;
  93273. /**
  93274. * Serializes the actions and its related information.
  93275. * @param parent defines the object to serialize in
  93276. * @returns the serialized object
  93277. */
  93278. serialize(parent: any): any;
  93279. }
  93280. /**
  93281. * This defines an action helpful to stop a defined sound on a triggered action.
  93282. */
  93283. export class StopSoundAction extends Action {
  93284. private _sound;
  93285. /**
  93286. * Instantiate the action
  93287. * @param triggerOptions defines the trigger options
  93288. * @param sound defines the sound to stop
  93289. * @param condition defines the trigger related conditions
  93290. */
  93291. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93292. /** @hidden */
  93293. _prepare(): void;
  93294. /**
  93295. * Execute the action and stop the sound.
  93296. */
  93297. execute(): void;
  93298. /**
  93299. * Serializes the actions and its related information.
  93300. * @param parent defines the object to serialize in
  93301. * @returns the serialized object
  93302. */
  93303. serialize(parent: any): any;
  93304. }
  93305. }
  93306. declare module BABYLON {
  93307. /**
  93308. * This defines an action responsible to change the value of a property
  93309. * by interpolating between its current value and the newly set one once triggered.
  93310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93311. */
  93312. export class InterpolateValueAction extends Action {
  93313. /**
  93314. * Defines the path of the property where the value should be interpolated
  93315. */
  93316. propertyPath: string;
  93317. /**
  93318. * Defines the target value at the end of the interpolation.
  93319. */
  93320. value: any;
  93321. /**
  93322. * Defines the time it will take for the property to interpolate to the value.
  93323. */
  93324. duration: number;
  93325. /**
  93326. * Defines if the other scene animations should be stopped when the action has been triggered
  93327. */
  93328. stopOtherAnimations?: boolean;
  93329. /**
  93330. * Defines a callback raised once the interpolation animation has been done.
  93331. */
  93332. onInterpolationDone?: () => void;
  93333. /**
  93334. * Observable triggered once the interpolation animation has been done.
  93335. */
  93336. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93337. private _target;
  93338. private _effectiveTarget;
  93339. private _property;
  93340. /**
  93341. * Instantiate the action
  93342. * @param triggerOptions defines the trigger options
  93343. * @param target defines the object containing the value to interpolate
  93344. * @param propertyPath defines the path to the property in the target object
  93345. * @param value defines the target value at the end of the interpolation
  93346. * @param duration deines the time it will take for the property to interpolate to the value.
  93347. * @param condition defines the trigger related conditions
  93348. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93349. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93350. */
  93351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93352. /** @hidden */
  93353. _prepare(): void;
  93354. /**
  93355. * Execute the action starts the value interpolation.
  93356. */
  93357. execute(): void;
  93358. /**
  93359. * Serializes the actions and its related information.
  93360. * @param parent defines the object to serialize in
  93361. * @returns the serialized object
  93362. */
  93363. serialize(parent: any): any;
  93364. }
  93365. }
  93366. declare module BABYLON {
  93367. /**
  93368. * Options allowed during the creation of a sound track.
  93369. */
  93370. export interface ISoundTrackOptions {
  93371. /**
  93372. * The volume the sound track should take during creation
  93373. */
  93374. volume?: number;
  93375. /**
  93376. * Define if the sound track is the main sound track of the scene
  93377. */
  93378. mainTrack?: boolean;
  93379. }
  93380. /**
  93381. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93382. * It will be also used in a future release to apply effects on a specific track.
  93383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93384. */
  93385. export class SoundTrack {
  93386. /**
  93387. * The unique identifier of the sound track in the scene.
  93388. */
  93389. id: number;
  93390. /**
  93391. * The list of sounds included in the sound track.
  93392. */
  93393. soundCollection: Array<Sound>;
  93394. private _outputAudioNode;
  93395. private _scene;
  93396. private _isMainTrack;
  93397. private _connectedAnalyser;
  93398. private _options;
  93399. private _isInitialized;
  93400. /**
  93401. * Creates a new sound track.
  93402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93403. * @param scene Define the scene the sound track belongs to
  93404. * @param options
  93405. */
  93406. constructor(scene: Scene, options?: ISoundTrackOptions);
  93407. private _initializeSoundTrackAudioGraph;
  93408. /**
  93409. * Release the sound track and its associated resources
  93410. */
  93411. dispose(): void;
  93412. /**
  93413. * Adds a sound to this sound track
  93414. * @param sound define the cound to add
  93415. * @ignoreNaming
  93416. */
  93417. AddSound(sound: Sound): void;
  93418. /**
  93419. * Removes a sound to this sound track
  93420. * @param sound define the cound to remove
  93421. * @ignoreNaming
  93422. */
  93423. RemoveSound(sound: Sound): void;
  93424. /**
  93425. * Set a global volume for the full sound track.
  93426. * @param newVolume Define the new volume of the sound track
  93427. */
  93428. setVolume(newVolume: number): void;
  93429. /**
  93430. * Switch the panning model to HRTF:
  93431. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93433. */
  93434. switchPanningModelToHRTF(): void;
  93435. /**
  93436. * Switch the panning model to Equal Power:
  93437. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93439. */
  93440. switchPanningModelToEqualPower(): void;
  93441. /**
  93442. * Connect the sound track to an audio analyser allowing some amazing
  93443. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93445. * @param analyser The analyser to connect to the engine
  93446. */
  93447. connectToAnalyser(analyser: Analyser): void;
  93448. }
  93449. }
  93450. declare module BABYLON {
  93451. interface AbstractScene {
  93452. /**
  93453. * The list of sounds used in the scene.
  93454. */
  93455. sounds: Nullable<Array<Sound>>;
  93456. }
  93457. interface Scene {
  93458. /**
  93459. * @hidden
  93460. * Backing field
  93461. */
  93462. _mainSoundTrack: SoundTrack;
  93463. /**
  93464. * The main sound track played by the scene.
  93465. * It cotains your primary collection of sounds.
  93466. */
  93467. mainSoundTrack: SoundTrack;
  93468. /**
  93469. * The list of sound tracks added to the scene
  93470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93471. */
  93472. soundTracks: Nullable<Array<SoundTrack>>;
  93473. /**
  93474. * Gets a sound using a given name
  93475. * @param name defines the name to search for
  93476. * @return the found sound or null if not found at all.
  93477. */
  93478. getSoundByName(name: string): Nullable<Sound>;
  93479. /**
  93480. * Gets or sets if audio support is enabled
  93481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93482. */
  93483. audioEnabled: boolean;
  93484. /**
  93485. * Gets or sets if audio will be output to headphones
  93486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93487. */
  93488. headphone: boolean;
  93489. }
  93490. /**
  93491. * Defines the sound scene component responsible to manage any sounds
  93492. * in a given scene.
  93493. */
  93494. export class AudioSceneComponent implements ISceneSerializableComponent {
  93495. /**
  93496. * The component name helpfull to identify the component in the list of scene components.
  93497. */
  93498. readonly name: string;
  93499. /**
  93500. * The scene the component belongs to.
  93501. */
  93502. scene: Scene;
  93503. private _audioEnabled;
  93504. /**
  93505. * Gets whether audio is enabled or not.
  93506. * Please use related enable/disable method to switch state.
  93507. */
  93508. readonly audioEnabled: boolean;
  93509. private _headphone;
  93510. /**
  93511. * Gets whether audio is outputing to headphone or not.
  93512. * Please use the according Switch methods to change output.
  93513. */
  93514. readonly headphone: boolean;
  93515. /**
  93516. * Creates a new instance of the component for the given scene
  93517. * @param scene Defines the scene to register the component in
  93518. */
  93519. constructor(scene: Scene);
  93520. /**
  93521. * Registers the component in a given scene
  93522. */
  93523. register(): void;
  93524. /**
  93525. * Rebuilds the elements related to this component in case of
  93526. * context lost for instance.
  93527. */
  93528. rebuild(): void;
  93529. /**
  93530. * Serializes the component data to the specified json object
  93531. * @param serializationObject The object to serialize to
  93532. */
  93533. serialize(serializationObject: any): void;
  93534. /**
  93535. * Adds all the element from the container to the scene
  93536. * @param container the container holding the elements
  93537. */
  93538. addFromContainer(container: AbstractScene): void;
  93539. /**
  93540. * Removes all the elements in the container from the scene
  93541. * @param container contains the elements to remove
  93542. * @param dispose if the removed element should be disposed (default: false)
  93543. */
  93544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93545. /**
  93546. * Disposes the component and the associated ressources.
  93547. */
  93548. dispose(): void;
  93549. /**
  93550. * Disables audio in the associated scene.
  93551. */
  93552. disableAudio(): void;
  93553. /**
  93554. * Enables audio in the associated scene.
  93555. */
  93556. enableAudio(): void;
  93557. /**
  93558. * Switch audio to headphone output.
  93559. */
  93560. switchAudioModeForHeadphones(): void;
  93561. /**
  93562. * Switch audio to normal speakers.
  93563. */
  93564. switchAudioModeForNormalSpeakers(): void;
  93565. private _afterRender;
  93566. }
  93567. }
  93568. declare module BABYLON {
  93569. /**
  93570. * Wraps one or more Sound objects and selects one with random weight for playback.
  93571. */
  93572. export class WeightedSound {
  93573. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93574. loop: boolean;
  93575. private _coneInnerAngle;
  93576. private _coneOuterAngle;
  93577. private _volume;
  93578. /** A Sound is currently playing. */
  93579. isPlaying: boolean;
  93580. /** A Sound is currently paused. */
  93581. isPaused: boolean;
  93582. private _sounds;
  93583. private _weights;
  93584. private _currentIndex?;
  93585. /**
  93586. * Creates a new WeightedSound from the list of sounds given.
  93587. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93588. * @param sounds Array of Sounds that will be selected from.
  93589. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93590. */
  93591. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93592. /**
  93593. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93594. */
  93595. /**
  93596. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93597. */
  93598. directionalConeInnerAngle: number;
  93599. /**
  93600. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93601. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93602. */
  93603. /**
  93604. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93605. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93606. */
  93607. directionalConeOuterAngle: number;
  93608. /**
  93609. * Playback volume.
  93610. */
  93611. /**
  93612. * Playback volume.
  93613. */
  93614. volume: number;
  93615. private _onended;
  93616. /**
  93617. * Suspend playback
  93618. */
  93619. pause(): void;
  93620. /**
  93621. * Stop playback
  93622. */
  93623. stop(): void;
  93624. /**
  93625. * Start playback.
  93626. * @param startOffset Position the clip head at a specific time in seconds.
  93627. */
  93628. play(startOffset?: number): void;
  93629. }
  93630. }
  93631. declare module BABYLON {
  93632. /**
  93633. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93635. */
  93636. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93637. /**
  93638. * Gets the name of the behavior.
  93639. */
  93640. readonly name: string;
  93641. /**
  93642. * The easing function used by animations
  93643. */
  93644. static EasingFunction: BackEase;
  93645. /**
  93646. * The easing mode used by animations
  93647. */
  93648. static EasingMode: number;
  93649. /**
  93650. * The duration of the animation, in milliseconds
  93651. */
  93652. transitionDuration: number;
  93653. /**
  93654. * Length of the distance animated by the transition when lower radius is reached
  93655. */
  93656. lowerRadiusTransitionRange: number;
  93657. /**
  93658. * Length of the distance animated by the transition when upper radius is reached
  93659. */
  93660. upperRadiusTransitionRange: number;
  93661. private _autoTransitionRange;
  93662. /**
  93663. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93664. */
  93665. /**
  93666. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93667. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93668. */
  93669. autoTransitionRange: boolean;
  93670. private _attachedCamera;
  93671. private _onAfterCheckInputsObserver;
  93672. private _onMeshTargetChangedObserver;
  93673. /**
  93674. * Initializes the behavior.
  93675. */
  93676. init(): void;
  93677. /**
  93678. * Attaches the behavior to its arc rotate camera.
  93679. * @param camera Defines the camera to attach the behavior to
  93680. */
  93681. attach(camera: ArcRotateCamera): void;
  93682. /**
  93683. * Detaches the behavior from its current arc rotate camera.
  93684. */
  93685. detach(): void;
  93686. private _radiusIsAnimating;
  93687. private _radiusBounceTransition;
  93688. private _animatables;
  93689. private _cachedWheelPrecision;
  93690. /**
  93691. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93692. * @param radiusLimit The limit to check against.
  93693. * @return Bool to indicate if at limit.
  93694. */
  93695. private _isRadiusAtLimit;
  93696. /**
  93697. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93698. * @param radiusDelta The delta by which to animate to. Can be negative.
  93699. */
  93700. private _applyBoundRadiusAnimation;
  93701. /**
  93702. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93703. */
  93704. protected _clearAnimationLocks(): void;
  93705. /**
  93706. * Stops and removes all animations that have been applied to the camera
  93707. */
  93708. stopAllAnimations(): void;
  93709. }
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * 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.
  93714. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93715. */
  93716. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93717. /**
  93718. * Gets the name of the behavior.
  93719. */
  93720. readonly name: string;
  93721. private _mode;
  93722. private _radiusScale;
  93723. private _positionScale;
  93724. private _defaultElevation;
  93725. private _elevationReturnTime;
  93726. private _elevationReturnWaitTime;
  93727. private _zoomStopsAnimation;
  93728. private _framingTime;
  93729. /**
  93730. * The easing function used by animations
  93731. */
  93732. static EasingFunction: ExponentialEase;
  93733. /**
  93734. * The easing mode used by animations
  93735. */
  93736. static EasingMode: number;
  93737. /**
  93738. * Sets the current mode used by the behavior
  93739. */
  93740. /**
  93741. * Gets current mode used by the behavior.
  93742. */
  93743. mode: number;
  93744. /**
  93745. * Sets the scale applied to the radius (1 by default)
  93746. */
  93747. /**
  93748. * Gets the scale applied to the radius
  93749. */
  93750. radiusScale: number;
  93751. /**
  93752. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93753. */
  93754. /**
  93755. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93756. */
  93757. positionScale: number;
  93758. /**
  93759. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93760. * behaviour is triggered, in radians.
  93761. */
  93762. /**
  93763. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93764. * behaviour is triggered, in radians.
  93765. */
  93766. defaultElevation: number;
  93767. /**
  93768. * Sets the time (in milliseconds) taken to return to the default beta position.
  93769. * Negative value indicates camera should not return to default.
  93770. */
  93771. /**
  93772. * Gets the time (in milliseconds) taken to return to the default beta position.
  93773. * Negative value indicates camera should not return to default.
  93774. */
  93775. elevationReturnTime: number;
  93776. /**
  93777. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93778. */
  93779. /**
  93780. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93781. */
  93782. elevationReturnWaitTime: number;
  93783. /**
  93784. * Sets the flag that indicates if user zooming should stop animation.
  93785. */
  93786. /**
  93787. * Gets the flag that indicates if user zooming should stop animation.
  93788. */
  93789. zoomStopsAnimation: boolean;
  93790. /**
  93791. * Sets the transition time when framing the mesh, in milliseconds
  93792. */
  93793. /**
  93794. * Gets the transition time when framing the mesh, in milliseconds
  93795. */
  93796. framingTime: number;
  93797. /**
  93798. * Define if the behavior should automatically change the configured
  93799. * camera limits and sensibilities.
  93800. */
  93801. autoCorrectCameraLimitsAndSensibility: boolean;
  93802. private _onPrePointerObservableObserver;
  93803. private _onAfterCheckInputsObserver;
  93804. private _onMeshTargetChangedObserver;
  93805. private _attachedCamera;
  93806. private _isPointerDown;
  93807. private _lastInteractionTime;
  93808. /**
  93809. * Initializes the behavior.
  93810. */
  93811. init(): void;
  93812. /**
  93813. * Attaches the behavior to its arc rotate camera.
  93814. * @param camera Defines the camera to attach the behavior to
  93815. */
  93816. attach(camera: ArcRotateCamera): void;
  93817. /**
  93818. * Detaches the behavior from its current arc rotate camera.
  93819. */
  93820. detach(): void;
  93821. private _animatables;
  93822. private _betaIsAnimating;
  93823. private _betaTransition;
  93824. private _radiusTransition;
  93825. private _vectorTransition;
  93826. /**
  93827. * Targets the given mesh and updates zoom level accordingly.
  93828. * @param mesh The mesh to target.
  93829. * @param radius Optional. If a cached radius position already exists, overrides default.
  93830. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93831. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93832. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93833. */
  93834. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93835. /**
  93836. * Targets the given mesh with its children and updates zoom level accordingly.
  93837. * @param mesh The mesh to target.
  93838. * @param radius Optional. If a cached radius position already exists, overrides default.
  93839. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93840. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93841. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93842. */
  93843. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93844. /**
  93845. * Targets the given meshes with their children and updates zoom level accordingly.
  93846. * @param meshes The mesh to target.
  93847. * @param radius Optional. If a cached radius position already exists, overrides default.
  93848. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93851. */
  93852. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93853. /**
  93854. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93855. * @param minimumWorld Determines the smaller position of the bounding box extend
  93856. * @param maximumWorld Determines the bigger position of the bounding box extend
  93857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93859. */
  93860. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93861. /**
  93862. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93863. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93864. * frustum width.
  93865. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93866. * to fully enclose the mesh in the viewing frustum.
  93867. */
  93868. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93869. /**
  93870. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93871. * is automatically returned to its default position (expected to be above ground plane).
  93872. */
  93873. private _maintainCameraAboveGround;
  93874. /**
  93875. * Returns the frustum slope based on the canvas ratio and camera FOV
  93876. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93877. */
  93878. private _getFrustumSlope;
  93879. /**
  93880. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93881. */
  93882. private _clearAnimationLocks;
  93883. /**
  93884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93885. */
  93886. private _applyUserInteraction;
  93887. /**
  93888. * Stops and removes all animations that have been applied to the camera
  93889. */
  93890. stopAllAnimations(): void;
  93891. /**
  93892. * Gets a value indicating if the user is moving the camera
  93893. */
  93894. readonly isUserIsMoving: boolean;
  93895. /**
  93896. * The camera can move all the way towards the mesh.
  93897. */
  93898. static IgnoreBoundsSizeMode: number;
  93899. /**
  93900. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93901. */
  93902. static FitFrustumSidesMode: number;
  93903. }
  93904. }
  93905. declare module BABYLON {
  93906. /**
  93907. * Base class for Camera Pointer Inputs.
  93908. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93909. * for example usage.
  93910. */
  93911. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93912. /**
  93913. * Defines the camera the input is attached to.
  93914. */
  93915. abstract camera: Camera;
  93916. /**
  93917. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93918. */
  93919. protected _altKey: boolean;
  93920. protected _ctrlKey: boolean;
  93921. protected _metaKey: boolean;
  93922. protected _shiftKey: boolean;
  93923. /**
  93924. * Which mouse buttons were pressed at time of last mouse event.
  93925. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93926. */
  93927. protected _buttonsPressed: number;
  93928. /**
  93929. * Defines the buttons associated with the input to handle camera move.
  93930. */
  93931. buttons: number[];
  93932. /**
  93933. * Attach the input controls to a specific dom element to get the input from.
  93934. * @param element Defines the element the controls should be listened from
  93935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93936. */
  93937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93938. /**
  93939. * Detach the current controls from the specified dom element.
  93940. * @param element Defines the element to stop listening the inputs from
  93941. */
  93942. detachControl(element: Nullable<HTMLElement>): void;
  93943. /**
  93944. * Gets the class name of the current input.
  93945. * @returns the class name
  93946. */
  93947. getClassName(): string;
  93948. /**
  93949. * Get the friendly name associated with the input class.
  93950. * @returns the input friendly name
  93951. */
  93952. getSimpleName(): string;
  93953. /**
  93954. * Called on pointer POINTERDOUBLETAP event.
  93955. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93956. */
  93957. protected onDoubleTap(type: string): void;
  93958. /**
  93959. * Called on pointer POINTERMOVE event if only a single touch is active.
  93960. * Override this method to provide functionality.
  93961. */
  93962. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93963. /**
  93964. * Called on pointer POINTERMOVE event if multiple touches are active.
  93965. * Override this method to provide functionality.
  93966. */
  93967. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93968. /**
  93969. * Called on JS contextmenu event.
  93970. * Override this method to provide functionality.
  93971. */
  93972. protected onContextMenu(evt: PointerEvent): void;
  93973. /**
  93974. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93975. * press.
  93976. * Override this method to provide functionality.
  93977. */
  93978. protected onButtonDown(evt: PointerEvent): void;
  93979. /**
  93980. * Called each time a new POINTERUP event occurs. Ie, for each button
  93981. * release.
  93982. * Override this method to provide functionality.
  93983. */
  93984. protected onButtonUp(evt: PointerEvent): void;
  93985. /**
  93986. * Called when window becomes inactive.
  93987. * Override this method to provide functionality.
  93988. */
  93989. protected onLostFocus(): void;
  93990. private _pointerInput;
  93991. private _observer;
  93992. private _onLostFocus;
  93993. private pointA;
  93994. private pointB;
  93995. }
  93996. }
  93997. declare module BABYLON {
  93998. /**
  93999. * Manage the pointers inputs to control an arc rotate camera.
  94000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94001. */
  94002. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94003. /**
  94004. * Defines the camera the input is attached to.
  94005. */
  94006. camera: ArcRotateCamera;
  94007. /**
  94008. * Gets the class name of the current input.
  94009. * @returns the class name
  94010. */
  94011. getClassName(): string;
  94012. /**
  94013. * Defines the buttons associated with the input to handle camera move.
  94014. */
  94015. buttons: number[];
  94016. /**
  94017. * Defines the pointer angular sensibility along the X axis or how fast is
  94018. * the camera rotating.
  94019. */
  94020. angularSensibilityX: number;
  94021. /**
  94022. * Defines the pointer angular sensibility along the Y axis or how fast is
  94023. * the camera rotating.
  94024. */
  94025. angularSensibilityY: number;
  94026. /**
  94027. * Defines the pointer pinch precision or how fast is the camera zooming.
  94028. */
  94029. pinchPrecision: number;
  94030. /**
  94031. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94032. * from 0.
  94033. * It defines the percentage of current camera.radius to use as delta when
  94034. * pinch zoom is used.
  94035. */
  94036. pinchDeltaPercentage: number;
  94037. /**
  94038. * Defines the pointer panning sensibility or how fast is the camera moving.
  94039. */
  94040. panningSensibility: number;
  94041. /**
  94042. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94043. */
  94044. multiTouchPanning: boolean;
  94045. /**
  94046. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94047. * zoom (pinch) through multitouch.
  94048. */
  94049. multiTouchPanAndZoom: boolean;
  94050. /**
  94051. * Revers pinch action direction.
  94052. */
  94053. pinchInwards: boolean;
  94054. private _isPanClick;
  94055. private _twoFingerActivityCount;
  94056. private _isPinching;
  94057. /**
  94058. * Called on pointer POINTERMOVE event if only a single touch is active.
  94059. */
  94060. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94061. /**
  94062. * Called on pointer POINTERDOUBLETAP event.
  94063. */
  94064. protected onDoubleTap(type: string): void;
  94065. /**
  94066. * Called on pointer POINTERMOVE event if multiple touches are active.
  94067. */
  94068. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94069. /**
  94070. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94071. * press.
  94072. */
  94073. protected onButtonDown(evt: PointerEvent): void;
  94074. /**
  94075. * Called each time a new POINTERUP event occurs. Ie, for each button
  94076. * release.
  94077. */
  94078. protected onButtonUp(evt: PointerEvent): void;
  94079. /**
  94080. * Called when window becomes inactive.
  94081. */
  94082. protected onLostFocus(): void;
  94083. }
  94084. }
  94085. declare module BABYLON {
  94086. /**
  94087. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94089. */
  94090. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94091. /**
  94092. * Defines the camera the input is attached to.
  94093. */
  94094. camera: ArcRotateCamera;
  94095. /**
  94096. * Defines the list of key codes associated with the up action (increase alpha)
  94097. */
  94098. keysUp: number[];
  94099. /**
  94100. * Defines the list of key codes associated with the down action (decrease alpha)
  94101. */
  94102. keysDown: number[];
  94103. /**
  94104. * Defines the list of key codes associated with the left action (increase beta)
  94105. */
  94106. keysLeft: number[];
  94107. /**
  94108. * Defines the list of key codes associated with the right action (decrease beta)
  94109. */
  94110. keysRight: number[];
  94111. /**
  94112. * Defines the list of key codes associated with the reset action.
  94113. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94114. */
  94115. keysReset: number[];
  94116. /**
  94117. * Defines the panning sensibility of the inputs.
  94118. * (How fast is the camera paning)
  94119. */
  94120. panningSensibility: number;
  94121. /**
  94122. * Defines the zooming sensibility of the inputs.
  94123. * (How fast is the camera zooming)
  94124. */
  94125. zoomingSensibility: number;
  94126. /**
  94127. * Defines wether maintaining the alt key down switch the movement mode from
  94128. * orientation to zoom.
  94129. */
  94130. useAltToZoom: boolean;
  94131. /**
  94132. * Rotation speed of the camera
  94133. */
  94134. angularSpeed: number;
  94135. private _keys;
  94136. private _ctrlPressed;
  94137. private _altPressed;
  94138. private _onCanvasBlurObserver;
  94139. private _onKeyboardObserver;
  94140. private _engine;
  94141. private _scene;
  94142. /**
  94143. * Attach the input controls to a specific dom element to get the input from.
  94144. * @param element Defines the element the controls should be listened from
  94145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94146. */
  94147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94148. /**
  94149. * Detach the current controls from the specified dom element.
  94150. * @param element Defines the element to stop listening the inputs from
  94151. */
  94152. detachControl(element: Nullable<HTMLElement>): void;
  94153. /**
  94154. * Update the current camera state depending on the inputs that have been used this frame.
  94155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94156. */
  94157. checkInputs(): void;
  94158. /**
  94159. * Gets the class name of the current intput.
  94160. * @returns the class name
  94161. */
  94162. getClassName(): string;
  94163. /**
  94164. * Get the friendly name associated with the input class.
  94165. * @returns the input friendly name
  94166. */
  94167. getSimpleName(): string;
  94168. }
  94169. }
  94170. declare module BABYLON {
  94171. /**
  94172. * Manage the mouse wheel inputs to control an arc rotate camera.
  94173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94174. */
  94175. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94176. /**
  94177. * Defines the camera the input is attached to.
  94178. */
  94179. camera: ArcRotateCamera;
  94180. /**
  94181. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94182. */
  94183. wheelPrecision: number;
  94184. /**
  94185. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94186. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94187. */
  94188. wheelDeltaPercentage: number;
  94189. private _wheel;
  94190. private _observer;
  94191. /**
  94192. * Attach the input controls to a specific dom element to get the input from.
  94193. * @param element Defines the element the controls should be listened from
  94194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94195. */
  94196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94197. /**
  94198. * Detach the current controls from the specified dom element.
  94199. * @param element Defines the element to stop listening the inputs from
  94200. */
  94201. detachControl(element: Nullable<HTMLElement>): void;
  94202. /**
  94203. * Gets the class name of the current intput.
  94204. * @returns the class name
  94205. */
  94206. getClassName(): string;
  94207. /**
  94208. * Get the friendly name associated with the input class.
  94209. * @returns the input friendly name
  94210. */
  94211. getSimpleName(): string;
  94212. }
  94213. }
  94214. declare module BABYLON {
  94215. /**
  94216. * Default Inputs manager for the ArcRotateCamera.
  94217. * It groups all the default supported inputs for ease of use.
  94218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94219. */
  94220. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94221. /**
  94222. * Instantiates a new ArcRotateCameraInputsManager.
  94223. * @param camera Defines the camera the inputs belong to
  94224. */
  94225. constructor(camera: ArcRotateCamera);
  94226. /**
  94227. * Add mouse wheel input support to the input manager.
  94228. * @returns the current input manager
  94229. */
  94230. addMouseWheel(): ArcRotateCameraInputsManager;
  94231. /**
  94232. * Add pointers input support to the input manager.
  94233. * @returns the current input manager
  94234. */
  94235. addPointers(): ArcRotateCameraInputsManager;
  94236. /**
  94237. * Add keyboard input support to the input manager.
  94238. * @returns the current input manager
  94239. */
  94240. addKeyboard(): ArcRotateCameraInputsManager;
  94241. }
  94242. }
  94243. declare module BABYLON {
  94244. /**
  94245. * This represents an orbital type of camera.
  94246. *
  94247. * 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.
  94248. * 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.
  94249. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94250. */
  94251. export class ArcRotateCamera extends TargetCamera {
  94252. /**
  94253. * Defines the rotation angle of the camera along the longitudinal axis.
  94254. */
  94255. alpha: number;
  94256. /**
  94257. * Defines the rotation angle of the camera along the latitudinal axis.
  94258. */
  94259. beta: number;
  94260. /**
  94261. * Defines the radius of the camera from it s target point.
  94262. */
  94263. radius: number;
  94264. protected _target: Vector3;
  94265. protected _targetHost: Nullable<AbstractMesh>;
  94266. /**
  94267. * Defines the target point of the camera.
  94268. * The camera looks towards it form the radius distance.
  94269. */
  94270. target: Vector3;
  94271. /**
  94272. * Define the current local position of the camera in the scene
  94273. */
  94274. position: Vector3;
  94275. /**
  94276. * Current inertia value on the longitudinal axis.
  94277. * The bigger this number the longer it will take for the camera to stop.
  94278. */
  94279. inertialAlphaOffset: number;
  94280. /**
  94281. * Current inertia value on the latitudinal axis.
  94282. * The bigger this number the longer it will take for the camera to stop.
  94283. */
  94284. inertialBetaOffset: number;
  94285. /**
  94286. * Current inertia value on the radius axis.
  94287. * The bigger this number the longer it will take for the camera to stop.
  94288. */
  94289. inertialRadiusOffset: number;
  94290. /**
  94291. * Minimum allowed angle on the longitudinal axis.
  94292. * This can help limiting how the Camera is able to move in the scene.
  94293. */
  94294. lowerAlphaLimit: Nullable<number>;
  94295. /**
  94296. * Maximum allowed angle on the longitudinal axis.
  94297. * This can help limiting how the Camera is able to move in the scene.
  94298. */
  94299. upperAlphaLimit: Nullable<number>;
  94300. /**
  94301. * Minimum allowed angle on the latitudinal axis.
  94302. * This can help limiting how the Camera is able to move in the scene.
  94303. */
  94304. lowerBetaLimit: number;
  94305. /**
  94306. * Maximum allowed angle on the latitudinal axis.
  94307. * This can help limiting how the Camera is able to move in the scene.
  94308. */
  94309. upperBetaLimit: number;
  94310. /**
  94311. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94312. * This can help limiting how the Camera is able to move in the scene.
  94313. */
  94314. lowerRadiusLimit: Nullable<number>;
  94315. /**
  94316. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94317. * This can help limiting how the Camera is able to move in the scene.
  94318. */
  94319. upperRadiusLimit: Nullable<number>;
  94320. /**
  94321. * Defines the current inertia value used during panning of the camera along the X axis.
  94322. */
  94323. inertialPanningX: number;
  94324. /**
  94325. * Defines the current inertia value used during panning of the camera along the Y axis.
  94326. */
  94327. inertialPanningY: number;
  94328. /**
  94329. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94330. * Basically if your fingers moves away from more than this distance you will be considered
  94331. * in pinch mode.
  94332. */
  94333. pinchToPanMaxDistance: number;
  94334. /**
  94335. * Defines the maximum distance the camera can pan.
  94336. * This could help keeping the cammera always in your scene.
  94337. */
  94338. panningDistanceLimit: Nullable<number>;
  94339. /**
  94340. * Defines the target of the camera before paning.
  94341. */
  94342. panningOriginTarget: Vector3;
  94343. /**
  94344. * Defines the value of the inertia used during panning.
  94345. * 0 would mean stop inertia and one would mean no decelleration at all.
  94346. */
  94347. panningInertia: number;
  94348. /**
  94349. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94350. */
  94351. angularSensibilityX: number;
  94352. /**
  94353. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94354. */
  94355. angularSensibilityY: number;
  94356. /**
  94357. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94358. */
  94359. pinchPrecision: number;
  94360. /**
  94361. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94362. * It will be used instead of pinchDeltaPrecision if different from 0.
  94363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94364. */
  94365. pinchDeltaPercentage: number;
  94366. /**
  94367. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94368. */
  94369. panningSensibility: number;
  94370. /**
  94371. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94372. */
  94373. keysUp: number[];
  94374. /**
  94375. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94376. */
  94377. keysDown: number[];
  94378. /**
  94379. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94380. */
  94381. keysLeft: number[];
  94382. /**
  94383. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94384. */
  94385. keysRight: number[];
  94386. /**
  94387. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94388. */
  94389. wheelPrecision: number;
  94390. /**
  94391. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94392. * It will be used instead of pinchDeltaPrecision if different from 0.
  94393. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94394. */
  94395. wheelDeltaPercentage: number;
  94396. /**
  94397. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94398. */
  94399. zoomOnFactor: number;
  94400. /**
  94401. * Defines a screen offset for the camera position.
  94402. */
  94403. targetScreenOffset: Vector2;
  94404. /**
  94405. * Allows the camera to be completely reversed.
  94406. * If false the camera can not arrive upside down.
  94407. */
  94408. allowUpsideDown: boolean;
  94409. /**
  94410. * Define if double tap/click is used to restore the previously saved state of the camera.
  94411. */
  94412. useInputToRestoreState: boolean;
  94413. /** @hidden */
  94414. _viewMatrix: Matrix;
  94415. /** @hidden */
  94416. _useCtrlForPanning: boolean;
  94417. /** @hidden */
  94418. _panningMouseButton: number;
  94419. /**
  94420. * Defines the input associated to the camera.
  94421. */
  94422. inputs: ArcRotateCameraInputsManager;
  94423. /** @hidden */
  94424. _reset: () => void;
  94425. /**
  94426. * Defines the allowed panning axis.
  94427. */
  94428. panningAxis: Vector3;
  94429. protected _localDirection: Vector3;
  94430. protected _transformedDirection: Vector3;
  94431. private _bouncingBehavior;
  94432. /**
  94433. * Gets the bouncing behavior of the camera if it has been enabled.
  94434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94435. */
  94436. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94437. /**
  94438. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94440. */
  94441. useBouncingBehavior: boolean;
  94442. private _framingBehavior;
  94443. /**
  94444. * Gets the framing behavior of the camera if it has been enabled.
  94445. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94446. */
  94447. readonly framingBehavior: Nullable<FramingBehavior>;
  94448. /**
  94449. * Defines if the framing behavior of the camera is enabled on the camera.
  94450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94451. */
  94452. useFramingBehavior: boolean;
  94453. private _autoRotationBehavior;
  94454. /**
  94455. * Gets the auto rotation behavior of the camera if it has been enabled.
  94456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94457. */
  94458. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94459. /**
  94460. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94462. */
  94463. useAutoRotationBehavior: boolean;
  94464. /**
  94465. * Observable triggered when the mesh target has been changed on the camera.
  94466. */
  94467. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94468. /**
  94469. * Event raised when the camera is colliding with a mesh.
  94470. */
  94471. onCollide: (collidedMesh: AbstractMesh) => void;
  94472. /**
  94473. * Defines whether the camera should check collision with the objects oh the scene.
  94474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94475. */
  94476. checkCollisions: boolean;
  94477. /**
  94478. * Defines the collision radius of the camera.
  94479. * This simulates a sphere around the camera.
  94480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94481. */
  94482. collisionRadius: Vector3;
  94483. protected _collider: Collider;
  94484. protected _previousPosition: Vector3;
  94485. protected _collisionVelocity: Vector3;
  94486. protected _newPosition: Vector3;
  94487. protected _previousAlpha: number;
  94488. protected _previousBeta: number;
  94489. protected _previousRadius: number;
  94490. protected _collisionTriggered: boolean;
  94491. protected _targetBoundingCenter: Nullable<Vector3>;
  94492. private _computationVector;
  94493. private _tempAxisVector;
  94494. private _tempAxisRotationMatrix;
  94495. /**
  94496. * Instantiates a new ArcRotateCamera in a given scene
  94497. * @param name Defines the name of the camera
  94498. * @param alpha Defines the camera rotation along the logitudinal axis
  94499. * @param beta Defines the camera rotation along the latitudinal axis
  94500. * @param radius Defines the camera distance from its target
  94501. * @param target Defines the camera target
  94502. * @param scene Defines the scene the camera belongs to
  94503. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94504. */
  94505. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94506. /** @hidden */
  94507. _initCache(): void;
  94508. /** @hidden */
  94509. _updateCache(ignoreParentClass?: boolean): void;
  94510. protected _getTargetPosition(): Vector3;
  94511. private _storedAlpha;
  94512. private _storedBeta;
  94513. private _storedRadius;
  94514. private _storedTarget;
  94515. /**
  94516. * Stores the current state of the camera (alpha, beta, radius and target)
  94517. * @returns the camera itself
  94518. */
  94519. storeState(): Camera;
  94520. /**
  94521. * @hidden
  94522. * Restored camera state. You must call storeState() first
  94523. */
  94524. _restoreStateValues(): boolean;
  94525. /** @hidden */
  94526. _isSynchronizedViewMatrix(): boolean;
  94527. /**
  94528. * Attached controls to the current camera.
  94529. * @param element Defines the element the controls should be listened from
  94530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94531. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94532. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94533. */
  94534. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94535. /**
  94536. * Detach the current controls from the camera.
  94537. * The camera will stop reacting to inputs.
  94538. * @param element Defines the element to stop listening the inputs from
  94539. */
  94540. detachControl(element: HTMLElement): void;
  94541. /** @hidden */
  94542. _checkInputs(): void;
  94543. protected _checkLimits(): void;
  94544. /**
  94545. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94546. */
  94547. rebuildAnglesAndRadius(): void;
  94548. /**
  94549. * Use a position to define the current camera related information like aplha, beta and radius
  94550. * @param position Defines the position to set the camera at
  94551. */
  94552. setPosition(position: Vector3): void;
  94553. /**
  94554. * Defines the target the camera should look at.
  94555. * This will automatically adapt alpha beta and radius to fit within the new target.
  94556. * @param target Defines the new target as a Vector or a mesh
  94557. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94558. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94559. */
  94560. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94561. /** @hidden */
  94562. _getViewMatrix(): Matrix;
  94563. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94564. /**
  94565. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94566. * @param meshes Defines the mesh to zoom on
  94567. * @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)
  94568. */
  94569. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94570. /**
  94571. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94572. * The target will be changed but the radius
  94573. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94574. * @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)
  94575. */
  94576. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94577. min: Vector3;
  94578. max: Vector3;
  94579. distance: number;
  94580. }, doNotUpdateMaxZ?: boolean): void;
  94581. /**
  94582. * @override
  94583. * Override Camera.createRigCamera
  94584. */
  94585. createRigCamera(name: string, cameraIndex: number): Camera;
  94586. /**
  94587. * @hidden
  94588. * @override
  94589. * Override Camera._updateRigCameras
  94590. */
  94591. _updateRigCameras(): void;
  94592. /**
  94593. * Destroy the camera and release the current resources hold by it.
  94594. */
  94595. dispose(): void;
  94596. /**
  94597. * Gets the current object class name.
  94598. * @return the class name
  94599. */
  94600. getClassName(): string;
  94601. }
  94602. }
  94603. declare module BABYLON {
  94604. /**
  94605. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94606. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94607. */
  94608. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94609. /**
  94610. * Gets the name of the behavior.
  94611. */
  94612. readonly name: string;
  94613. private _zoomStopsAnimation;
  94614. private _idleRotationSpeed;
  94615. private _idleRotationWaitTime;
  94616. private _idleRotationSpinupTime;
  94617. /**
  94618. * Sets the flag that indicates if user zooming should stop animation.
  94619. */
  94620. /**
  94621. * Gets the flag that indicates if user zooming should stop animation.
  94622. */
  94623. zoomStopsAnimation: boolean;
  94624. /**
  94625. * Sets the default speed at which the camera rotates around the model.
  94626. */
  94627. /**
  94628. * Gets the default speed at which the camera rotates around the model.
  94629. */
  94630. idleRotationSpeed: number;
  94631. /**
  94632. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94633. */
  94634. /**
  94635. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94636. */
  94637. idleRotationWaitTime: number;
  94638. /**
  94639. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94640. */
  94641. /**
  94642. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94643. */
  94644. idleRotationSpinupTime: number;
  94645. /**
  94646. * Gets a value indicating if the camera is currently rotating because of this behavior
  94647. */
  94648. readonly rotationInProgress: boolean;
  94649. private _onPrePointerObservableObserver;
  94650. private _onAfterCheckInputsObserver;
  94651. private _attachedCamera;
  94652. private _isPointerDown;
  94653. private _lastFrameTime;
  94654. private _lastInteractionTime;
  94655. private _cameraRotationSpeed;
  94656. /**
  94657. * Initializes the behavior.
  94658. */
  94659. init(): void;
  94660. /**
  94661. * Attaches the behavior to its arc rotate camera.
  94662. * @param camera Defines the camera to attach the behavior to
  94663. */
  94664. attach(camera: ArcRotateCamera): void;
  94665. /**
  94666. * Detaches the behavior from its current arc rotate camera.
  94667. */
  94668. detach(): void;
  94669. /**
  94670. * Returns true if user is scrolling.
  94671. * @return true if user is scrolling.
  94672. */
  94673. private _userIsZooming;
  94674. private _lastFrameRadius;
  94675. private _shouldAnimationStopForInteraction;
  94676. /**
  94677. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94678. */
  94679. private _applyUserInteraction;
  94680. private _userIsMoving;
  94681. }
  94682. }
  94683. declare module BABYLON {
  94684. /**
  94685. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94686. */
  94687. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94688. private ui;
  94689. /**
  94690. * The name of the behavior
  94691. */
  94692. name: string;
  94693. /**
  94694. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94695. */
  94696. distanceAwayFromFace: number;
  94697. /**
  94698. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94699. */
  94700. distanceAwayFromBottomOfFace: number;
  94701. private _faceVectors;
  94702. private _target;
  94703. private _scene;
  94704. private _onRenderObserver;
  94705. private _tmpMatrix;
  94706. private _tmpVector;
  94707. /**
  94708. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94709. * @param ui The transform node that should be attched to the mesh
  94710. */
  94711. constructor(ui: TransformNode);
  94712. /**
  94713. * Initializes the behavior
  94714. */
  94715. init(): void;
  94716. private _closestFace;
  94717. private _zeroVector;
  94718. private _lookAtTmpMatrix;
  94719. private _lookAtToRef;
  94720. /**
  94721. * Attaches the AttachToBoxBehavior to the passed in mesh
  94722. * @param target The mesh that the specified node will be attached to
  94723. */
  94724. attach(target: Mesh): void;
  94725. /**
  94726. * Detaches the behavior from the mesh
  94727. */
  94728. detach(): void;
  94729. }
  94730. }
  94731. declare module BABYLON {
  94732. /**
  94733. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94734. */
  94735. export class FadeInOutBehavior implements Behavior<Mesh> {
  94736. /**
  94737. * Time in milliseconds to delay before fading in (Default: 0)
  94738. */
  94739. delay: number;
  94740. /**
  94741. * Time in milliseconds for the mesh to fade in (Default: 300)
  94742. */
  94743. fadeInTime: number;
  94744. private _millisecondsPerFrame;
  94745. private _hovered;
  94746. private _hoverValue;
  94747. private _ownerNode;
  94748. /**
  94749. * Instatiates the FadeInOutBehavior
  94750. */
  94751. constructor();
  94752. /**
  94753. * The name of the behavior
  94754. */
  94755. readonly name: string;
  94756. /**
  94757. * Initializes the behavior
  94758. */
  94759. init(): void;
  94760. /**
  94761. * Attaches the fade behavior on the passed in mesh
  94762. * @param ownerNode The mesh that will be faded in/out once attached
  94763. */
  94764. attach(ownerNode: Mesh): void;
  94765. /**
  94766. * Detaches the behavior from the mesh
  94767. */
  94768. detach(): void;
  94769. /**
  94770. * Triggers the mesh to begin fading in or out
  94771. * @param value if the object should fade in or out (true to fade in)
  94772. */
  94773. fadeIn(value: boolean): void;
  94774. private _update;
  94775. private _setAllVisibility;
  94776. }
  94777. }
  94778. declare module BABYLON {
  94779. /**
  94780. * Class containing a set of static utilities functions for managing Pivots
  94781. * @hidden
  94782. */
  94783. export class PivotTools {
  94784. private static _PivotCached;
  94785. private static _OldPivotPoint;
  94786. private static _PivotTranslation;
  94787. private static _PivotTmpVector;
  94788. /** @hidden */
  94789. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94790. /** @hidden */
  94791. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94792. }
  94793. }
  94794. declare module BABYLON {
  94795. /**
  94796. * Class containing static functions to help procedurally build meshes
  94797. */
  94798. export class PlaneBuilder {
  94799. /**
  94800. * Creates a plane mesh
  94801. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94802. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94803. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94807. * @param name defines the name of the mesh
  94808. * @param options defines the options used to create the mesh
  94809. * @param scene defines the hosting scene
  94810. * @returns the plane mesh
  94811. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94812. */
  94813. static CreatePlane(name: string, options: {
  94814. size?: number;
  94815. width?: number;
  94816. height?: number;
  94817. sideOrientation?: number;
  94818. frontUVs?: Vector4;
  94819. backUVs?: Vector4;
  94820. updatable?: boolean;
  94821. sourcePlane?: Plane;
  94822. }, scene?: Nullable<Scene>): Mesh;
  94823. }
  94824. }
  94825. declare module BABYLON {
  94826. /**
  94827. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94828. */
  94829. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94830. private static _AnyMouseID;
  94831. private _attachedNode;
  94832. private _dragPlane;
  94833. private _scene;
  94834. private _pointerObserver;
  94835. private _beforeRenderObserver;
  94836. private static _planeScene;
  94837. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94838. /**
  94839. * 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)
  94840. */
  94841. maxDragAngle: number;
  94842. /**
  94843. * @hidden
  94844. */
  94845. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94846. /**
  94847. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94848. */
  94849. currentDraggingPointerID: number;
  94850. /**
  94851. * The last position where the pointer hit the drag plane in world space
  94852. */
  94853. lastDragPosition: Vector3;
  94854. /**
  94855. * If the behavior is currently in a dragging state
  94856. */
  94857. dragging: boolean;
  94858. /**
  94859. * 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)
  94860. */
  94861. dragDeltaRatio: number;
  94862. /**
  94863. * If the drag plane orientation should be updated during the dragging (Default: true)
  94864. */
  94865. updateDragPlane: boolean;
  94866. private _debugMode;
  94867. private _moving;
  94868. /**
  94869. * Fires each time the attached mesh is dragged with the pointer
  94870. * * delta between last drag position and current drag position in world space
  94871. * * dragDistance along the drag axis
  94872. * * dragPlaneNormal normal of the current drag plane used during the drag
  94873. * * dragPlanePoint in world space where the drag intersects the drag plane
  94874. */
  94875. onDragObservable: Observable<{
  94876. delta: Vector3;
  94877. dragPlanePoint: Vector3;
  94878. dragPlaneNormal: Vector3;
  94879. dragDistance: number;
  94880. pointerId: number;
  94881. }>;
  94882. /**
  94883. * Fires each time a drag begins (eg. mouse down on mesh)
  94884. */
  94885. onDragStartObservable: Observable<{
  94886. dragPlanePoint: Vector3;
  94887. pointerId: number;
  94888. }>;
  94889. /**
  94890. * Fires each time a drag ends (eg. mouse release after drag)
  94891. */
  94892. onDragEndObservable: Observable<{
  94893. dragPlanePoint: Vector3;
  94894. pointerId: number;
  94895. }>;
  94896. /**
  94897. * If the attached mesh should be moved when dragged
  94898. */
  94899. moveAttached: boolean;
  94900. /**
  94901. * If the drag behavior will react to drag events (Default: true)
  94902. */
  94903. enabled: boolean;
  94904. /**
  94905. * If camera controls should be detached during the drag
  94906. */
  94907. detachCameraControls: boolean;
  94908. /**
  94909. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94910. */
  94911. useObjectOrienationForDragging: boolean;
  94912. private _options;
  94913. /**
  94914. * Creates a pointer drag behavior that can be attached to a mesh
  94915. * @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)
  94916. */
  94917. constructor(options?: {
  94918. dragAxis?: Vector3;
  94919. dragPlaneNormal?: Vector3;
  94920. });
  94921. /**
  94922. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94923. */
  94924. validateDrag: (targetPosition: Vector3) => boolean;
  94925. /**
  94926. * The name of the behavior
  94927. */
  94928. readonly name: string;
  94929. /**
  94930. * Initializes the behavior
  94931. */
  94932. init(): void;
  94933. private _tmpVector;
  94934. private _alternatePickedPoint;
  94935. private _worldDragAxis;
  94936. private _targetPosition;
  94937. private _attachedElement;
  94938. /**
  94939. * Attaches the drag behavior the passed in mesh
  94940. * @param ownerNode The mesh that will be dragged around once attached
  94941. */
  94942. attach(ownerNode: AbstractMesh): void;
  94943. /**
  94944. * Force relase the drag action by code.
  94945. */
  94946. releaseDrag(): void;
  94947. private _startDragRay;
  94948. private _lastPointerRay;
  94949. /**
  94950. * Simulates the start of a pointer drag event on the behavior
  94951. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94952. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94953. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94954. */
  94955. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94956. private _startDrag;
  94957. private _dragDelta;
  94958. private _moveDrag;
  94959. private _pickWithRayOnDragPlane;
  94960. private _pointA;
  94961. private _pointB;
  94962. private _pointC;
  94963. private _lineA;
  94964. private _lineB;
  94965. private _localAxis;
  94966. private _lookAt;
  94967. private _updateDragPlanePosition;
  94968. /**
  94969. * Detaches the behavior from the mesh
  94970. */
  94971. detach(): void;
  94972. }
  94973. }
  94974. declare module BABYLON {
  94975. /**
  94976. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94977. */
  94978. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94979. private _dragBehaviorA;
  94980. private _dragBehaviorB;
  94981. private _startDistance;
  94982. private _initialScale;
  94983. private _targetScale;
  94984. private _ownerNode;
  94985. private _sceneRenderObserver;
  94986. /**
  94987. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94988. */
  94989. constructor();
  94990. /**
  94991. * The name of the behavior
  94992. */
  94993. readonly name: string;
  94994. /**
  94995. * Initializes the behavior
  94996. */
  94997. init(): void;
  94998. private _getCurrentDistance;
  94999. /**
  95000. * Attaches the scale behavior the passed in mesh
  95001. * @param ownerNode The mesh that will be scaled around once attached
  95002. */
  95003. attach(ownerNode: Mesh): void;
  95004. /**
  95005. * Detaches the behavior from the mesh
  95006. */
  95007. detach(): void;
  95008. }
  95009. }
  95010. declare module BABYLON {
  95011. /**
  95012. * 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
  95013. */
  95014. export class SixDofDragBehavior implements Behavior<Mesh> {
  95015. private static _virtualScene;
  95016. private _ownerNode;
  95017. private _sceneRenderObserver;
  95018. private _scene;
  95019. private _targetPosition;
  95020. private _virtualOriginMesh;
  95021. private _virtualDragMesh;
  95022. private _pointerObserver;
  95023. private _moving;
  95024. private _startingOrientation;
  95025. /**
  95026. * 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)
  95027. */
  95028. private zDragFactor;
  95029. /**
  95030. * If the object should rotate to face the drag origin
  95031. */
  95032. rotateDraggedObject: boolean;
  95033. /**
  95034. * If the behavior is currently in a dragging state
  95035. */
  95036. dragging: boolean;
  95037. /**
  95038. * 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)
  95039. */
  95040. dragDeltaRatio: number;
  95041. /**
  95042. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95043. */
  95044. currentDraggingPointerID: number;
  95045. /**
  95046. * If camera controls should be detached during the drag
  95047. */
  95048. detachCameraControls: boolean;
  95049. /**
  95050. * Fires each time a drag starts
  95051. */
  95052. onDragStartObservable: Observable<{}>;
  95053. /**
  95054. * Fires each time a drag ends (eg. mouse release after drag)
  95055. */
  95056. onDragEndObservable: Observable<{}>;
  95057. /**
  95058. * 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
  95059. */
  95060. constructor();
  95061. /**
  95062. * The name of the behavior
  95063. */
  95064. readonly name: string;
  95065. /**
  95066. * Initializes the behavior
  95067. */
  95068. init(): void;
  95069. /**
  95070. * Attaches the scale behavior the passed in mesh
  95071. * @param ownerNode The mesh that will be scaled around once attached
  95072. */
  95073. attach(ownerNode: Mesh): void;
  95074. /**
  95075. * Detaches the behavior from the mesh
  95076. */
  95077. detach(): void;
  95078. }
  95079. }
  95080. declare module BABYLON {
  95081. /**
  95082. * Class used to apply inverse kinematics to bones
  95083. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95084. */
  95085. export class BoneIKController {
  95086. private static _tmpVecs;
  95087. private static _tmpQuat;
  95088. private static _tmpMats;
  95089. /**
  95090. * Gets or sets the target mesh
  95091. */
  95092. targetMesh: AbstractMesh;
  95093. /** Gets or sets the mesh used as pole */
  95094. poleTargetMesh: AbstractMesh;
  95095. /**
  95096. * Gets or sets the bone used as pole
  95097. */
  95098. poleTargetBone: Nullable<Bone>;
  95099. /**
  95100. * Gets or sets the target position
  95101. */
  95102. targetPosition: Vector3;
  95103. /**
  95104. * Gets or sets the pole target position
  95105. */
  95106. poleTargetPosition: Vector3;
  95107. /**
  95108. * Gets or sets the pole target local offset
  95109. */
  95110. poleTargetLocalOffset: Vector3;
  95111. /**
  95112. * Gets or sets the pole angle
  95113. */
  95114. poleAngle: number;
  95115. /**
  95116. * Gets or sets the mesh associated with the controller
  95117. */
  95118. mesh: AbstractMesh;
  95119. /**
  95120. * 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)
  95121. */
  95122. slerpAmount: number;
  95123. private _bone1Quat;
  95124. private _bone1Mat;
  95125. private _bone2Ang;
  95126. private _bone1;
  95127. private _bone2;
  95128. private _bone1Length;
  95129. private _bone2Length;
  95130. private _maxAngle;
  95131. private _maxReach;
  95132. private _rightHandedSystem;
  95133. private _bendAxis;
  95134. private _slerping;
  95135. private _adjustRoll;
  95136. /**
  95137. * Gets or sets maximum allowed angle
  95138. */
  95139. maxAngle: number;
  95140. /**
  95141. * Creates a new BoneIKController
  95142. * @param mesh defines the mesh to control
  95143. * @param bone defines the bone to control
  95144. * @param options defines options to set up the controller
  95145. */
  95146. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95147. targetMesh?: AbstractMesh;
  95148. poleTargetMesh?: AbstractMesh;
  95149. poleTargetBone?: Bone;
  95150. poleTargetLocalOffset?: Vector3;
  95151. poleAngle?: number;
  95152. bendAxis?: Vector3;
  95153. maxAngle?: number;
  95154. slerpAmount?: number;
  95155. });
  95156. private _setMaxAngle;
  95157. /**
  95158. * Force the controller to update the bones
  95159. */
  95160. update(): void;
  95161. }
  95162. }
  95163. declare module BABYLON {
  95164. /**
  95165. * Class used to make a bone look toward a point in space
  95166. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95167. */
  95168. export class BoneLookController {
  95169. private static _tmpVecs;
  95170. private static _tmpQuat;
  95171. private static _tmpMats;
  95172. /**
  95173. * The target Vector3 that the bone will look at
  95174. */
  95175. target: Vector3;
  95176. /**
  95177. * The mesh that the bone is attached to
  95178. */
  95179. mesh: AbstractMesh;
  95180. /**
  95181. * The bone that will be looking to the target
  95182. */
  95183. bone: Bone;
  95184. /**
  95185. * The up axis of the coordinate system that is used when the bone is rotated
  95186. */
  95187. upAxis: Vector3;
  95188. /**
  95189. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95190. */
  95191. upAxisSpace: Space;
  95192. /**
  95193. * Used to make an adjustment to the yaw of the bone
  95194. */
  95195. adjustYaw: number;
  95196. /**
  95197. * Used to make an adjustment to the pitch of the bone
  95198. */
  95199. adjustPitch: number;
  95200. /**
  95201. * Used to make an adjustment to the roll of the bone
  95202. */
  95203. adjustRoll: number;
  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 _minYaw;
  95209. private _maxYaw;
  95210. private _minPitch;
  95211. private _maxPitch;
  95212. private _minYawSin;
  95213. private _minYawCos;
  95214. private _maxYawSin;
  95215. private _maxYawCos;
  95216. private _midYawConstraint;
  95217. private _minPitchTan;
  95218. private _maxPitchTan;
  95219. private _boneQuat;
  95220. private _slerping;
  95221. private _transformYawPitch;
  95222. private _transformYawPitchInv;
  95223. private _firstFrameSkipped;
  95224. private _yawRange;
  95225. private _fowardAxis;
  95226. /**
  95227. * Gets or sets the minimum yaw angle that the bone can look to
  95228. */
  95229. minYaw: number;
  95230. /**
  95231. * Gets or sets the maximum yaw angle that the bone can look to
  95232. */
  95233. maxYaw: number;
  95234. /**
  95235. * Gets or sets the minimum pitch angle that the bone can look to
  95236. */
  95237. minPitch: number;
  95238. /**
  95239. * Gets or sets the maximum pitch angle that the bone can look to
  95240. */
  95241. maxPitch: number;
  95242. /**
  95243. * Create a BoneLookController
  95244. * @param mesh the mesh that the bone belongs to
  95245. * @param bone the bone that will be looking to the target
  95246. * @param target the target Vector3 to look at
  95247. * @param options optional settings:
  95248. * * maxYaw: the maximum angle the bone will yaw to
  95249. * * minYaw: the minimum angle the bone will yaw to
  95250. * * maxPitch: the maximum angle the bone will pitch to
  95251. * * minPitch: the minimum angle the bone will yaw to
  95252. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95253. * * upAxis: the up axis of the coordinate system
  95254. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95255. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95256. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95257. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95258. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95259. * * adjustRoll: used to make an adjustment to the roll of the bone
  95260. **/
  95261. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95262. maxYaw?: number;
  95263. minYaw?: number;
  95264. maxPitch?: number;
  95265. minPitch?: number;
  95266. slerpAmount?: number;
  95267. upAxis?: Vector3;
  95268. upAxisSpace?: Space;
  95269. yawAxis?: Vector3;
  95270. pitchAxis?: Vector3;
  95271. adjustYaw?: number;
  95272. adjustPitch?: number;
  95273. adjustRoll?: number;
  95274. });
  95275. /**
  95276. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95277. */
  95278. update(): void;
  95279. private _getAngleDiff;
  95280. private _getAngleBetween;
  95281. private _isAngleBetween;
  95282. }
  95283. }
  95284. declare module BABYLON {
  95285. /**
  95286. * Manage the gamepad inputs to control an arc rotate camera.
  95287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95288. */
  95289. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95290. /**
  95291. * Defines the camera the input is attached to.
  95292. */
  95293. camera: ArcRotateCamera;
  95294. /**
  95295. * Defines the gamepad the input is gathering event from.
  95296. */
  95297. gamepad: Nullable<Gamepad>;
  95298. /**
  95299. * Defines the gamepad rotation sensiblity.
  95300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95301. */
  95302. gamepadRotationSensibility: number;
  95303. /**
  95304. * Defines the gamepad move sensiblity.
  95305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95306. */
  95307. gamepadMoveSensibility: number;
  95308. private _onGamepadConnectedObserver;
  95309. private _onGamepadDisconnectedObserver;
  95310. /**
  95311. * Attach the input controls to a specific dom element to get the input from.
  95312. * @param element Defines the element the controls should be listened from
  95313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95314. */
  95315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95316. /**
  95317. * Detach the current controls from the specified dom element.
  95318. * @param element Defines the element to stop listening the inputs from
  95319. */
  95320. detachControl(element: Nullable<HTMLElement>): void;
  95321. /**
  95322. * Update the current camera state depending on the inputs that have been used this frame.
  95323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95324. */
  95325. checkInputs(): void;
  95326. /**
  95327. * Gets the class name of the current intput.
  95328. * @returns the class name
  95329. */
  95330. getClassName(): string;
  95331. /**
  95332. * Get the friendly name associated with the input class.
  95333. * @returns the input friendly name
  95334. */
  95335. getSimpleName(): string;
  95336. }
  95337. }
  95338. declare module BABYLON {
  95339. interface ArcRotateCameraInputsManager {
  95340. /**
  95341. * Add orientation input support to the input manager.
  95342. * @returns the current input manager
  95343. */
  95344. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95345. }
  95346. /**
  95347. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95349. */
  95350. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95351. /**
  95352. * Defines the camera the input is attached to.
  95353. */
  95354. camera: ArcRotateCamera;
  95355. /**
  95356. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95357. */
  95358. alphaCorrection: number;
  95359. /**
  95360. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95361. */
  95362. gammaCorrection: number;
  95363. private _alpha;
  95364. private _gamma;
  95365. private _dirty;
  95366. private _deviceOrientationHandler;
  95367. /**
  95368. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95369. */
  95370. constructor();
  95371. /**
  95372. * Attach the input controls to a specific dom element to get the input from.
  95373. * @param element Defines the element the controls should be listened from
  95374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95375. */
  95376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95377. /** @hidden */
  95378. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95379. /**
  95380. * Update the current camera state depending on the inputs that have been used this frame.
  95381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95382. */
  95383. checkInputs(): void;
  95384. /**
  95385. * Detach the current controls from the specified dom element.
  95386. * @param element Defines the element to stop listening the inputs from
  95387. */
  95388. detachControl(element: Nullable<HTMLElement>): void;
  95389. /**
  95390. * Gets the class name of the current intput.
  95391. * @returns the class name
  95392. */
  95393. getClassName(): string;
  95394. /**
  95395. * Get the friendly name associated with the input class.
  95396. * @returns the input friendly name
  95397. */
  95398. getSimpleName(): string;
  95399. }
  95400. }
  95401. declare module BABYLON {
  95402. /**
  95403. * Listen to mouse events to control the camera.
  95404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95405. */
  95406. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95407. /**
  95408. * Defines the camera the input is attached to.
  95409. */
  95410. camera: FlyCamera;
  95411. /**
  95412. * Defines if touch is enabled. (Default is true.)
  95413. */
  95414. touchEnabled: boolean;
  95415. /**
  95416. * Defines the buttons associated with the input to handle camera rotation.
  95417. */
  95418. buttons: number[];
  95419. /**
  95420. * Assign buttons for Yaw control.
  95421. */
  95422. buttonsYaw: number[];
  95423. /**
  95424. * Assign buttons for Pitch control.
  95425. */
  95426. buttonsPitch: number[];
  95427. /**
  95428. * Assign buttons for Roll control.
  95429. */
  95430. buttonsRoll: number[];
  95431. /**
  95432. * Detect if any button is being pressed while mouse is moved.
  95433. * -1 = Mouse locked.
  95434. * 0 = Left button.
  95435. * 1 = Middle Button.
  95436. * 2 = Right Button.
  95437. */
  95438. activeButton: number;
  95439. /**
  95440. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95441. * Higher values reduce its sensitivity.
  95442. */
  95443. angularSensibility: number;
  95444. private _mousemoveCallback;
  95445. private _observer;
  95446. private _rollObserver;
  95447. private previousPosition;
  95448. private noPreventDefault;
  95449. private element;
  95450. /**
  95451. * Listen to mouse events to control the camera.
  95452. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95454. */
  95455. constructor(touchEnabled?: boolean);
  95456. /**
  95457. * Attach the mouse control to the HTML DOM element.
  95458. * @param element Defines the element that listens to the input events.
  95459. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95460. */
  95461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95462. /**
  95463. * Detach the current controls from the specified dom element.
  95464. * @param element Defines the element to stop listening the inputs from
  95465. */
  95466. detachControl(element: Nullable<HTMLElement>): void;
  95467. /**
  95468. * Gets the class name of the current input.
  95469. * @returns the class name.
  95470. */
  95471. getClassName(): string;
  95472. /**
  95473. * Get the friendly name associated with the input class.
  95474. * @returns the input's friendly name.
  95475. */
  95476. getSimpleName(): string;
  95477. private _pointerInput;
  95478. private _onMouseMove;
  95479. /**
  95480. * Rotate camera by mouse offset.
  95481. */
  95482. private rotateCamera;
  95483. }
  95484. }
  95485. declare module BABYLON {
  95486. /**
  95487. * Default Inputs manager for the FlyCamera.
  95488. * It groups all the default supported inputs for ease of use.
  95489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95490. */
  95491. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95492. /**
  95493. * Instantiates a new FlyCameraInputsManager.
  95494. * @param camera Defines the camera the inputs belong to.
  95495. */
  95496. constructor(camera: FlyCamera);
  95497. /**
  95498. * Add keyboard input support to the input manager.
  95499. * @returns the new FlyCameraKeyboardMoveInput().
  95500. */
  95501. addKeyboard(): FlyCameraInputsManager;
  95502. /**
  95503. * Add mouse input support to the input manager.
  95504. * @param touchEnabled Enable touch screen support.
  95505. * @returns the new FlyCameraMouseInput().
  95506. */
  95507. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95508. }
  95509. }
  95510. declare module BABYLON {
  95511. /**
  95512. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95513. * such as in a 3D Space Shooter or a Flight Simulator.
  95514. */
  95515. export class FlyCamera extends TargetCamera {
  95516. /**
  95517. * Define the collision ellipsoid of the camera.
  95518. * This is helpful for simulating a camera body, like a player's body.
  95519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95520. */
  95521. ellipsoid: Vector3;
  95522. /**
  95523. * Define an offset for the position of the ellipsoid around the camera.
  95524. * This can be helpful if the camera is attached away from the player's body center,
  95525. * such as at its head.
  95526. */
  95527. ellipsoidOffset: Vector3;
  95528. /**
  95529. * Enable or disable collisions of the camera with the rest of the scene objects.
  95530. */
  95531. checkCollisions: boolean;
  95532. /**
  95533. * Enable or disable gravity on the camera.
  95534. */
  95535. applyGravity: boolean;
  95536. /**
  95537. * Define the current direction the camera is moving to.
  95538. */
  95539. cameraDirection: Vector3;
  95540. /**
  95541. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95542. * This overrides and empties cameraRotation.
  95543. */
  95544. rotationQuaternion: Quaternion;
  95545. /**
  95546. * Track Roll to maintain the wanted Rolling when looking around.
  95547. */
  95548. _trackRoll: number;
  95549. /**
  95550. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95551. */
  95552. rollCorrect: number;
  95553. /**
  95554. * Mimic a banked turn, Rolling the camera when Yawing.
  95555. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95556. */
  95557. bankedTurn: boolean;
  95558. /**
  95559. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95560. */
  95561. bankedTurnLimit: number;
  95562. /**
  95563. * Value of 0 disables the banked Roll.
  95564. * Value of 1 is equal to the Yaw angle in radians.
  95565. */
  95566. bankedTurnMultiplier: number;
  95567. /**
  95568. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95569. */
  95570. inputs: FlyCameraInputsManager;
  95571. /**
  95572. * Gets the input sensibility for mouse input.
  95573. * Higher values reduce sensitivity.
  95574. */
  95575. /**
  95576. * Sets the input sensibility for a mouse input.
  95577. * Higher values reduce sensitivity.
  95578. */
  95579. angularSensibility: number;
  95580. /**
  95581. * Get the keys for camera movement forward.
  95582. */
  95583. /**
  95584. * Set the keys for camera movement forward.
  95585. */
  95586. keysForward: number[];
  95587. /**
  95588. * Get the keys for camera movement backward.
  95589. */
  95590. keysBackward: number[];
  95591. /**
  95592. * Get the keys for camera movement up.
  95593. */
  95594. /**
  95595. * Set the keys for camera movement up.
  95596. */
  95597. keysUp: number[];
  95598. /**
  95599. * Get the keys for camera movement down.
  95600. */
  95601. /**
  95602. * Set the keys for camera movement down.
  95603. */
  95604. keysDown: number[];
  95605. /**
  95606. * Get the keys for camera movement left.
  95607. */
  95608. /**
  95609. * Set the keys for camera movement left.
  95610. */
  95611. keysLeft: number[];
  95612. /**
  95613. * Set the keys for camera movement right.
  95614. */
  95615. /**
  95616. * Set the keys for camera movement right.
  95617. */
  95618. keysRight: number[];
  95619. /**
  95620. * Event raised when the camera collides with a mesh in the scene.
  95621. */
  95622. onCollide: (collidedMesh: AbstractMesh) => void;
  95623. private _collider;
  95624. private _needMoveForGravity;
  95625. private _oldPosition;
  95626. private _diffPosition;
  95627. private _newPosition;
  95628. /** @hidden */
  95629. _localDirection: Vector3;
  95630. /** @hidden */
  95631. _transformedDirection: Vector3;
  95632. /**
  95633. * Instantiates a FlyCamera.
  95634. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95635. * such as in a 3D Space Shooter or a Flight Simulator.
  95636. * @param name Define the name of the camera in the scene.
  95637. * @param position Define the starting position of the camera in the scene.
  95638. * @param scene Define the scene the camera belongs to.
  95639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95640. */
  95641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95642. /**
  95643. * Attach a control to the HTML DOM element.
  95644. * @param element Defines the element that listens to the input events.
  95645. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95646. */
  95647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95648. /**
  95649. * Detach a control from the HTML DOM element.
  95650. * The camera will stop reacting to that input.
  95651. * @param element Defines the element that listens to the input events.
  95652. */
  95653. detachControl(element: HTMLElement): void;
  95654. private _collisionMask;
  95655. /**
  95656. * Get the mask that the camera ignores in collision events.
  95657. */
  95658. /**
  95659. * Set the mask that the camera ignores in collision events.
  95660. */
  95661. collisionMask: number;
  95662. /** @hidden */
  95663. _collideWithWorld(displacement: Vector3): void;
  95664. /** @hidden */
  95665. private _onCollisionPositionChange;
  95666. /** @hidden */
  95667. _checkInputs(): void;
  95668. /** @hidden */
  95669. _decideIfNeedsToMove(): boolean;
  95670. /** @hidden */
  95671. _updatePosition(): void;
  95672. /**
  95673. * Restore the Roll to its target value at the rate specified.
  95674. * @param rate - Higher means slower restoring.
  95675. * @hidden
  95676. */
  95677. restoreRoll(rate: number): void;
  95678. /**
  95679. * Destroy the camera and release the current resources held by it.
  95680. */
  95681. dispose(): void;
  95682. /**
  95683. * Get the current object class name.
  95684. * @returns the class name.
  95685. */
  95686. getClassName(): string;
  95687. }
  95688. }
  95689. declare module BABYLON {
  95690. /**
  95691. * Listen to keyboard events to control the camera.
  95692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95693. */
  95694. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95695. /**
  95696. * Defines the camera the input is attached to.
  95697. */
  95698. camera: FlyCamera;
  95699. /**
  95700. * The list of keyboard keys used to control the forward move of the camera.
  95701. */
  95702. keysForward: number[];
  95703. /**
  95704. * The list of keyboard keys used to control the backward move of the camera.
  95705. */
  95706. keysBackward: number[];
  95707. /**
  95708. * The list of keyboard keys used to control the forward move of the camera.
  95709. */
  95710. keysUp: number[];
  95711. /**
  95712. * The list of keyboard keys used to control the backward move of the camera.
  95713. */
  95714. keysDown: number[];
  95715. /**
  95716. * The list of keyboard keys used to control the right strafe move of the camera.
  95717. */
  95718. keysRight: number[];
  95719. /**
  95720. * The list of keyboard keys used to control the left strafe move of the camera.
  95721. */
  95722. keysLeft: number[];
  95723. private _keys;
  95724. private _onCanvasBlurObserver;
  95725. private _onKeyboardObserver;
  95726. private _engine;
  95727. private _scene;
  95728. /**
  95729. * Attach the input controls to a specific dom element to get the input from.
  95730. * @param element Defines the element the controls should be listened from
  95731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95732. */
  95733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95734. /**
  95735. * Detach the current controls from the specified dom element.
  95736. * @param element Defines the element to stop listening the inputs from
  95737. */
  95738. detachControl(element: Nullable<HTMLElement>): void;
  95739. /**
  95740. * Gets the class name of the current intput.
  95741. * @returns the class name
  95742. */
  95743. getClassName(): string;
  95744. /** @hidden */
  95745. _onLostFocus(e: FocusEvent): void;
  95746. /**
  95747. * Get the friendly name associated with the input class.
  95748. * @returns the input friendly name
  95749. */
  95750. getSimpleName(): string;
  95751. /**
  95752. * Update the current camera state depending on the inputs that have been used this frame.
  95753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95754. */
  95755. checkInputs(): void;
  95756. }
  95757. }
  95758. declare module BABYLON {
  95759. /**
  95760. * Manage the mouse wheel inputs to control a follow camera.
  95761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95762. */
  95763. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95764. /**
  95765. * Defines the camera the input is attached to.
  95766. */
  95767. camera: FollowCamera;
  95768. /**
  95769. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95770. */
  95771. axisControlRadius: boolean;
  95772. /**
  95773. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95774. */
  95775. axisControlHeight: boolean;
  95776. /**
  95777. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95778. */
  95779. axisControlRotation: boolean;
  95780. /**
  95781. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95782. * relation to mouseWheel events.
  95783. */
  95784. wheelPrecision: number;
  95785. /**
  95786. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95787. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95788. */
  95789. wheelDeltaPercentage: number;
  95790. private _wheel;
  95791. private _observer;
  95792. /**
  95793. * Attach the input controls to a specific dom element to get the input from.
  95794. * @param element Defines the element the controls should be listened from
  95795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95796. */
  95797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95798. /**
  95799. * Detach the current controls from the specified dom element.
  95800. * @param element Defines the element to stop listening the inputs from
  95801. */
  95802. detachControl(element: Nullable<HTMLElement>): void;
  95803. /**
  95804. * Gets the class name of the current intput.
  95805. * @returns the class name
  95806. */
  95807. getClassName(): string;
  95808. /**
  95809. * Get the friendly name associated with the input class.
  95810. * @returns the input friendly name
  95811. */
  95812. getSimpleName(): string;
  95813. }
  95814. }
  95815. declare module BABYLON {
  95816. /**
  95817. * Manage the pointers inputs to control an follow camera.
  95818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95819. */
  95820. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95821. /**
  95822. * Defines the camera the input is attached to.
  95823. */
  95824. camera: FollowCamera;
  95825. /**
  95826. * Gets the class name of the current input.
  95827. * @returns the class name
  95828. */
  95829. getClassName(): string;
  95830. /**
  95831. * Defines the pointer angular sensibility along the X axis or how fast is
  95832. * the camera rotating.
  95833. * A negative number will reverse the axis direction.
  95834. */
  95835. angularSensibilityX: number;
  95836. /**
  95837. * Defines the pointer angular sensibility along the Y axis or how fast is
  95838. * the camera rotating.
  95839. * A negative number will reverse the axis direction.
  95840. */
  95841. angularSensibilityY: number;
  95842. /**
  95843. * Defines the pointer pinch precision or how fast is the camera zooming.
  95844. * A negative number will reverse the axis direction.
  95845. */
  95846. pinchPrecision: number;
  95847. /**
  95848. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95849. * from 0.
  95850. * It defines the percentage of current camera.radius to use as delta when
  95851. * pinch zoom is used.
  95852. */
  95853. pinchDeltaPercentage: number;
  95854. /**
  95855. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95856. */
  95857. axisXControlRadius: boolean;
  95858. /**
  95859. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95860. */
  95861. axisXControlHeight: boolean;
  95862. /**
  95863. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95864. */
  95865. axisXControlRotation: boolean;
  95866. /**
  95867. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95868. */
  95869. axisYControlRadius: boolean;
  95870. /**
  95871. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95872. */
  95873. axisYControlHeight: boolean;
  95874. /**
  95875. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95876. */
  95877. axisYControlRotation: boolean;
  95878. /**
  95879. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95880. */
  95881. axisPinchControlRadius: boolean;
  95882. /**
  95883. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95884. */
  95885. axisPinchControlHeight: boolean;
  95886. /**
  95887. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95888. */
  95889. axisPinchControlRotation: boolean;
  95890. /**
  95891. * Log error messages if basic misconfiguration has occurred.
  95892. */
  95893. warningEnable: boolean;
  95894. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95895. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95896. private _warningCounter;
  95897. private _warning;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * Default Inputs manager for the FollowCamera.
  95903. * It groups all the default supported inputs for ease of use.
  95904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95905. */
  95906. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95907. /**
  95908. * Instantiates a new FollowCameraInputsManager.
  95909. * @param camera Defines the camera the inputs belong to
  95910. */
  95911. constructor(camera: FollowCamera);
  95912. /**
  95913. * Add keyboard input support to the input manager.
  95914. * @returns the current input manager
  95915. */
  95916. addKeyboard(): FollowCameraInputsManager;
  95917. /**
  95918. * Add mouse wheel input support to the input manager.
  95919. * @returns the current input manager
  95920. */
  95921. addMouseWheel(): FollowCameraInputsManager;
  95922. /**
  95923. * Add pointers input support to the input manager.
  95924. * @returns the current input manager
  95925. */
  95926. addPointers(): FollowCameraInputsManager;
  95927. /**
  95928. * Add orientation input support to the input manager.
  95929. * @returns the current input manager
  95930. */
  95931. addVRDeviceOrientation(): FollowCameraInputsManager;
  95932. }
  95933. }
  95934. declare module BABYLON {
  95935. /**
  95936. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95937. * an arc rotate version arcFollowCamera are available.
  95938. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95939. */
  95940. export class FollowCamera extends TargetCamera {
  95941. /**
  95942. * Distance the follow camera should follow an object at
  95943. */
  95944. radius: number;
  95945. /**
  95946. * Minimum allowed distance of the camera to the axis of rotation
  95947. * (The camera can not get closer).
  95948. * This can help limiting how the Camera is able to move in the scene.
  95949. */
  95950. lowerRadiusLimit: Nullable<number>;
  95951. /**
  95952. * Maximum allowed distance of the camera to the axis of rotation
  95953. * (The camera can not get further).
  95954. * This can help limiting how the Camera is able to move in the scene.
  95955. */
  95956. upperRadiusLimit: Nullable<number>;
  95957. /**
  95958. * Define a rotation offset between the camera and the object it follows
  95959. */
  95960. rotationOffset: number;
  95961. /**
  95962. * Minimum allowed angle to camera position relative to target object.
  95963. * This can help limiting how the Camera is able to move in the scene.
  95964. */
  95965. lowerRotationOffsetLimit: Nullable<number>;
  95966. /**
  95967. * Maximum allowed angle to camera position relative to target object.
  95968. * This can help limiting how the Camera is able to move in the scene.
  95969. */
  95970. upperRotationOffsetLimit: Nullable<number>;
  95971. /**
  95972. * Define a height offset between the camera and the object it follows.
  95973. * It can help following an object from the top (like a car chaing a plane)
  95974. */
  95975. heightOffset: number;
  95976. /**
  95977. * Minimum allowed height of camera position relative to target object.
  95978. * This can help limiting how the Camera is able to move in the scene.
  95979. */
  95980. lowerHeightOffsetLimit: Nullable<number>;
  95981. /**
  95982. * Maximum allowed height of camera position relative to target object.
  95983. * This can help limiting how the Camera is able to move in the scene.
  95984. */
  95985. upperHeightOffsetLimit: Nullable<number>;
  95986. /**
  95987. * Define how fast the camera can accelerate to follow it s target.
  95988. */
  95989. cameraAcceleration: number;
  95990. /**
  95991. * Define the speed limit of the camera following an object.
  95992. */
  95993. maxCameraSpeed: number;
  95994. /**
  95995. * Define the target of the camera.
  95996. */
  95997. lockedTarget: Nullable<AbstractMesh>;
  95998. /**
  95999. * Defines the input associated with the camera.
  96000. */
  96001. inputs: FollowCameraInputsManager;
  96002. /**
  96003. * Instantiates the follow camera.
  96004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96005. * @param name Define the name of the camera in the scene
  96006. * @param position Define the position of the camera
  96007. * @param scene Define the scene the camera belong to
  96008. * @param lockedTarget Define the target of the camera
  96009. */
  96010. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96011. private _follow;
  96012. /**
  96013. * Attached controls to the current camera.
  96014. * @param element Defines the element the controls should be listened from
  96015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96016. */
  96017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96018. /**
  96019. * Detach the current controls from the camera.
  96020. * The camera will stop reacting to inputs.
  96021. * @param element Defines the element to stop listening the inputs from
  96022. */
  96023. detachControl(element: HTMLElement): void;
  96024. /** @hidden */
  96025. _checkInputs(): void;
  96026. private _checkLimits;
  96027. /**
  96028. * Gets the camera class name.
  96029. * @returns the class name
  96030. */
  96031. getClassName(): string;
  96032. }
  96033. /**
  96034. * Arc Rotate version of the follow camera.
  96035. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96036. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96037. */
  96038. export class ArcFollowCamera extends TargetCamera {
  96039. /** The longitudinal angle of the camera */
  96040. alpha: number;
  96041. /** The latitudinal angle of the camera */
  96042. beta: number;
  96043. /** The radius of the camera from its target */
  96044. radius: number;
  96045. /** Define the camera target (the messh it should follow) */
  96046. target: Nullable<AbstractMesh>;
  96047. private _cartesianCoordinates;
  96048. /**
  96049. * Instantiates a new ArcFollowCamera
  96050. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96051. * @param name Define the name of the camera
  96052. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96053. * @param beta Define the rotation angle of the camera around the elevation axis
  96054. * @param radius Define the radius of the camera from its target point
  96055. * @param target Define the target of the camera
  96056. * @param scene Define the scene the camera belongs to
  96057. */
  96058. constructor(name: string,
  96059. /** The longitudinal angle of the camera */
  96060. alpha: number,
  96061. /** The latitudinal angle of the camera */
  96062. beta: number,
  96063. /** The radius of the camera from its target */
  96064. radius: number,
  96065. /** Define the camera target (the messh it should follow) */
  96066. target: Nullable<AbstractMesh>, scene: Scene);
  96067. private _follow;
  96068. /** @hidden */
  96069. _checkInputs(): void;
  96070. /**
  96071. * Returns the class name of the object.
  96072. * It is mostly used internally for serialization purposes.
  96073. */
  96074. getClassName(): string;
  96075. }
  96076. }
  96077. declare module BABYLON {
  96078. /**
  96079. * Manage the keyboard inputs to control the movement of a follow camera.
  96080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96081. */
  96082. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96083. /**
  96084. * Defines the camera the input is attached to.
  96085. */
  96086. camera: FollowCamera;
  96087. /**
  96088. * Defines the list of key codes associated with the up action (increase heightOffset)
  96089. */
  96090. keysHeightOffsetIncr: number[];
  96091. /**
  96092. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96093. */
  96094. keysHeightOffsetDecr: number[];
  96095. /**
  96096. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96097. */
  96098. keysHeightOffsetModifierAlt: boolean;
  96099. /**
  96100. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96101. */
  96102. keysHeightOffsetModifierCtrl: boolean;
  96103. /**
  96104. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96105. */
  96106. keysHeightOffsetModifierShift: boolean;
  96107. /**
  96108. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96109. */
  96110. keysRotationOffsetIncr: number[];
  96111. /**
  96112. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96113. */
  96114. keysRotationOffsetDecr: number[];
  96115. /**
  96116. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96117. */
  96118. keysRotationOffsetModifierAlt: boolean;
  96119. /**
  96120. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96121. */
  96122. keysRotationOffsetModifierCtrl: boolean;
  96123. /**
  96124. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96125. */
  96126. keysRotationOffsetModifierShift: boolean;
  96127. /**
  96128. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96129. */
  96130. keysRadiusIncr: number[];
  96131. /**
  96132. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96133. */
  96134. keysRadiusDecr: number[];
  96135. /**
  96136. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96137. */
  96138. keysRadiusModifierAlt: boolean;
  96139. /**
  96140. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96141. */
  96142. keysRadiusModifierCtrl: boolean;
  96143. /**
  96144. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96145. */
  96146. keysRadiusModifierShift: boolean;
  96147. /**
  96148. * Defines the rate of change of heightOffset.
  96149. */
  96150. heightSensibility: number;
  96151. /**
  96152. * Defines the rate of change of rotationOffset.
  96153. */
  96154. rotationSensibility: number;
  96155. /**
  96156. * Defines the rate of change of radius.
  96157. */
  96158. radiusSensibility: number;
  96159. private _keys;
  96160. private _ctrlPressed;
  96161. private _altPressed;
  96162. private _shiftPressed;
  96163. private _onCanvasBlurObserver;
  96164. private _onKeyboardObserver;
  96165. private _engine;
  96166. private _scene;
  96167. /**
  96168. * Attach the input controls to a specific dom element to get the input from.
  96169. * @param element Defines the element the controls should be listened from
  96170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96171. */
  96172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96173. /**
  96174. * Detach the current controls from the specified dom element.
  96175. * @param element Defines the element to stop listening the inputs from
  96176. */
  96177. detachControl(element: Nullable<HTMLElement>): void;
  96178. /**
  96179. * Update the current camera state depending on the inputs that have been used this frame.
  96180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96181. */
  96182. checkInputs(): void;
  96183. /**
  96184. * Gets the class name of the current input.
  96185. * @returns the class name
  96186. */
  96187. getClassName(): string;
  96188. /**
  96189. * Get the friendly name associated with the input class.
  96190. * @returns the input friendly name
  96191. */
  96192. getSimpleName(): string;
  96193. /**
  96194. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96195. * allow modification of the heightOffset value.
  96196. */
  96197. private _modifierHeightOffset;
  96198. /**
  96199. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96200. * allow modification of the rotationOffset value.
  96201. */
  96202. private _modifierRotationOffset;
  96203. /**
  96204. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96205. * allow modification of the radius value.
  96206. */
  96207. private _modifierRadius;
  96208. }
  96209. }
  96210. declare module BABYLON {
  96211. interface FreeCameraInputsManager {
  96212. /**
  96213. * @hidden
  96214. */
  96215. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96216. /**
  96217. * Add orientation input support to the input manager.
  96218. * @returns the current input manager
  96219. */
  96220. addDeviceOrientation(): FreeCameraInputsManager;
  96221. }
  96222. /**
  96223. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96224. * Screen rotation is taken into account.
  96225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96226. */
  96227. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96228. private _camera;
  96229. private _screenOrientationAngle;
  96230. private _constantTranform;
  96231. private _screenQuaternion;
  96232. private _alpha;
  96233. private _beta;
  96234. private _gamma;
  96235. /**
  96236. * @hidden
  96237. */
  96238. _onDeviceOrientationChangedObservable: Observable<void>;
  96239. /**
  96240. * Instantiates a new input
  96241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96242. */
  96243. constructor();
  96244. /**
  96245. * Define the camera controlled by the input.
  96246. */
  96247. camera: FreeCamera;
  96248. /**
  96249. * Attach the input controls to a specific dom element to get the input from.
  96250. * @param element Defines the element the controls should be listened from
  96251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96252. */
  96253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96254. private _orientationChanged;
  96255. private _deviceOrientation;
  96256. /**
  96257. * Detach the current controls from the specified dom element.
  96258. * @param element Defines the element to stop listening the inputs from
  96259. */
  96260. detachControl(element: Nullable<HTMLElement>): void;
  96261. /**
  96262. * Update the current camera state depending on the inputs that have been used this frame.
  96263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96264. */
  96265. checkInputs(): void;
  96266. /**
  96267. * Gets the class name of the current intput.
  96268. * @returns the class name
  96269. */
  96270. getClassName(): string;
  96271. /**
  96272. * Get the friendly name associated with the input class.
  96273. * @returns the input friendly name
  96274. */
  96275. getSimpleName(): string;
  96276. }
  96277. }
  96278. declare module BABYLON {
  96279. /**
  96280. * Manage the gamepad inputs to control a free camera.
  96281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96282. */
  96283. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96284. /**
  96285. * Define the camera the input is attached to.
  96286. */
  96287. camera: FreeCamera;
  96288. /**
  96289. * Define the Gamepad controlling the input
  96290. */
  96291. gamepad: Nullable<Gamepad>;
  96292. /**
  96293. * Defines the gamepad rotation sensiblity.
  96294. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96295. */
  96296. gamepadAngularSensibility: number;
  96297. /**
  96298. * Defines the gamepad move sensiblity.
  96299. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96300. */
  96301. gamepadMoveSensibility: number;
  96302. private _onGamepadConnectedObserver;
  96303. private _onGamepadDisconnectedObserver;
  96304. private _cameraTransform;
  96305. private _deltaTransform;
  96306. private _vector3;
  96307. private _vector2;
  96308. /**
  96309. * Attach the input controls to a specific dom element to get the input from.
  96310. * @param element Defines the element the controls should be listened from
  96311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96312. */
  96313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96314. /**
  96315. * Detach the current controls from the specified dom element.
  96316. * @param element Defines the element to stop listening the inputs from
  96317. */
  96318. detachControl(element: Nullable<HTMLElement>): void;
  96319. /**
  96320. * Update the current camera state depending on the inputs that have been used this frame.
  96321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96322. */
  96323. checkInputs(): void;
  96324. /**
  96325. * Gets the class name of the current intput.
  96326. * @returns the class name
  96327. */
  96328. getClassName(): string;
  96329. /**
  96330. * Get the friendly name associated with the input class.
  96331. * @returns the input friendly name
  96332. */
  96333. getSimpleName(): string;
  96334. }
  96335. }
  96336. declare module BABYLON {
  96337. /**
  96338. * Defines the potential axis of a Joystick
  96339. */
  96340. export enum JoystickAxis {
  96341. /** X axis */
  96342. X = 0,
  96343. /** Y axis */
  96344. Y = 1,
  96345. /** Z axis */
  96346. Z = 2
  96347. }
  96348. /**
  96349. * Class used to define virtual joystick (used in touch mode)
  96350. */
  96351. export class VirtualJoystick {
  96352. /**
  96353. * Gets or sets a boolean indicating that left and right values must be inverted
  96354. */
  96355. reverseLeftRight: boolean;
  96356. /**
  96357. * Gets or sets a boolean indicating that up and down values must be inverted
  96358. */
  96359. reverseUpDown: boolean;
  96360. /**
  96361. * Gets the offset value for the position (ie. the change of the position value)
  96362. */
  96363. deltaPosition: Vector3;
  96364. /**
  96365. * Gets a boolean indicating if the virtual joystick was pressed
  96366. */
  96367. pressed: boolean;
  96368. /**
  96369. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96370. */
  96371. static Canvas: Nullable<HTMLCanvasElement>;
  96372. private static _globalJoystickIndex;
  96373. private static vjCanvasContext;
  96374. private static vjCanvasWidth;
  96375. private static vjCanvasHeight;
  96376. private static halfWidth;
  96377. private _action;
  96378. private _axisTargetedByLeftAndRight;
  96379. private _axisTargetedByUpAndDown;
  96380. private _joystickSensibility;
  96381. private _inversedSensibility;
  96382. private _joystickPointerID;
  96383. private _joystickColor;
  96384. private _joystickPointerPos;
  96385. private _joystickPreviousPointerPos;
  96386. private _joystickPointerStartPos;
  96387. private _deltaJoystickVector;
  96388. private _leftJoystick;
  96389. private _touches;
  96390. private _onPointerDownHandlerRef;
  96391. private _onPointerMoveHandlerRef;
  96392. private _onPointerUpHandlerRef;
  96393. private _onResize;
  96394. /**
  96395. * Creates a new virtual joystick
  96396. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96397. */
  96398. constructor(leftJoystick?: boolean);
  96399. /**
  96400. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96401. * @param newJoystickSensibility defines the new sensibility
  96402. */
  96403. setJoystickSensibility(newJoystickSensibility: number): void;
  96404. private _onPointerDown;
  96405. private _onPointerMove;
  96406. private _onPointerUp;
  96407. /**
  96408. * Change the color of the virtual joystick
  96409. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96410. */
  96411. setJoystickColor(newColor: string): void;
  96412. /**
  96413. * Defines a callback to call when the joystick is touched
  96414. * @param action defines the callback
  96415. */
  96416. setActionOnTouch(action: () => any): void;
  96417. /**
  96418. * Defines which axis you'd like to control for left & right
  96419. * @param axis defines the axis to use
  96420. */
  96421. setAxisForLeftRight(axis: JoystickAxis): void;
  96422. /**
  96423. * Defines which axis you'd like to control for up & down
  96424. * @param axis defines the axis to use
  96425. */
  96426. setAxisForUpDown(axis: JoystickAxis): void;
  96427. private _drawVirtualJoystick;
  96428. /**
  96429. * Release internal HTML canvas
  96430. */
  96431. releaseCanvas(): void;
  96432. }
  96433. }
  96434. declare module BABYLON {
  96435. interface FreeCameraInputsManager {
  96436. /**
  96437. * Add virtual joystick input support to the input manager.
  96438. * @returns the current input manager
  96439. */
  96440. addVirtualJoystick(): FreeCameraInputsManager;
  96441. }
  96442. /**
  96443. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96445. */
  96446. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96447. /**
  96448. * Defines the camera the input is attached to.
  96449. */
  96450. camera: FreeCamera;
  96451. private _leftjoystick;
  96452. private _rightjoystick;
  96453. /**
  96454. * Gets the left stick of the virtual joystick.
  96455. * @returns The virtual Joystick
  96456. */
  96457. getLeftJoystick(): VirtualJoystick;
  96458. /**
  96459. * Gets the right stick of the virtual joystick.
  96460. * @returns The virtual Joystick
  96461. */
  96462. getRightJoystick(): VirtualJoystick;
  96463. /**
  96464. * Update the current camera state depending on the inputs that have been used this frame.
  96465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96466. */
  96467. checkInputs(): void;
  96468. /**
  96469. * Attach the input controls to a specific dom element to get the input from.
  96470. * @param element Defines the element the controls should be listened from
  96471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96472. */
  96473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96474. /**
  96475. * Detach the current controls from the specified dom element.
  96476. * @param element Defines the element to stop listening the inputs from
  96477. */
  96478. detachControl(element: Nullable<HTMLElement>): void;
  96479. /**
  96480. * Gets the class name of the current intput.
  96481. * @returns the class name
  96482. */
  96483. getClassName(): string;
  96484. /**
  96485. * Get the friendly name associated with the input class.
  96486. * @returns the input friendly name
  96487. */
  96488. getSimpleName(): string;
  96489. }
  96490. }
  96491. declare module BABYLON {
  96492. /**
  96493. * This represents a FPS type of camera controlled by touch.
  96494. * This is like a universal camera minus the Gamepad controls.
  96495. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96496. */
  96497. export class TouchCamera extends FreeCamera {
  96498. /**
  96499. * Defines the touch sensibility for rotation.
  96500. * The higher the faster.
  96501. */
  96502. touchAngularSensibility: number;
  96503. /**
  96504. * Defines the touch sensibility for move.
  96505. * The higher the faster.
  96506. */
  96507. touchMoveSensibility: number;
  96508. /**
  96509. * Instantiates a new touch camera.
  96510. * This represents a FPS type of camera controlled by touch.
  96511. * This is like a universal camera minus the Gamepad controls.
  96512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96513. * @param name Define the name of the camera in the scene
  96514. * @param position Define the start position of the camera in the scene
  96515. * @param scene Define the scene the camera belongs to
  96516. */
  96517. constructor(name: string, position: Vector3, scene: Scene);
  96518. /**
  96519. * Gets the current object class name.
  96520. * @return the class name
  96521. */
  96522. getClassName(): string;
  96523. /** @hidden */
  96524. _setupInputs(): void;
  96525. }
  96526. }
  96527. declare module BABYLON {
  96528. /**
  96529. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96530. * being tilted forward or back and left or right.
  96531. */
  96532. export class DeviceOrientationCamera extends FreeCamera {
  96533. private _initialQuaternion;
  96534. private _quaternionCache;
  96535. private _tmpDragQuaternion;
  96536. /**
  96537. * Creates a new device orientation camera
  96538. * @param name The name of the camera
  96539. * @param position The start position camera
  96540. * @param scene The scene the camera belongs to
  96541. */
  96542. constructor(name: string, position: Vector3, scene: Scene);
  96543. /**
  96544. * Disabled pointer input on first orientation sensor update (Default: true)
  96545. */
  96546. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96547. private _dragFactor;
  96548. /**
  96549. * Enabled turning on the y axis when the orientation sensor is active
  96550. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96551. */
  96552. enableHorizontalDragging(dragFactor?: number): void;
  96553. /**
  96554. * Gets the current instance class name ("DeviceOrientationCamera").
  96555. * This helps avoiding instanceof at run time.
  96556. * @returns the class name
  96557. */
  96558. getClassName(): string;
  96559. /**
  96560. * @hidden
  96561. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96562. */
  96563. _checkInputs(): void;
  96564. /**
  96565. * Reset the camera to its default orientation on the specified axis only.
  96566. * @param axis The axis to reset
  96567. */
  96568. resetToCurrentRotation(axis?: Axis): void;
  96569. }
  96570. }
  96571. declare module BABYLON {
  96572. /**
  96573. * 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,
  96574. * which still works and will still be found in many Playgrounds.
  96575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96576. */
  96577. export class UniversalCamera extends TouchCamera {
  96578. /**
  96579. * Defines the gamepad rotation sensiblity.
  96580. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96581. */
  96582. gamepadAngularSensibility: number;
  96583. /**
  96584. * Defines the gamepad move sensiblity.
  96585. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96586. */
  96587. gamepadMoveSensibility: number;
  96588. /**
  96589. * 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,
  96590. * which still works and will still be found in many Playgrounds.
  96591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96592. * @param name Define the name of the camera in the scene
  96593. * @param position Define the start position of the camera in the scene
  96594. * @param scene Define the scene the camera belongs to
  96595. */
  96596. constructor(name: string, position: Vector3, scene: Scene);
  96597. /**
  96598. * Gets the current object class name.
  96599. * @return the class name
  96600. */
  96601. getClassName(): string;
  96602. }
  96603. }
  96604. declare module BABYLON {
  96605. /**
  96606. * This represents a FPS type of camera. This is only here for back compat purpose.
  96607. * Please use the UniversalCamera instead as both are identical.
  96608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96609. */
  96610. export class GamepadCamera extends UniversalCamera {
  96611. /**
  96612. * Instantiates a new Gamepad Camera
  96613. * This represents a FPS type of camera. This is only here for back compat purpose.
  96614. * Please use the UniversalCamera instead as both are identical.
  96615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96616. * @param name Define the name of the camera in the scene
  96617. * @param position Define the start position of the camera in the scene
  96618. * @param scene Define the scene the camera belongs to
  96619. */
  96620. constructor(name: string, position: Vector3, scene: Scene);
  96621. /**
  96622. * Gets the current object class name.
  96623. * @return the class name
  96624. */
  96625. getClassName(): string;
  96626. }
  96627. }
  96628. declare module BABYLON {
  96629. /** @hidden */
  96630. export var passPixelShader: {
  96631. name: string;
  96632. shader: string;
  96633. };
  96634. }
  96635. declare module BABYLON {
  96636. /** @hidden */
  96637. export var passCubePixelShader: {
  96638. name: string;
  96639. shader: string;
  96640. };
  96641. }
  96642. declare module BABYLON {
  96643. /**
  96644. * PassPostProcess which produces an output the same as it's input
  96645. */
  96646. export class PassPostProcess extends PostProcess {
  96647. /**
  96648. * Creates the PassPostProcess
  96649. * @param name The name of the effect.
  96650. * @param options The required width/height ratio to downsize to before computing the render pass.
  96651. * @param camera The camera to apply the render pass to.
  96652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96653. * @param engine The engine which the post process will be applied. (default: current engine)
  96654. * @param reusable If the post process can be reused on the same frame. (default: false)
  96655. * @param textureType The type of texture to be used when performing the post processing.
  96656. * @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)
  96657. */
  96658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96659. }
  96660. /**
  96661. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96662. */
  96663. export class PassCubePostProcess extends PostProcess {
  96664. private _face;
  96665. /**
  96666. * Gets or sets the cube face to display.
  96667. * * 0 is +X
  96668. * * 1 is -X
  96669. * * 2 is +Y
  96670. * * 3 is -Y
  96671. * * 4 is +Z
  96672. * * 5 is -Z
  96673. */
  96674. face: number;
  96675. /**
  96676. * Creates the PassCubePostProcess
  96677. * @param name The name of the effect.
  96678. * @param options The required width/height ratio to downsize to before computing the render pass.
  96679. * @param camera The camera to apply the render pass to.
  96680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96681. * @param engine The engine which the post process will be applied. (default: current engine)
  96682. * @param reusable If the post process can be reused on the same frame. (default: false)
  96683. * @param textureType The type of texture to be used when performing the post processing.
  96684. * @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)
  96685. */
  96686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96687. }
  96688. }
  96689. declare module BABYLON {
  96690. /** @hidden */
  96691. export var anaglyphPixelShader: {
  96692. name: string;
  96693. shader: string;
  96694. };
  96695. }
  96696. declare module BABYLON {
  96697. /**
  96698. * Postprocess used to generate anaglyphic rendering
  96699. */
  96700. export class AnaglyphPostProcess extends PostProcess {
  96701. private _passedProcess;
  96702. /**
  96703. * Creates a new AnaglyphPostProcess
  96704. * @param name defines postprocess name
  96705. * @param options defines creation options or target ratio scale
  96706. * @param rigCameras defines cameras using this postprocess
  96707. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96708. * @param engine defines hosting engine
  96709. * @param reusable defines if the postprocess will be reused multiple times per frame
  96710. */
  96711. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96712. }
  96713. }
  96714. declare module BABYLON {
  96715. /**
  96716. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96717. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96718. */
  96719. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96720. /**
  96721. * Creates a new AnaglyphArcRotateCamera
  96722. * @param name defines camera name
  96723. * @param alpha defines alpha angle (in radians)
  96724. * @param beta defines beta angle (in radians)
  96725. * @param radius defines radius
  96726. * @param target defines camera target
  96727. * @param interaxialDistance defines distance between each color axis
  96728. * @param scene defines the hosting scene
  96729. */
  96730. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96731. /**
  96732. * Gets camera class name
  96733. * @returns AnaglyphArcRotateCamera
  96734. */
  96735. getClassName(): string;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96741. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96742. */
  96743. export class AnaglyphFreeCamera extends FreeCamera {
  96744. /**
  96745. * Creates a new AnaglyphFreeCamera
  96746. * @param name defines camera name
  96747. * @param position defines initial position
  96748. * @param interaxialDistance defines distance between each color axis
  96749. * @param scene defines the hosting scene
  96750. */
  96751. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96752. /**
  96753. * Gets camera class name
  96754. * @returns AnaglyphFreeCamera
  96755. */
  96756. getClassName(): string;
  96757. }
  96758. }
  96759. declare module BABYLON {
  96760. /**
  96761. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96763. */
  96764. export class AnaglyphGamepadCamera extends GamepadCamera {
  96765. /**
  96766. * Creates a new AnaglyphGamepadCamera
  96767. * @param name defines camera name
  96768. * @param position defines initial position
  96769. * @param interaxialDistance defines distance between each color axis
  96770. * @param scene defines the hosting scene
  96771. */
  96772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96773. /**
  96774. * Gets camera class name
  96775. * @returns AnaglyphGamepadCamera
  96776. */
  96777. getClassName(): string;
  96778. }
  96779. }
  96780. declare module BABYLON {
  96781. /**
  96782. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96783. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96784. */
  96785. export class AnaglyphUniversalCamera extends UniversalCamera {
  96786. /**
  96787. * Creates a new AnaglyphUniversalCamera
  96788. * @param name defines camera name
  96789. * @param position defines initial position
  96790. * @param interaxialDistance defines distance between each color axis
  96791. * @param scene defines the hosting scene
  96792. */
  96793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96794. /**
  96795. * Gets camera class name
  96796. * @returns AnaglyphUniversalCamera
  96797. */
  96798. getClassName(): string;
  96799. }
  96800. }
  96801. declare module BABYLON {
  96802. /** @hidden */
  96803. export var stereoscopicInterlacePixelShader: {
  96804. name: string;
  96805. shader: string;
  96806. };
  96807. }
  96808. declare module BABYLON {
  96809. /**
  96810. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96811. */
  96812. export class StereoscopicInterlacePostProcess extends PostProcess {
  96813. private _stepSize;
  96814. private _passedProcess;
  96815. /**
  96816. * Initializes a StereoscopicInterlacePostProcess
  96817. * @param name The name of the effect.
  96818. * @param rigCameras The rig cameras to be appled to the post process
  96819. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96821. * @param engine The engine which the post process will be applied. (default: current engine)
  96822. * @param reusable If the post process can be reused on the same frame. (default: false)
  96823. */
  96824. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96825. }
  96826. }
  96827. declare module BABYLON {
  96828. /**
  96829. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96830. * @see http://doc.babylonjs.com/features/cameras
  96831. */
  96832. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96833. /**
  96834. * Creates a new StereoscopicArcRotateCamera
  96835. * @param name defines camera name
  96836. * @param alpha defines alpha angle (in radians)
  96837. * @param beta defines beta angle (in radians)
  96838. * @param radius defines radius
  96839. * @param target defines camera target
  96840. * @param interaxialDistance defines distance between each color axis
  96841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96842. * @param scene defines the hosting scene
  96843. */
  96844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96845. /**
  96846. * Gets camera class name
  96847. * @returns StereoscopicArcRotateCamera
  96848. */
  96849. getClassName(): string;
  96850. }
  96851. }
  96852. declare module BABYLON {
  96853. /**
  96854. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96855. * @see http://doc.babylonjs.com/features/cameras
  96856. */
  96857. export class StereoscopicFreeCamera extends FreeCamera {
  96858. /**
  96859. * Creates a new StereoscopicFreeCamera
  96860. * @param name defines camera name
  96861. * @param position defines initial position
  96862. * @param interaxialDistance defines distance between each color axis
  96863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96864. * @param scene defines the hosting scene
  96865. */
  96866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96867. /**
  96868. * Gets camera class name
  96869. * @returns StereoscopicFreeCamera
  96870. */
  96871. getClassName(): string;
  96872. }
  96873. }
  96874. declare module BABYLON {
  96875. /**
  96876. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96877. * @see http://doc.babylonjs.com/features/cameras
  96878. */
  96879. export class StereoscopicGamepadCamera extends GamepadCamera {
  96880. /**
  96881. * Creates a new StereoscopicGamepadCamera
  96882. * @param name defines camera name
  96883. * @param position defines initial position
  96884. * @param interaxialDistance defines distance between each color axis
  96885. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96886. * @param scene defines the hosting scene
  96887. */
  96888. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96889. /**
  96890. * Gets camera class name
  96891. * @returns StereoscopicGamepadCamera
  96892. */
  96893. getClassName(): string;
  96894. }
  96895. }
  96896. declare module BABYLON {
  96897. /**
  96898. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96899. * @see http://doc.babylonjs.com/features/cameras
  96900. */
  96901. export class StereoscopicUniversalCamera extends UniversalCamera {
  96902. /**
  96903. * Creates a new StereoscopicUniversalCamera
  96904. * @param name defines camera name
  96905. * @param position defines initial position
  96906. * @param interaxialDistance defines distance between each color axis
  96907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96908. * @param scene defines the hosting scene
  96909. */
  96910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96911. /**
  96912. * Gets camera class name
  96913. * @returns StereoscopicUniversalCamera
  96914. */
  96915. getClassName(): string;
  96916. }
  96917. }
  96918. declare module BABYLON {
  96919. /**
  96920. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96921. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96922. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96923. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96924. */
  96925. export class VirtualJoysticksCamera extends FreeCamera {
  96926. /**
  96927. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96928. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96929. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96930. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96931. * @param name Define the name of the camera in the scene
  96932. * @param position Define the start position of the camera in the scene
  96933. * @param scene Define the scene the camera belongs to
  96934. */
  96935. constructor(name: string, position: Vector3, scene: Scene);
  96936. /**
  96937. * Gets the current object class name.
  96938. * @return the class name
  96939. */
  96940. getClassName(): string;
  96941. }
  96942. }
  96943. declare module BABYLON {
  96944. /**
  96945. * This represents all the required metrics to create a VR camera.
  96946. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96947. */
  96948. export class VRCameraMetrics {
  96949. /**
  96950. * Define the horizontal resolution off the screen.
  96951. */
  96952. hResolution: number;
  96953. /**
  96954. * Define the vertical resolution off the screen.
  96955. */
  96956. vResolution: number;
  96957. /**
  96958. * Define the horizontal screen size.
  96959. */
  96960. hScreenSize: number;
  96961. /**
  96962. * Define the vertical screen size.
  96963. */
  96964. vScreenSize: number;
  96965. /**
  96966. * Define the vertical screen center position.
  96967. */
  96968. vScreenCenter: number;
  96969. /**
  96970. * Define the distance of the eyes to the screen.
  96971. */
  96972. eyeToScreenDistance: number;
  96973. /**
  96974. * Define the distance between both lenses
  96975. */
  96976. lensSeparationDistance: number;
  96977. /**
  96978. * Define the distance between both viewer's eyes.
  96979. */
  96980. interpupillaryDistance: number;
  96981. /**
  96982. * Define the distortion factor of the VR postprocess.
  96983. * Please, touch with care.
  96984. */
  96985. distortionK: number[];
  96986. /**
  96987. * Define the chromatic aberration correction factors for the VR post process.
  96988. */
  96989. chromaAbCorrection: number[];
  96990. /**
  96991. * Define the scale factor of the post process.
  96992. * The smaller the better but the slower.
  96993. */
  96994. postProcessScaleFactor: number;
  96995. /**
  96996. * Define an offset for the lens center.
  96997. */
  96998. lensCenterOffset: number;
  96999. /**
  97000. * Define if the current vr camera should compensate the distortion of the lense or not.
  97001. */
  97002. compensateDistortion: boolean;
  97003. /**
  97004. * Defines if multiview should be enabled when rendering (Default: false)
  97005. */
  97006. multiviewEnabled: boolean;
  97007. /**
  97008. * Gets the rendering aspect ratio based on the provided resolutions.
  97009. */
  97010. readonly aspectRatio: number;
  97011. /**
  97012. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97013. */
  97014. readonly aspectRatioFov: number;
  97015. /**
  97016. * @hidden
  97017. */
  97018. readonly leftHMatrix: Matrix;
  97019. /**
  97020. * @hidden
  97021. */
  97022. readonly rightHMatrix: Matrix;
  97023. /**
  97024. * @hidden
  97025. */
  97026. readonly leftPreViewMatrix: Matrix;
  97027. /**
  97028. * @hidden
  97029. */
  97030. readonly rightPreViewMatrix: Matrix;
  97031. /**
  97032. * Get the default VRMetrics based on the most generic setup.
  97033. * @returns the default vr metrics
  97034. */
  97035. static GetDefault(): VRCameraMetrics;
  97036. }
  97037. }
  97038. declare module BABYLON {
  97039. /** @hidden */
  97040. export var vrDistortionCorrectionPixelShader: {
  97041. name: string;
  97042. shader: string;
  97043. };
  97044. }
  97045. declare module BABYLON {
  97046. /**
  97047. * VRDistortionCorrectionPostProcess used for mobile VR
  97048. */
  97049. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97050. private _isRightEye;
  97051. private _distortionFactors;
  97052. private _postProcessScaleFactor;
  97053. private _lensCenterOffset;
  97054. private _scaleIn;
  97055. private _scaleFactor;
  97056. private _lensCenter;
  97057. /**
  97058. * Initializes the VRDistortionCorrectionPostProcess
  97059. * @param name The name of the effect.
  97060. * @param camera The camera to apply the render pass to.
  97061. * @param isRightEye If this is for the right eye distortion
  97062. * @param vrMetrics All the required metrics for the VR camera
  97063. */
  97064. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97065. }
  97066. }
  97067. declare module BABYLON {
  97068. /**
  97069. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97071. */
  97072. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97073. /**
  97074. * Creates a new VRDeviceOrientationArcRotateCamera
  97075. * @param name defines camera name
  97076. * @param alpha defines the camera rotation along the logitudinal axis
  97077. * @param beta defines the camera rotation along the latitudinal axis
  97078. * @param radius defines the camera distance from its target
  97079. * @param target defines the camera target
  97080. * @param scene defines the scene the camera belongs to
  97081. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97082. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97083. */
  97084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97085. /**
  97086. * Gets camera class name
  97087. * @returns VRDeviceOrientationArcRotateCamera
  97088. */
  97089. getClassName(): string;
  97090. }
  97091. }
  97092. declare module BABYLON {
  97093. /**
  97094. * Camera used to simulate VR rendering (based on FreeCamera)
  97095. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97096. */
  97097. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97098. /**
  97099. * Creates a new VRDeviceOrientationFreeCamera
  97100. * @param name defines camera name
  97101. * @param position defines the start position of the camera
  97102. * @param scene defines the scene the camera belongs to
  97103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97105. */
  97106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97107. /**
  97108. * Gets camera class name
  97109. * @returns VRDeviceOrientationFreeCamera
  97110. */
  97111. getClassName(): string;
  97112. }
  97113. }
  97114. declare module BABYLON {
  97115. /**
  97116. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97117. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97118. */
  97119. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97120. /**
  97121. * Creates a new VRDeviceOrientationGamepadCamera
  97122. * @param name defines camera name
  97123. * @param position defines the start position of the camera
  97124. * @param scene defines the scene the camera belongs to
  97125. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97126. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97127. */
  97128. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97129. /**
  97130. * Gets camera class name
  97131. * @returns VRDeviceOrientationGamepadCamera
  97132. */
  97133. getClassName(): string;
  97134. }
  97135. }
  97136. declare module BABYLON {
  97137. /**
  97138. * Defines supported buttons for XBox360 compatible gamepads
  97139. */
  97140. export enum Xbox360Button {
  97141. /** A */
  97142. A = 0,
  97143. /** B */
  97144. B = 1,
  97145. /** X */
  97146. X = 2,
  97147. /** Y */
  97148. Y = 3,
  97149. /** Start */
  97150. Start = 4,
  97151. /** Back */
  97152. Back = 5,
  97153. /** Left button */
  97154. LB = 6,
  97155. /** Right button */
  97156. RB = 7,
  97157. /** Left stick */
  97158. LeftStick = 8,
  97159. /** Right stick */
  97160. RightStick = 9
  97161. }
  97162. /** Defines values for XBox360 DPad */
  97163. export enum Xbox360Dpad {
  97164. /** Up */
  97165. Up = 0,
  97166. /** Down */
  97167. Down = 1,
  97168. /** Left */
  97169. Left = 2,
  97170. /** Right */
  97171. Right = 3
  97172. }
  97173. /**
  97174. * Defines a XBox360 gamepad
  97175. */
  97176. export class Xbox360Pad extends Gamepad {
  97177. private _leftTrigger;
  97178. private _rightTrigger;
  97179. private _onlefttriggerchanged;
  97180. private _onrighttriggerchanged;
  97181. private _onbuttondown;
  97182. private _onbuttonup;
  97183. private _ondpaddown;
  97184. private _ondpadup;
  97185. /** Observable raised when a button is pressed */
  97186. onButtonDownObservable: Observable<Xbox360Button>;
  97187. /** Observable raised when a button is released */
  97188. onButtonUpObservable: Observable<Xbox360Button>;
  97189. /** Observable raised when a pad is pressed */
  97190. onPadDownObservable: Observable<Xbox360Dpad>;
  97191. /** Observable raised when a pad is released */
  97192. onPadUpObservable: Observable<Xbox360Dpad>;
  97193. private _buttonA;
  97194. private _buttonB;
  97195. private _buttonX;
  97196. private _buttonY;
  97197. private _buttonBack;
  97198. private _buttonStart;
  97199. private _buttonLB;
  97200. private _buttonRB;
  97201. private _buttonLeftStick;
  97202. private _buttonRightStick;
  97203. private _dPadUp;
  97204. private _dPadDown;
  97205. private _dPadLeft;
  97206. private _dPadRight;
  97207. private _isXboxOnePad;
  97208. /**
  97209. * Creates a new XBox360 gamepad object
  97210. * @param id defines the id of this gamepad
  97211. * @param index defines its index
  97212. * @param gamepad defines the internal HTML gamepad object
  97213. * @param xboxOne defines if it is a XBox One gamepad
  97214. */
  97215. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97216. /**
  97217. * Defines the callback to call when left trigger is pressed
  97218. * @param callback defines the callback to use
  97219. */
  97220. onlefttriggerchanged(callback: (value: number) => void): void;
  97221. /**
  97222. * Defines the callback to call when right trigger is pressed
  97223. * @param callback defines the callback to use
  97224. */
  97225. onrighttriggerchanged(callback: (value: number) => void): void;
  97226. /**
  97227. * Gets the left trigger value
  97228. */
  97229. /**
  97230. * Sets the left trigger value
  97231. */
  97232. leftTrigger: number;
  97233. /**
  97234. * Gets the right trigger value
  97235. */
  97236. /**
  97237. * Sets the right trigger value
  97238. */
  97239. rightTrigger: number;
  97240. /**
  97241. * Defines the callback to call when a button is pressed
  97242. * @param callback defines the callback to use
  97243. */
  97244. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97245. /**
  97246. * Defines the callback to call when a button is released
  97247. * @param callback defines the callback to use
  97248. */
  97249. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97250. /**
  97251. * Defines the callback to call when a pad is pressed
  97252. * @param callback defines the callback to use
  97253. */
  97254. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97255. /**
  97256. * Defines the callback to call when a pad is released
  97257. * @param callback defines the callback to use
  97258. */
  97259. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97260. private _setButtonValue;
  97261. private _setDPadValue;
  97262. /**
  97263. * Gets the value of the `A` button
  97264. */
  97265. /**
  97266. * Sets the value of the `A` button
  97267. */
  97268. buttonA: number;
  97269. /**
  97270. * Gets the value of the `B` button
  97271. */
  97272. /**
  97273. * Sets the value of the `B` button
  97274. */
  97275. buttonB: number;
  97276. /**
  97277. * Gets the value of the `X` button
  97278. */
  97279. /**
  97280. * Sets the value of the `X` button
  97281. */
  97282. buttonX: number;
  97283. /**
  97284. * Gets the value of the `Y` button
  97285. */
  97286. /**
  97287. * Sets the value of the `Y` button
  97288. */
  97289. buttonY: number;
  97290. /**
  97291. * Gets the value of the `Start` button
  97292. */
  97293. /**
  97294. * Sets the value of the `Start` button
  97295. */
  97296. buttonStart: number;
  97297. /**
  97298. * Gets the value of the `Back` button
  97299. */
  97300. /**
  97301. * Sets the value of the `Back` button
  97302. */
  97303. buttonBack: number;
  97304. /**
  97305. * Gets the value of the `Left` button
  97306. */
  97307. /**
  97308. * Sets the value of the `Left` button
  97309. */
  97310. buttonLB: number;
  97311. /**
  97312. * Gets the value of the `Right` button
  97313. */
  97314. /**
  97315. * Sets the value of the `Right` button
  97316. */
  97317. buttonRB: number;
  97318. /**
  97319. * Gets the value of the Left joystick
  97320. */
  97321. /**
  97322. * Sets the value of the Left joystick
  97323. */
  97324. buttonLeftStick: number;
  97325. /**
  97326. * Gets the value of the Right joystick
  97327. */
  97328. /**
  97329. * Sets the value of the Right joystick
  97330. */
  97331. buttonRightStick: number;
  97332. /**
  97333. * Gets the value of D-pad up
  97334. */
  97335. /**
  97336. * Sets the value of D-pad up
  97337. */
  97338. dPadUp: number;
  97339. /**
  97340. * Gets the value of D-pad down
  97341. */
  97342. /**
  97343. * Sets the value of D-pad down
  97344. */
  97345. dPadDown: number;
  97346. /**
  97347. * Gets the value of D-pad left
  97348. */
  97349. /**
  97350. * Sets the value of D-pad left
  97351. */
  97352. dPadLeft: number;
  97353. /**
  97354. * Gets the value of D-pad right
  97355. */
  97356. /**
  97357. * Sets the value of D-pad right
  97358. */
  97359. dPadRight: number;
  97360. /**
  97361. * Force the gamepad to synchronize with device values
  97362. */
  97363. update(): void;
  97364. /**
  97365. * Disposes the gamepad
  97366. */
  97367. dispose(): void;
  97368. }
  97369. }
  97370. declare module BABYLON {
  97371. /**
  97372. * Base class of materials working in push mode in babylon JS
  97373. * @hidden
  97374. */
  97375. export class PushMaterial extends Material {
  97376. protected _activeEffect: Effect;
  97377. protected _normalMatrix: Matrix;
  97378. /**
  97379. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97380. * This means that the material can keep using a previous shader while a new one is being compiled.
  97381. * This is mostly used when shader parallel compilation is supported (true by default)
  97382. */
  97383. allowShaderHotSwapping: boolean;
  97384. constructor(name: string, scene: Scene);
  97385. getEffect(): Effect;
  97386. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97387. /**
  97388. * Binds the given world matrix to the active effect
  97389. *
  97390. * @param world the matrix to bind
  97391. */
  97392. bindOnlyWorldMatrix(world: Matrix): void;
  97393. /**
  97394. * Binds the given normal matrix to the active effect
  97395. *
  97396. * @param normalMatrix the matrix to bind
  97397. */
  97398. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97399. bind(world: Matrix, mesh?: Mesh): void;
  97400. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97401. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97402. }
  97403. }
  97404. declare module BABYLON {
  97405. /**
  97406. * This groups all the flags used to control the materials channel.
  97407. */
  97408. export class MaterialFlags {
  97409. private static _DiffuseTextureEnabled;
  97410. /**
  97411. * Are diffuse textures enabled in the application.
  97412. */
  97413. static DiffuseTextureEnabled: boolean;
  97414. private static _AmbientTextureEnabled;
  97415. /**
  97416. * Are ambient textures enabled in the application.
  97417. */
  97418. static AmbientTextureEnabled: boolean;
  97419. private static _OpacityTextureEnabled;
  97420. /**
  97421. * Are opacity textures enabled in the application.
  97422. */
  97423. static OpacityTextureEnabled: boolean;
  97424. private static _ReflectionTextureEnabled;
  97425. /**
  97426. * Are reflection textures enabled in the application.
  97427. */
  97428. static ReflectionTextureEnabled: boolean;
  97429. private static _EmissiveTextureEnabled;
  97430. /**
  97431. * Are emissive textures enabled in the application.
  97432. */
  97433. static EmissiveTextureEnabled: boolean;
  97434. private static _SpecularTextureEnabled;
  97435. /**
  97436. * Are specular textures enabled in the application.
  97437. */
  97438. static SpecularTextureEnabled: boolean;
  97439. private static _BumpTextureEnabled;
  97440. /**
  97441. * Are bump textures enabled in the application.
  97442. */
  97443. static BumpTextureEnabled: boolean;
  97444. private static _LightmapTextureEnabled;
  97445. /**
  97446. * Are lightmap textures enabled in the application.
  97447. */
  97448. static LightmapTextureEnabled: boolean;
  97449. private static _RefractionTextureEnabled;
  97450. /**
  97451. * Are refraction textures enabled in the application.
  97452. */
  97453. static RefractionTextureEnabled: boolean;
  97454. private static _ColorGradingTextureEnabled;
  97455. /**
  97456. * Are color grading textures enabled in the application.
  97457. */
  97458. static ColorGradingTextureEnabled: boolean;
  97459. private static _FresnelEnabled;
  97460. /**
  97461. * Are fresnels enabled in the application.
  97462. */
  97463. static FresnelEnabled: boolean;
  97464. private static _ClearCoatTextureEnabled;
  97465. /**
  97466. * Are clear coat textures enabled in the application.
  97467. */
  97468. static ClearCoatTextureEnabled: boolean;
  97469. private static _ClearCoatBumpTextureEnabled;
  97470. /**
  97471. * Are clear coat bump textures enabled in the application.
  97472. */
  97473. static ClearCoatBumpTextureEnabled: boolean;
  97474. private static _ClearCoatTintTextureEnabled;
  97475. /**
  97476. * Are clear coat tint textures enabled in the application.
  97477. */
  97478. static ClearCoatTintTextureEnabled: boolean;
  97479. private static _SheenTextureEnabled;
  97480. /**
  97481. * Are sheen textures enabled in the application.
  97482. */
  97483. static SheenTextureEnabled: boolean;
  97484. private static _AnisotropicTextureEnabled;
  97485. /**
  97486. * Are anisotropic textures enabled in the application.
  97487. */
  97488. static AnisotropicTextureEnabled: boolean;
  97489. private static _ThicknessTextureEnabled;
  97490. /**
  97491. * Are thickness textures enabled in the application.
  97492. */
  97493. static ThicknessTextureEnabled: boolean;
  97494. }
  97495. }
  97496. declare module BABYLON {
  97497. /** @hidden */
  97498. export var defaultFragmentDeclaration: {
  97499. name: string;
  97500. shader: string;
  97501. };
  97502. }
  97503. declare module BABYLON {
  97504. /** @hidden */
  97505. export var defaultUboDeclaration: {
  97506. name: string;
  97507. shader: string;
  97508. };
  97509. }
  97510. declare module BABYLON {
  97511. /** @hidden */
  97512. export var lightFragmentDeclaration: {
  97513. name: string;
  97514. shader: string;
  97515. };
  97516. }
  97517. declare module BABYLON {
  97518. /** @hidden */
  97519. export var lightUboDeclaration: {
  97520. name: string;
  97521. shader: string;
  97522. };
  97523. }
  97524. declare module BABYLON {
  97525. /** @hidden */
  97526. export var lightsFragmentFunctions: {
  97527. name: string;
  97528. shader: string;
  97529. };
  97530. }
  97531. declare module BABYLON {
  97532. /** @hidden */
  97533. export var shadowsFragmentFunctions: {
  97534. name: string;
  97535. shader: string;
  97536. };
  97537. }
  97538. declare module BABYLON {
  97539. /** @hidden */
  97540. export var fresnelFunction: {
  97541. name: string;
  97542. shader: string;
  97543. };
  97544. }
  97545. declare module BABYLON {
  97546. /** @hidden */
  97547. export var reflectionFunction: {
  97548. name: string;
  97549. shader: string;
  97550. };
  97551. }
  97552. declare module BABYLON {
  97553. /** @hidden */
  97554. export var bumpFragmentFunctions: {
  97555. name: string;
  97556. shader: string;
  97557. };
  97558. }
  97559. declare module BABYLON {
  97560. /** @hidden */
  97561. export var logDepthDeclaration: {
  97562. name: string;
  97563. shader: string;
  97564. };
  97565. }
  97566. declare module BABYLON {
  97567. /** @hidden */
  97568. export var bumpFragment: {
  97569. name: string;
  97570. shader: string;
  97571. };
  97572. }
  97573. declare module BABYLON {
  97574. /** @hidden */
  97575. export var depthPrePass: {
  97576. name: string;
  97577. shader: string;
  97578. };
  97579. }
  97580. declare module BABYLON {
  97581. /** @hidden */
  97582. export var lightFragment: {
  97583. name: string;
  97584. shader: string;
  97585. };
  97586. }
  97587. declare module BABYLON {
  97588. /** @hidden */
  97589. export var logDepthFragment: {
  97590. name: string;
  97591. shader: string;
  97592. };
  97593. }
  97594. declare module BABYLON {
  97595. /** @hidden */
  97596. export var defaultPixelShader: {
  97597. name: string;
  97598. shader: string;
  97599. };
  97600. }
  97601. declare module BABYLON {
  97602. /** @hidden */
  97603. export var defaultVertexDeclaration: {
  97604. name: string;
  97605. shader: string;
  97606. };
  97607. }
  97608. declare module BABYLON {
  97609. /** @hidden */
  97610. export var bumpVertexDeclaration: {
  97611. name: string;
  97612. shader: string;
  97613. };
  97614. }
  97615. declare module BABYLON {
  97616. /** @hidden */
  97617. export var bumpVertex: {
  97618. name: string;
  97619. shader: string;
  97620. };
  97621. }
  97622. declare module BABYLON {
  97623. /** @hidden */
  97624. export var fogVertex: {
  97625. name: string;
  97626. shader: string;
  97627. };
  97628. }
  97629. declare module BABYLON {
  97630. /** @hidden */
  97631. export var shadowsVertex: {
  97632. name: string;
  97633. shader: string;
  97634. };
  97635. }
  97636. declare module BABYLON {
  97637. /** @hidden */
  97638. export var pointCloudVertex: {
  97639. name: string;
  97640. shader: string;
  97641. };
  97642. }
  97643. declare module BABYLON {
  97644. /** @hidden */
  97645. export var logDepthVertex: {
  97646. name: string;
  97647. shader: string;
  97648. };
  97649. }
  97650. declare module BABYLON {
  97651. /** @hidden */
  97652. export var defaultVertexShader: {
  97653. name: string;
  97654. shader: string;
  97655. };
  97656. }
  97657. declare module BABYLON {
  97658. /** @hidden */
  97659. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97660. MAINUV1: boolean;
  97661. MAINUV2: boolean;
  97662. DIFFUSE: boolean;
  97663. DIFFUSEDIRECTUV: number;
  97664. AMBIENT: boolean;
  97665. AMBIENTDIRECTUV: number;
  97666. OPACITY: boolean;
  97667. OPACITYDIRECTUV: number;
  97668. OPACITYRGB: boolean;
  97669. REFLECTION: boolean;
  97670. EMISSIVE: boolean;
  97671. EMISSIVEDIRECTUV: number;
  97672. SPECULAR: boolean;
  97673. SPECULARDIRECTUV: number;
  97674. BUMP: boolean;
  97675. BUMPDIRECTUV: number;
  97676. PARALLAX: boolean;
  97677. PARALLAXOCCLUSION: boolean;
  97678. SPECULAROVERALPHA: boolean;
  97679. CLIPPLANE: boolean;
  97680. CLIPPLANE2: boolean;
  97681. CLIPPLANE3: boolean;
  97682. CLIPPLANE4: boolean;
  97683. ALPHATEST: boolean;
  97684. DEPTHPREPASS: boolean;
  97685. ALPHAFROMDIFFUSE: boolean;
  97686. POINTSIZE: boolean;
  97687. FOG: boolean;
  97688. SPECULARTERM: boolean;
  97689. DIFFUSEFRESNEL: boolean;
  97690. OPACITYFRESNEL: boolean;
  97691. REFLECTIONFRESNEL: boolean;
  97692. REFRACTIONFRESNEL: boolean;
  97693. EMISSIVEFRESNEL: boolean;
  97694. FRESNEL: boolean;
  97695. NORMAL: boolean;
  97696. UV1: boolean;
  97697. UV2: boolean;
  97698. VERTEXCOLOR: boolean;
  97699. VERTEXALPHA: boolean;
  97700. NUM_BONE_INFLUENCERS: number;
  97701. BonesPerMesh: number;
  97702. BONETEXTURE: boolean;
  97703. INSTANCES: boolean;
  97704. GLOSSINESS: boolean;
  97705. ROUGHNESS: boolean;
  97706. EMISSIVEASILLUMINATION: boolean;
  97707. LINKEMISSIVEWITHDIFFUSE: boolean;
  97708. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97709. LIGHTMAP: boolean;
  97710. LIGHTMAPDIRECTUV: number;
  97711. OBJECTSPACE_NORMALMAP: boolean;
  97712. USELIGHTMAPASSHADOWMAP: boolean;
  97713. REFLECTIONMAP_3D: boolean;
  97714. REFLECTIONMAP_SPHERICAL: boolean;
  97715. REFLECTIONMAP_PLANAR: boolean;
  97716. REFLECTIONMAP_CUBIC: boolean;
  97717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97718. REFLECTIONMAP_PROJECTION: boolean;
  97719. REFLECTIONMAP_SKYBOX: boolean;
  97720. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97721. REFLECTIONMAP_EXPLICIT: boolean;
  97722. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97723. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97724. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97725. INVERTCUBICMAP: boolean;
  97726. LOGARITHMICDEPTH: boolean;
  97727. REFRACTION: boolean;
  97728. REFRACTIONMAP_3D: boolean;
  97729. REFLECTIONOVERALPHA: boolean;
  97730. TWOSIDEDLIGHTING: boolean;
  97731. SHADOWFLOAT: boolean;
  97732. MORPHTARGETS: boolean;
  97733. MORPHTARGETS_NORMAL: boolean;
  97734. MORPHTARGETS_TANGENT: boolean;
  97735. NUM_MORPH_INFLUENCERS: number;
  97736. NONUNIFORMSCALING: boolean;
  97737. PREMULTIPLYALPHA: boolean;
  97738. IMAGEPROCESSING: boolean;
  97739. VIGNETTE: boolean;
  97740. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97741. VIGNETTEBLENDMODEOPAQUE: boolean;
  97742. TONEMAPPING: boolean;
  97743. TONEMAPPING_ACES: boolean;
  97744. CONTRAST: boolean;
  97745. COLORCURVES: boolean;
  97746. COLORGRADING: boolean;
  97747. COLORGRADING3D: boolean;
  97748. SAMPLER3DGREENDEPTH: boolean;
  97749. SAMPLER3DBGRMAP: boolean;
  97750. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97751. MULTIVIEW: boolean;
  97752. /**
  97753. * If the reflection texture on this material is in linear color space
  97754. * @hidden
  97755. */
  97756. IS_REFLECTION_LINEAR: boolean;
  97757. /**
  97758. * If the refraction texture on this material is in linear color space
  97759. * @hidden
  97760. */
  97761. IS_REFRACTION_LINEAR: boolean;
  97762. EXPOSURE: boolean;
  97763. constructor();
  97764. setReflectionMode(modeToEnable: string): void;
  97765. }
  97766. /**
  97767. * This is the default material used in Babylon. It is the best trade off between quality
  97768. * and performances.
  97769. * @see http://doc.babylonjs.com/babylon101/materials
  97770. */
  97771. export class StandardMaterial extends PushMaterial {
  97772. private _diffuseTexture;
  97773. /**
  97774. * The basic texture of the material as viewed under a light.
  97775. */
  97776. diffuseTexture: Nullable<BaseTexture>;
  97777. private _ambientTexture;
  97778. /**
  97779. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97780. */
  97781. ambientTexture: Nullable<BaseTexture>;
  97782. private _opacityTexture;
  97783. /**
  97784. * Define the transparency of the material from a texture.
  97785. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97786. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97787. */
  97788. opacityTexture: Nullable<BaseTexture>;
  97789. private _reflectionTexture;
  97790. /**
  97791. * Define the texture used to display the reflection.
  97792. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97793. */
  97794. reflectionTexture: Nullable<BaseTexture>;
  97795. private _emissiveTexture;
  97796. /**
  97797. * Define texture of the material as if self lit.
  97798. * This will be mixed in the final result even in the absence of light.
  97799. */
  97800. emissiveTexture: Nullable<BaseTexture>;
  97801. private _specularTexture;
  97802. /**
  97803. * Define how the color and intensity of the highlight given by the light in the material.
  97804. */
  97805. specularTexture: Nullable<BaseTexture>;
  97806. private _bumpTexture;
  97807. /**
  97808. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97809. * 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.
  97810. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97811. */
  97812. bumpTexture: Nullable<BaseTexture>;
  97813. private _lightmapTexture;
  97814. /**
  97815. * Complex lighting can be computationally expensive to compute at runtime.
  97816. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97817. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97818. */
  97819. lightmapTexture: Nullable<BaseTexture>;
  97820. private _refractionTexture;
  97821. /**
  97822. * Define the texture used to display the refraction.
  97823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97824. */
  97825. refractionTexture: Nullable<BaseTexture>;
  97826. /**
  97827. * The color of the material lit by the environmental background lighting.
  97828. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97829. */
  97830. ambientColor: Color3;
  97831. /**
  97832. * The basic color of the material as viewed under a light.
  97833. */
  97834. diffuseColor: Color3;
  97835. /**
  97836. * Define how the color and intensity of the highlight given by the light in the material.
  97837. */
  97838. specularColor: Color3;
  97839. /**
  97840. * Define the color of the material as if self lit.
  97841. * This will be mixed in the final result even in the absence of light.
  97842. */
  97843. emissiveColor: Color3;
  97844. /**
  97845. * Defines how sharp are the highlights in the material.
  97846. * The bigger the value the sharper giving a more glossy feeling to the result.
  97847. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97848. */
  97849. specularPower: number;
  97850. private _useAlphaFromDiffuseTexture;
  97851. /**
  97852. * Does the transparency come from the diffuse texture alpha channel.
  97853. */
  97854. useAlphaFromDiffuseTexture: boolean;
  97855. private _useEmissiveAsIllumination;
  97856. /**
  97857. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97858. */
  97859. useEmissiveAsIllumination: boolean;
  97860. private _linkEmissiveWithDiffuse;
  97861. /**
  97862. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97863. * the emissive level when the final color is close to one.
  97864. */
  97865. linkEmissiveWithDiffuse: boolean;
  97866. private _useSpecularOverAlpha;
  97867. /**
  97868. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97869. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97870. */
  97871. useSpecularOverAlpha: boolean;
  97872. private _useReflectionOverAlpha;
  97873. /**
  97874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97876. */
  97877. useReflectionOverAlpha: boolean;
  97878. private _disableLighting;
  97879. /**
  97880. * Does lights from the scene impacts this material.
  97881. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97882. */
  97883. disableLighting: boolean;
  97884. private _useObjectSpaceNormalMap;
  97885. /**
  97886. * Allows using an object space normal map (instead of tangent space).
  97887. */
  97888. useObjectSpaceNormalMap: boolean;
  97889. private _useParallax;
  97890. /**
  97891. * Is parallax enabled or not.
  97892. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97893. */
  97894. useParallax: boolean;
  97895. private _useParallaxOcclusion;
  97896. /**
  97897. * Is parallax occlusion enabled or not.
  97898. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97899. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97900. */
  97901. useParallaxOcclusion: boolean;
  97902. /**
  97903. * 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.
  97904. */
  97905. parallaxScaleBias: number;
  97906. private _roughness;
  97907. /**
  97908. * Helps to define how blurry the reflections should appears in the material.
  97909. */
  97910. roughness: number;
  97911. /**
  97912. * In case of refraction, define the value of the indice of refraction.
  97913. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97914. */
  97915. indexOfRefraction: number;
  97916. /**
  97917. * Invert the refraction texture alongside the y axis.
  97918. * It can be useful with procedural textures or probe for instance.
  97919. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97920. */
  97921. invertRefractionY: boolean;
  97922. /**
  97923. * Defines the alpha limits in alpha test mode.
  97924. */
  97925. alphaCutOff: number;
  97926. private _useLightmapAsShadowmap;
  97927. /**
  97928. * In case of light mapping, define whether the map contains light or shadow informations.
  97929. */
  97930. useLightmapAsShadowmap: boolean;
  97931. private _diffuseFresnelParameters;
  97932. /**
  97933. * Define the diffuse fresnel parameters of the material.
  97934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97935. */
  97936. diffuseFresnelParameters: FresnelParameters;
  97937. private _opacityFresnelParameters;
  97938. /**
  97939. * Define the opacity fresnel parameters of the material.
  97940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97941. */
  97942. opacityFresnelParameters: FresnelParameters;
  97943. private _reflectionFresnelParameters;
  97944. /**
  97945. * Define the reflection fresnel parameters of the material.
  97946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97947. */
  97948. reflectionFresnelParameters: FresnelParameters;
  97949. private _refractionFresnelParameters;
  97950. /**
  97951. * Define the refraction fresnel parameters of the material.
  97952. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97953. */
  97954. refractionFresnelParameters: FresnelParameters;
  97955. private _emissiveFresnelParameters;
  97956. /**
  97957. * Define the emissive fresnel parameters of the material.
  97958. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97959. */
  97960. emissiveFresnelParameters: FresnelParameters;
  97961. private _useReflectionFresnelFromSpecular;
  97962. /**
  97963. * If true automatically deducts the fresnels values from the material specularity.
  97964. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97965. */
  97966. useReflectionFresnelFromSpecular: boolean;
  97967. private _useGlossinessFromSpecularMapAlpha;
  97968. /**
  97969. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97970. */
  97971. useGlossinessFromSpecularMapAlpha: boolean;
  97972. private _maxSimultaneousLights;
  97973. /**
  97974. * Defines the maximum number of lights that can be used in the material
  97975. */
  97976. maxSimultaneousLights: number;
  97977. private _invertNormalMapX;
  97978. /**
  97979. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97980. */
  97981. invertNormalMapX: boolean;
  97982. private _invertNormalMapY;
  97983. /**
  97984. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97985. */
  97986. invertNormalMapY: boolean;
  97987. private _twoSidedLighting;
  97988. /**
  97989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97990. */
  97991. twoSidedLighting: boolean;
  97992. /**
  97993. * Default configuration related to image processing available in the standard Material.
  97994. */
  97995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97996. /**
  97997. * Gets the image processing configuration used either in this material.
  97998. */
  97999. /**
  98000. * Sets the Default image processing configuration used either in the this material.
  98001. *
  98002. * If sets to null, the scene one is in use.
  98003. */
  98004. imageProcessingConfiguration: ImageProcessingConfiguration;
  98005. /**
  98006. * Keep track of the image processing observer to allow dispose and replace.
  98007. */
  98008. private _imageProcessingObserver;
  98009. /**
  98010. * Attaches a new image processing configuration to the Standard Material.
  98011. * @param configuration
  98012. */
  98013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98014. /**
  98015. * Gets wether the color curves effect is enabled.
  98016. */
  98017. /**
  98018. * Sets wether the color curves effect is enabled.
  98019. */
  98020. cameraColorCurvesEnabled: boolean;
  98021. /**
  98022. * Gets wether the color grading effect is enabled.
  98023. */
  98024. /**
  98025. * Gets wether the color grading effect is enabled.
  98026. */
  98027. cameraColorGradingEnabled: boolean;
  98028. /**
  98029. * Gets wether tonemapping is enabled or not.
  98030. */
  98031. /**
  98032. * Sets wether tonemapping is enabled or not
  98033. */
  98034. cameraToneMappingEnabled: boolean;
  98035. /**
  98036. * The camera exposure used on this material.
  98037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98038. * This corresponds to a photographic exposure.
  98039. */
  98040. /**
  98041. * The camera exposure used on this material.
  98042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98043. * This corresponds to a photographic exposure.
  98044. */
  98045. cameraExposure: number;
  98046. /**
  98047. * Gets The camera contrast used on this material.
  98048. */
  98049. /**
  98050. * Sets The camera contrast used on this material.
  98051. */
  98052. cameraContrast: number;
  98053. /**
  98054. * Gets the Color Grading 2D Lookup Texture.
  98055. */
  98056. /**
  98057. * Sets the Color Grading 2D Lookup Texture.
  98058. */
  98059. cameraColorGradingTexture: Nullable<BaseTexture>;
  98060. /**
  98061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98063. * 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;
  98064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98065. */
  98066. /**
  98067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98069. * 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;
  98070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98071. */
  98072. cameraColorCurves: Nullable<ColorCurves>;
  98073. /**
  98074. * Custom callback helping to override the default shader used in the material.
  98075. */
  98076. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98077. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98078. protected _worldViewProjectionMatrix: Matrix;
  98079. protected _globalAmbientColor: Color3;
  98080. protected _useLogarithmicDepth: boolean;
  98081. /**
  98082. * Instantiates a new standard material.
  98083. * This is the default material used in Babylon. It is the best trade off between quality
  98084. * and performances.
  98085. * @see http://doc.babylonjs.com/babylon101/materials
  98086. * @param name Define the name of the material in the scene
  98087. * @param scene Define the scene the material belong to
  98088. */
  98089. constructor(name: string, scene: Scene);
  98090. /**
  98091. * Gets a boolean indicating that current material needs to register RTT
  98092. */
  98093. readonly hasRenderTargetTextures: boolean;
  98094. /**
  98095. * Gets the current class name of the material e.g. "StandardMaterial"
  98096. * Mainly use in serialization.
  98097. * @returns the class name
  98098. */
  98099. getClassName(): string;
  98100. /**
  98101. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98102. * You can try switching to logarithmic depth.
  98103. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98104. */
  98105. useLogarithmicDepth: boolean;
  98106. /**
  98107. * Specifies if the material will require alpha blending
  98108. * @returns a boolean specifying if alpha blending is needed
  98109. */
  98110. needAlphaBlending(): boolean;
  98111. /**
  98112. * Specifies if this material should be rendered in alpha test mode
  98113. * @returns a boolean specifying if an alpha test is needed.
  98114. */
  98115. needAlphaTesting(): boolean;
  98116. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98117. /**
  98118. * Get the texture used for alpha test purpose.
  98119. * @returns the diffuse texture in case of the standard material.
  98120. */
  98121. getAlphaTestTexture(): Nullable<BaseTexture>;
  98122. /**
  98123. * Get if the submesh is ready to be used and all its information available.
  98124. * Child classes can use it to update shaders
  98125. * @param mesh defines the mesh to check
  98126. * @param subMesh defines which submesh to check
  98127. * @param useInstances specifies that instances should be used
  98128. * @returns a boolean indicating that the submesh is ready or not
  98129. */
  98130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98131. /**
  98132. * Builds the material UBO layouts.
  98133. * Used internally during the effect preparation.
  98134. */
  98135. buildUniformLayout(): void;
  98136. /**
  98137. * Unbinds the material from the mesh
  98138. */
  98139. unbind(): void;
  98140. /**
  98141. * Binds the submesh to this material by preparing the effect and shader to draw
  98142. * @param world defines the world transformation matrix
  98143. * @param mesh defines the mesh containing the submesh
  98144. * @param subMesh defines the submesh to bind the material to
  98145. */
  98146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98147. /**
  98148. * Get the list of animatables in the material.
  98149. * @returns the list of animatables object used in the material
  98150. */
  98151. getAnimatables(): IAnimatable[];
  98152. /**
  98153. * Gets the active textures from the material
  98154. * @returns an array of textures
  98155. */
  98156. getActiveTextures(): BaseTexture[];
  98157. /**
  98158. * Specifies if the material uses a texture
  98159. * @param texture defines the texture to check against the material
  98160. * @returns a boolean specifying if the material uses the texture
  98161. */
  98162. hasTexture(texture: BaseTexture): boolean;
  98163. /**
  98164. * Disposes the material
  98165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98167. */
  98168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98169. /**
  98170. * Makes a duplicate of the material, and gives it a new name
  98171. * @param name defines the new name for the duplicated material
  98172. * @returns the cloned material
  98173. */
  98174. clone(name: string): StandardMaterial;
  98175. /**
  98176. * Serializes this material in a JSON representation
  98177. * @returns the serialized material object
  98178. */
  98179. serialize(): any;
  98180. /**
  98181. * Creates a standard material from parsed material data
  98182. * @param source defines the JSON representation of the material
  98183. * @param scene defines the hosting scene
  98184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98185. * @returns a new standard material
  98186. */
  98187. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98188. /**
  98189. * Are diffuse textures enabled in the application.
  98190. */
  98191. static DiffuseTextureEnabled: boolean;
  98192. /**
  98193. * Are ambient textures enabled in the application.
  98194. */
  98195. static AmbientTextureEnabled: boolean;
  98196. /**
  98197. * Are opacity textures enabled in the application.
  98198. */
  98199. static OpacityTextureEnabled: boolean;
  98200. /**
  98201. * Are reflection textures enabled in the application.
  98202. */
  98203. static ReflectionTextureEnabled: boolean;
  98204. /**
  98205. * Are emissive textures enabled in the application.
  98206. */
  98207. static EmissiveTextureEnabled: boolean;
  98208. /**
  98209. * Are specular textures enabled in the application.
  98210. */
  98211. static SpecularTextureEnabled: boolean;
  98212. /**
  98213. * Are bump textures enabled in the application.
  98214. */
  98215. static BumpTextureEnabled: boolean;
  98216. /**
  98217. * Are lightmap textures enabled in the application.
  98218. */
  98219. static LightmapTextureEnabled: boolean;
  98220. /**
  98221. * Are refraction textures enabled in the application.
  98222. */
  98223. static RefractionTextureEnabled: boolean;
  98224. /**
  98225. * Are color grading textures enabled in the application.
  98226. */
  98227. static ColorGradingTextureEnabled: boolean;
  98228. /**
  98229. * Are fresnels enabled in the application.
  98230. */
  98231. static FresnelEnabled: boolean;
  98232. }
  98233. }
  98234. declare module BABYLON {
  98235. /**
  98236. * A class extending Texture allowing drawing on a texture
  98237. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98238. */
  98239. export class DynamicTexture extends Texture {
  98240. private _generateMipMaps;
  98241. private _canvas;
  98242. private _context;
  98243. private _engine;
  98244. /**
  98245. * Creates a DynamicTexture
  98246. * @param name defines the name of the texture
  98247. * @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
  98248. * @param scene defines the scene where you want the texture
  98249. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98251. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98252. */
  98253. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98254. /**
  98255. * Get the current class name of the texture useful for serialization or dynamic coding.
  98256. * @returns "DynamicTexture"
  98257. */
  98258. getClassName(): string;
  98259. /**
  98260. * Gets the current state of canRescale
  98261. */
  98262. readonly canRescale: boolean;
  98263. private _recreate;
  98264. /**
  98265. * Scales the texture
  98266. * @param ratio the scale factor to apply to both width and height
  98267. */
  98268. scale(ratio: number): void;
  98269. /**
  98270. * Resizes the texture
  98271. * @param width the new width
  98272. * @param height the new height
  98273. */
  98274. scaleTo(width: number, height: number): void;
  98275. /**
  98276. * Gets the context of the canvas used by the texture
  98277. * @returns the canvas context of the dynamic texture
  98278. */
  98279. getContext(): CanvasRenderingContext2D;
  98280. /**
  98281. * Clears the texture
  98282. */
  98283. clear(): void;
  98284. /**
  98285. * Updates the texture
  98286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98287. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98288. */
  98289. update(invertY?: boolean, premulAlpha?: boolean): void;
  98290. /**
  98291. * Draws text onto the texture
  98292. * @param text defines the text to be drawn
  98293. * @param x defines the placement of the text from the left
  98294. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98295. * @param font defines the font to be used with font-style, font-size, font-name
  98296. * @param color defines the color used for the text
  98297. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98299. * @param update defines whether texture is immediately update (default is true)
  98300. */
  98301. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98302. /**
  98303. * Clones the texture
  98304. * @returns the clone of the texture.
  98305. */
  98306. clone(): DynamicTexture;
  98307. /**
  98308. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98309. * @returns a serialized dynamic texture object
  98310. */
  98311. serialize(): any;
  98312. /** @hidden */
  98313. _rebuild(): void;
  98314. }
  98315. }
  98316. declare module BABYLON {
  98317. /** @hidden */
  98318. export var imageProcessingPixelShader: {
  98319. name: string;
  98320. shader: string;
  98321. };
  98322. }
  98323. declare module BABYLON {
  98324. /**
  98325. * ImageProcessingPostProcess
  98326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98327. */
  98328. export class ImageProcessingPostProcess extends PostProcess {
  98329. /**
  98330. * Default configuration related to image processing available in the PBR Material.
  98331. */
  98332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98333. /**
  98334. * Gets the image processing configuration used either in this material.
  98335. */
  98336. /**
  98337. * Sets the Default image processing configuration used either in the this material.
  98338. *
  98339. * If sets to null, the scene one is in use.
  98340. */
  98341. imageProcessingConfiguration: ImageProcessingConfiguration;
  98342. /**
  98343. * Keep track of the image processing observer to allow dispose and replace.
  98344. */
  98345. private _imageProcessingObserver;
  98346. /**
  98347. * Attaches a new image processing configuration to the PBR Material.
  98348. * @param configuration
  98349. */
  98350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98351. /**
  98352. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98353. */
  98354. /**
  98355. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98356. */
  98357. colorCurves: Nullable<ColorCurves>;
  98358. /**
  98359. * Gets wether the color curves effect is enabled.
  98360. */
  98361. /**
  98362. * Sets wether the color curves effect is enabled.
  98363. */
  98364. colorCurvesEnabled: boolean;
  98365. /**
  98366. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98367. */
  98368. /**
  98369. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98370. */
  98371. colorGradingTexture: Nullable<BaseTexture>;
  98372. /**
  98373. * Gets wether the color grading effect is enabled.
  98374. */
  98375. /**
  98376. * Gets wether the color grading effect is enabled.
  98377. */
  98378. colorGradingEnabled: boolean;
  98379. /**
  98380. * Gets exposure used in the effect.
  98381. */
  98382. /**
  98383. * Sets exposure used in the effect.
  98384. */
  98385. exposure: number;
  98386. /**
  98387. * Gets wether tonemapping is enabled or not.
  98388. */
  98389. /**
  98390. * Sets wether tonemapping is enabled or not
  98391. */
  98392. toneMappingEnabled: boolean;
  98393. /**
  98394. * Gets the type of tone mapping effect.
  98395. */
  98396. /**
  98397. * Sets the type of tone mapping effect.
  98398. */
  98399. toneMappingType: number;
  98400. /**
  98401. * Gets contrast used in the effect.
  98402. */
  98403. /**
  98404. * Sets contrast used in the effect.
  98405. */
  98406. contrast: number;
  98407. /**
  98408. * Gets Vignette stretch size.
  98409. */
  98410. /**
  98411. * Sets Vignette stretch size.
  98412. */
  98413. vignetteStretch: number;
  98414. /**
  98415. * Gets Vignette centre X Offset.
  98416. */
  98417. /**
  98418. * Sets Vignette centre X Offset.
  98419. */
  98420. vignetteCentreX: number;
  98421. /**
  98422. * Gets Vignette centre Y Offset.
  98423. */
  98424. /**
  98425. * Sets Vignette centre Y Offset.
  98426. */
  98427. vignetteCentreY: number;
  98428. /**
  98429. * Gets Vignette weight or intensity of the vignette effect.
  98430. */
  98431. /**
  98432. * Sets Vignette weight or intensity of the vignette effect.
  98433. */
  98434. vignetteWeight: number;
  98435. /**
  98436. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98437. * if vignetteEnabled is set to true.
  98438. */
  98439. /**
  98440. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98441. * if vignetteEnabled is set to true.
  98442. */
  98443. vignetteColor: Color4;
  98444. /**
  98445. * Gets Camera field of view used by the Vignette effect.
  98446. */
  98447. /**
  98448. * Sets Camera field of view used by the Vignette effect.
  98449. */
  98450. vignetteCameraFov: number;
  98451. /**
  98452. * Gets the vignette blend mode allowing different kind of effect.
  98453. */
  98454. /**
  98455. * Sets the vignette blend mode allowing different kind of effect.
  98456. */
  98457. vignetteBlendMode: number;
  98458. /**
  98459. * Gets wether the vignette effect is enabled.
  98460. */
  98461. /**
  98462. * Sets wether the vignette effect is enabled.
  98463. */
  98464. vignetteEnabled: boolean;
  98465. private _fromLinearSpace;
  98466. /**
  98467. * Gets wether the input of the processing is in Gamma or Linear Space.
  98468. */
  98469. /**
  98470. * Sets wether the input of the processing is in Gamma or Linear Space.
  98471. */
  98472. fromLinearSpace: boolean;
  98473. /**
  98474. * Defines cache preventing GC.
  98475. */
  98476. private _defines;
  98477. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98478. /**
  98479. * "ImageProcessingPostProcess"
  98480. * @returns "ImageProcessingPostProcess"
  98481. */
  98482. getClassName(): string;
  98483. protected _updateParameters(): void;
  98484. dispose(camera?: Camera): void;
  98485. }
  98486. }
  98487. declare module BABYLON {
  98488. /**
  98489. * Class containing static functions to help procedurally build meshes
  98490. */
  98491. export class GroundBuilder {
  98492. /**
  98493. * Creates a ground mesh
  98494. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98495. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98497. * @param name defines the name of the mesh
  98498. * @param options defines the options used to create the mesh
  98499. * @param scene defines the hosting scene
  98500. * @returns the ground mesh
  98501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98502. */
  98503. static CreateGround(name: string, options: {
  98504. width?: number;
  98505. height?: number;
  98506. subdivisions?: number;
  98507. subdivisionsX?: number;
  98508. subdivisionsY?: number;
  98509. updatable?: boolean;
  98510. }, scene: any): Mesh;
  98511. /**
  98512. * Creates a tiled ground mesh
  98513. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98514. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98515. * * 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
  98516. * * 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
  98517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98518. * @param name defines the name of the mesh
  98519. * @param options defines the options used to create the mesh
  98520. * @param scene defines the hosting scene
  98521. * @returns the tiled ground mesh
  98522. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98523. */
  98524. static CreateTiledGround(name: string, options: {
  98525. xmin: number;
  98526. zmin: number;
  98527. xmax: number;
  98528. zmax: number;
  98529. subdivisions?: {
  98530. w: number;
  98531. h: number;
  98532. };
  98533. precision?: {
  98534. w: number;
  98535. h: number;
  98536. };
  98537. updatable?: boolean;
  98538. }, scene?: Nullable<Scene>): Mesh;
  98539. /**
  98540. * Creates a ground mesh from a height map
  98541. * * The parameter `url` sets the URL of the height map image resource.
  98542. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98543. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98544. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98545. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98546. * * 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.
  98547. * * 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).
  98548. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98550. * @param name defines the name of the mesh
  98551. * @param url defines the url to the height map
  98552. * @param options defines the options used to create the mesh
  98553. * @param scene defines the hosting scene
  98554. * @returns the ground mesh
  98555. * @see https://doc.babylonjs.com/babylon101/height_map
  98556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98557. */
  98558. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98559. width?: number;
  98560. height?: number;
  98561. subdivisions?: number;
  98562. minHeight?: number;
  98563. maxHeight?: number;
  98564. colorFilter?: Color3;
  98565. alphaFilter?: number;
  98566. updatable?: boolean;
  98567. onReady?: (mesh: GroundMesh) => void;
  98568. }, scene?: Nullable<Scene>): GroundMesh;
  98569. }
  98570. }
  98571. declare module BABYLON {
  98572. /**
  98573. * Class containing static functions to help procedurally build meshes
  98574. */
  98575. export class TorusBuilder {
  98576. /**
  98577. * Creates a torus mesh
  98578. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98579. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98580. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98584. * @param name defines the name of the mesh
  98585. * @param options defines the options used to create the mesh
  98586. * @param scene defines the hosting scene
  98587. * @returns the torus mesh
  98588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98589. */
  98590. static CreateTorus(name: string, options: {
  98591. diameter?: number;
  98592. thickness?: number;
  98593. tessellation?: number;
  98594. updatable?: boolean;
  98595. sideOrientation?: number;
  98596. frontUVs?: Vector4;
  98597. backUVs?: Vector4;
  98598. }, scene: any): Mesh;
  98599. }
  98600. }
  98601. declare module BABYLON {
  98602. /**
  98603. * Class containing static functions to help procedurally build meshes
  98604. */
  98605. export class CylinderBuilder {
  98606. /**
  98607. * Creates a cylinder or a cone mesh
  98608. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98609. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98610. * * 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.
  98611. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98612. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98613. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98614. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98616. * * 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).
  98617. * * 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
  98618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98619. * * 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
  98620. * * 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.
  98621. * * If `enclose` is false, a ring surface is one element.
  98622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98623. * * 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
  98624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98627. * @param name defines the name of the mesh
  98628. * @param options defines the options used to create the mesh
  98629. * @param scene defines the hosting scene
  98630. * @returns the cylinder mesh
  98631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98632. */
  98633. static CreateCylinder(name: string, options: {
  98634. height?: number;
  98635. diameterTop?: number;
  98636. diameterBottom?: number;
  98637. diameter?: number;
  98638. tessellation?: number;
  98639. subdivisions?: number;
  98640. arc?: number;
  98641. faceColors?: Color4[];
  98642. faceUV?: Vector4[];
  98643. updatable?: boolean;
  98644. hasRings?: boolean;
  98645. enclose?: boolean;
  98646. sideOrientation?: number;
  98647. frontUVs?: Vector4;
  98648. backUVs?: Vector4;
  98649. }, scene: any): Mesh;
  98650. }
  98651. }
  98652. declare module BABYLON {
  98653. /**
  98654. * Manager for handling gamepads
  98655. */
  98656. export class GamepadManager {
  98657. private _scene?;
  98658. private _babylonGamepads;
  98659. private _oneGamepadConnected;
  98660. /** @hidden */
  98661. _isMonitoring: boolean;
  98662. private _gamepadEventSupported;
  98663. private _gamepadSupport;
  98664. /**
  98665. * observable to be triggered when the gamepad controller has been connected
  98666. */
  98667. onGamepadConnectedObservable: Observable<Gamepad>;
  98668. /**
  98669. * observable to be triggered when the gamepad controller has been disconnected
  98670. */
  98671. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98672. private _onGamepadConnectedEvent;
  98673. private _onGamepadDisconnectedEvent;
  98674. /**
  98675. * Initializes the gamepad manager
  98676. * @param _scene BabylonJS scene
  98677. */
  98678. constructor(_scene?: Scene | undefined);
  98679. /**
  98680. * The gamepads in the game pad manager
  98681. */
  98682. readonly gamepads: Gamepad[];
  98683. /**
  98684. * Get the gamepad controllers based on type
  98685. * @param type The type of gamepad controller
  98686. * @returns Nullable gamepad
  98687. */
  98688. getGamepadByType(type?: number): Nullable<Gamepad>;
  98689. /**
  98690. * Disposes the gamepad manager
  98691. */
  98692. dispose(): void;
  98693. private _addNewGamepad;
  98694. private _startMonitoringGamepads;
  98695. private _stopMonitoringGamepads;
  98696. /** @hidden */
  98697. _checkGamepadsStatus(): void;
  98698. private _updateGamepadObjects;
  98699. }
  98700. }
  98701. declare module BABYLON {
  98702. interface Scene {
  98703. /** @hidden */
  98704. _gamepadManager: Nullable<GamepadManager>;
  98705. /**
  98706. * Gets the gamepad manager associated with the scene
  98707. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98708. */
  98709. gamepadManager: GamepadManager;
  98710. }
  98711. /**
  98712. * Interface representing a free camera inputs manager
  98713. */
  98714. interface FreeCameraInputsManager {
  98715. /**
  98716. * Adds gamepad input support to the FreeCameraInputsManager.
  98717. * @returns the FreeCameraInputsManager
  98718. */
  98719. addGamepad(): FreeCameraInputsManager;
  98720. }
  98721. /**
  98722. * Interface representing an arc rotate camera inputs manager
  98723. */
  98724. interface ArcRotateCameraInputsManager {
  98725. /**
  98726. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98727. * @returns the camera inputs manager
  98728. */
  98729. addGamepad(): ArcRotateCameraInputsManager;
  98730. }
  98731. /**
  98732. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98733. */
  98734. export class GamepadSystemSceneComponent implements ISceneComponent {
  98735. /**
  98736. * The component name helpfull to identify the component in the list of scene components.
  98737. */
  98738. readonly name: string;
  98739. /**
  98740. * The scene the component belongs to.
  98741. */
  98742. scene: Scene;
  98743. /**
  98744. * Creates a new instance of the component for the given scene
  98745. * @param scene Defines the scene to register the component in
  98746. */
  98747. constructor(scene: Scene);
  98748. /**
  98749. * Registers the component in a given scene
  98750. */
  98751. register(): void;
  98752. /**
  98753. * Rebuilds the elements related to this component in case of
  98754. * context lost for instance.
  98755. */
  98756. rebuild(): void;
  98757. /**
  98758. * Disposes the component and the associated ressources
  98759. */
  98760. dispose(): void;
  98761. private _beforeCameraUpdate;
  98762. }
  98763. }
  98764. declare module BABYLON {
  98765. /**
  98766. * Options to modify the vr teleportation behavior.
  98767. */
  98768. export interface VRTeleportationOptions {
  98769. /**
  98770. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98771. */
  98772. floorMeshName?: string;
  98773. /**
  98774. * A list of meshes to be used as the teleportation floor. (default: empty)
  98775. */
  98776. floorMeshes?: Mesh[];
  98777. }
  98778. /**
  98779. * Options to modify the vr experience helper's behavior.
  98780. */
  98781. export interface VRExperienceHelperOptions extends WebVROptions {
  98782. /**
  98783. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98784. */
  98785. createDeviceOrientationCamera?: boolean;
  98786. /**
  98787. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98788. */
  98789. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98790. /**
  98791. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98792. */
  98793. laserToggle?: boolean;
  98794. /**
  98795. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98796. */
  98797. floorMeshes?: Mesh[];
  98798. /**
  98799. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98800. */
  98801. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98802. }
  98803. /**
  98804. * Event containing information after VR has been entered
  98805. */
  98806. export class OnAfterEnteringVRObservableEvent {
  98807. /**
  98808. * If entering vr was successful
  98809. */
  98810. success: boolean;
  98811. }
  98812. /**
  98813. * Helps to quickly add VR support to an existing scene.
  98814. * See http://doc.babylonjs.com/how_to/webvr_helper
  98815. */
  98816. export class VRExperienceHelper {
  98817. /** Options to modify the vr experience helper's behavior. */
  98818. webVROptions: VRExperienceHelperOptions;
  98819. private _scene;
  98820. private _position;
  98821. private _btnVR;
  98822. private _btnVRDisplayed;
  98823. private _webVRsupported;
  98824. private _webVRready;
  98825. private _webVRrequesting;
  98826. private _webVRpresenting;
  98827. private _hasEnteredVR;
  98828. private _fullscreenVRpresenting;
  98829. private _canvas;
  98830. private _webVRCamera;
  98831. private _vrDeviceOrientationCamera;
  98832. private _deviceOrientationCamera;
  98833. private _existingCamera;
  98834. private _onKeyDown;
  98835. private _onVrDisplayPresentChange;
  98836. private _onVRDisplayChanged;
  98837. private _onVRRequestPresentStart;
  98838. private _onVRRequestPresentComplete;
  98839. /**
  98840. * Observable raised right before entering VR.
  98841. */
  98842. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98843. /**
  98844. * Observable raised when entering VR has completed.
  98845. */
  98846. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98847. /**
  98848. * Observable raised when exiting VR.
  98849. */
  98850. onExitingVRObservable: Observable<VRExperienceHelper>;
  98851. /**
  98852. * Observable raised when controller mesh is loaded.
  98853. */
  98854. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98855. /** Return this.onEnteringVRObservable
  98856. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98857. */
  98858. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98859. /** Return this.onExitingVRObservable
  98860. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98861. */
  98862. readonly onExitingVR: Observable<VRExperienceHelper>;
  98863. /** Return this.onControllerMeshLoadedObservable
  98864. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98865. */
  98866. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98867. private _rayLength;
  98868. private _useCustomVRButton;
  98869. private _teleportationRequested;
  98870. private _teleportActive;
  98871. private _floorMeshName;
  98872. private _floorMeshesCollection;
  98873. private _rotationAllowed;
  98874. private _teleportBackwardsVector;
  98875. private _teleportationTarget;
  98876. private _isDefaultTeleportationTarget;
  98877. private _postProcessMove;
  98878. private _teleportationFillColor;
  98879. private _teleportationBorderColor;
  98880. private _rotationAngle;
  98881. private _haloCenter;
  98882. private _cameraGazer;
  98883. private _padSensibilityUp;
  98884. private _padSensibilityDown;
  98885. private _leftController;
  98886. private _rightController;
  98887. /**
  98888. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98889. */
  98890. onNewMeshSelected: Observable<AbstractMesh>;
  98891. /**
  98892. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98893. */
  98894. onNewMeshPicked: Observable<PickingInfo>;
  98895. private _circleEase;
  98896. /**
  98897. * Observable raised before camera teleportation
  98898. */
  98899. onBeforeCameraTeleport: Observable<Vector3>;
  98900. /**
  98901. * Observable raised after camera teleportation
  98902. */
  98903. onAfterCameraTeleport: Observable<Vector3>;
  98904. /**
  98905. * Observable raised when current selected mesh gets unselected
  98906. */
  98907. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98908. private _raySelectionPredicate;
  98909. /**
  98910. * To be optionaly changed by user to define custom ray selection
  98911. */
  98912. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98913. /**
  98914. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98915. */
  98916. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98917. /**
  98918. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98919. */
  98920. teleportationEnabled: boolean;
  98921. private _defaultHeight;
  98922. private _teleportationInitialized;
  98923. private _interactionsEnabled;
  98924. private _interactionsRequested;
  98925. private _displayGaze;
  98926. private _displayLaserPointer;
  98927. /**
  98928. * The mesh used to display where the user is going to teleport.
  98929. */
  98930. /**
  98931. * Sets the mesh to be used to display where the user is going to teleport.
  98932. */
  98933. teleportationTarget: Mesh;
  98934. /**
  98935. * 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
  98936. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98937. * See http://doc.babylonjs.com/resources/baking_transformations
  98938. */
  98939. gazeTrackerMesh: Mesh;
  98940. /**
  98941. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98942. */
  98943. updateGazeTrackerScale: boolean;
  98944. /**
  98945. * If the gaze trackers color should be updated when selecting meshes
  98946. */
  98947. updateGazeTrackerColor: boolean;
  98948. /**
  98949. * The gaze tracking mesh corresponding to the left controller
  98950. */
  98951. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98952. /**
  98953. * The gaze tracking mesh corresponding to the right controller
  98954. */
  98955. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98956. /**
  98957. * If the ray of the gaze should be displayed.
  98958. */
  98959. /**
  98960. * Sets if the ray of the gaze should be displayed.
  98961. */
  98962. displayGaze: boolean;
  98963. /**
  98964. * If the ray of the LaserPointer should be displayed.
  98965. */
  98966. /**
  98967. * Sets if the ray of the LaserPointer should be displayed.
  98968. */
  98969. displayLaserPointer: boolean;
  98970. /**
  98971. * The deviceOrientationCamera used as the camera when not in VR.
  98972. */
  98973. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98974. /**
  98975. * Based on the current WebVR support, returns the current VR camera used.
  98976. */
  98977. readonly currentVRCamera: Nullable<Camera>;
  98978. /**
  98979. * The webVRCamera which is used when in VR.
  98980. */
  98981. readonly webVRCamera: WebVRFreeCamera;
  98982. /**
  98983. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98984. */
  98985. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98986. private readonly _teleportationRequestInitiated;
  98987. /**
  98988. * Defines wether or not Pointer lock should be requested when switching to
  98989. * full screen.
  98990. */
  98991. requestPointerLockOnFullScreen: boolean;
  98992. /**
  98993. * Instantiates a VRExperienceHelper.
  98994. * Helps to quickly add VR support to an existing scene.
  98995. * @param scene The scene the VRExperienceHelper belongs to.
  98996. * @param webVROptions Options to modify the vr experience helper's behavior.
  98997. */
  98998. constructor(scene: Scene,
  98999. /** Options to modify the vr experience helper's behavior. */
  99000. webVROptions?: VRExperienceHelperOptions);
  99001. private _onDefaultMeshLoaded;
  99002. private _onResize;
  99003. private _onFullscreenChange;
  99004. /**
  99005. * Gets a value indicating if we are currently in VR mode.
  99006. */
  99007. readonly isInVRMode: boolean;
  99008. private onVrDisplayPresentChange;
  99009. private onVRDisplayChanged;
  99010. private moveButtonToBottomRight;
  99011. private displayVRButton;
  99012. private updateButtonVisibility;
  99013. private _cachedAngularSensibility;
  99014. /**
  99015. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99016. * Otherwise, will use the fullscreen API.
  99017. */
  99018. enterVR(): void;
  99019. /**
  99020. * Attempt to exit VR, or fullscreen.
  99021. */
  99022. exitVR(): void;
  99023. /**
  99024. * The position of the vr experience helper.
  99025. */
  99026. /**
  99027. * Sets the position of the vr experience helper.
  99028. */
  99029. position: Vector3;
  99030. /**
  99031. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99032. */
  99033. enableInteractions(): void;
  99034. private readonly _noControllerIsActive;
  99035. private beforeRender;
  99036. private _isTeleportationFloor;
  99037. /**
  99038. * Adds a floor mesh to be used for teleportation.
  99039. * @param floorMesh the mesh to be used for teleportation.
  99040. */
  99041. addFloorMesh(floorMesh: Mesh): void;
  99042. /**
  99043. * Removes a floor mesh from being used for teleportation.
  99044. * @param floorMesh the mesh to be removed.
  99045. */
  99046. removeFloorMesh(floorMesh: Mesh): void;
  99047. /**
  99048. * Enables interactions and teleportation using the VR controllers and gaze.
  99049. * @param vrTeleportationOptions options to modify teleportation behavior.
  99050. */
  99051. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99052. private _onNewGamepadConnected;
  99053. private _tryEnableInteractionOnController;
  99054. private _onNewGamepadDisconnected;
  99055. private _enableInteractionOnController;
  99056. private _checkTeleportWithRay;
  99057. private _checkRotate;
  99058. private _checkTeleportBackwards;
  99059. private _enableTeleportationOnController;
  99060. private _createTeleportationCircles;
  99061. private _displayTeleportationTarget;
  99062. private _hideTeleportationTarget;
  99063. private _rotateCamera;
  99064. private _moveTeleportationSelectorTo;
  99065. private _workingVector;
  99066. private _workingQuaternion;
  99067. private _workingMatrix;
  99068. /**
  99069. * Teleports the users feet to the desired location
  99070. * @param location The location where the user's feet should be placed
  99071. */
  99072. teleportCamera(location: Vector3): void;
  99073. private _convertNormalToDirectionOfRay;
  99074. private _castRayAndSelectObject;
  99075. private _notifySelectedMeshUnselected;
  99076. /**
  99077. * Sets the color of the laser ray from the vr controllers.
  99078. * @param color new color for the ray.
  99079. */
  99080. changeLaserColor(color: Color3): void;
  99081. /**
  99082. * Sets the color of the ray from the vr headsets gaze.
  99083. * @param color new color for the ray.
  99084. */
  99085. changeGazeColor(color: Color3): void;
  99086. /**
  99087. * Exits VR and disposes of the vr experience helper
  99088. */
  99089. dispose(): void;
  99090. /**
  99091. * Gets the name of the VRExperienceHelper class
  99092. * @returns "VRExperienceHelper"
  99093. */
  99094. getClassName(): string;
  99095. }
  99096. }
  99097. declare module BABYLON {
  99098. /**
  99099. * Manages an XRSession
  99100. * @see https://doc.babylonjs.com/how_to/webxr
  99101. */
  99102. export class WebXRSessionManager implements IDisposable {
  99103. private scene;
  99104. /**
  99105. * Fires every time a new xrFrame arrives which can be used to update the camera
  99106. */
  99107. onXRFrameObservable: Observable<any>;
  99108. /**
  99109. * Fires when the xr session is ended either by the device or manually done
  99110. */
  99111. onXRSessionEnded: Observable<any>;
  99112. /** @hidden */
  99113. _xrSession: XRSession;
  99114. /** @hidden */
  99115. _frameOfReference: XRFrameOfReference;
  99116. /** @hidden */
  99117. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99118. /** @hidden */
  99119. _currentXRFrame: Nullable<XRFrame>;
  99120. private _xrNavigator;
  99121. private _xrDevice;
  99122. private _tmpMatrix;
  99123. /**
  99124. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99125. * @param scene The scene which the session should be created for
  99126. */
  99127. constructor(scene: Scene);
  99128. /**
  99129. * Initializes the manager
  99130. * After initialization enterXR can be called to start an XR session
  99131. * @returns Promise which resolves after it is initialized
  99132. */
  99133. initializeAsync(): Promise<void>;
  99134. /**
  99135. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99136. * @param sessionCreationOptions xr options to create the session with
  99137. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99138. * @returns Promise which resolves after it enters XR
  99139. */
  99140. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99141. /**
  99142. * Stops the xrSession and restores the renderloop
  99143. * @returns Promise which resolves after it exits XR
  99144. */
  99145. exitXRAsync(): Promise<void>;
  99146. /**
  99147. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99148. * @param ray ray to cast into the environment
  99149. * @returns Promise which resolves with a collision point in the environment if it exists
  99150. */
  99151. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99152. /**
  99153. * Checks if a session would be supported for the creation options specified
  99154. * @param options creation options to check if they are supported
  99155. * @returns true if supported
  99156. */
  99157. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99158. /**
  99159. * @hidden
  99160. * Converts the render layer of xrSession to a render target
  99161. * @param session session to create render target for
  99162. * @param scene scene the new render target should be created for
  99163. */
  99164. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99165. /**
  99166. * Disposes of the session manager
  99167. */
  99168. dispose(): void;
  99169. }
  99170. }
  99171. declare module BABYLON {
  99172. /**
  99173. * WebXR Camera which holds the views for the xrSession
  99174. * @see https://doc.babylonjs.com/how_to/webxr
  99175. */
  99176. export class WebXRCamera extends FreeCamera {
  99177. private static _TmpMatrix;
  99178. /**
  99179. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99180. * @param name the name of the camera
  99181. * @param scene the scene to add the camera to
  99182. */
  99183. constructor(name: string, scene: Scene);
  99184. private _updateNumberOfRigCameras;
  99185. /** @hidden */
  99186. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99187. /**
  99188. * Updates the cameras position from the current pose information of the XR session
  99189. * @param xrSessionManager the session containing pose information
  99190. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99191. */
  99192. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99193. }
  99194. }
  99195. declare module BABYLON {
  99196. /**
  99197. * States of the webXR experience
  99198. */
  99199. export enum WebXRState {
  99200. /**
  99201. * Transitioning to being in XR mode
  99202. */
  99203. ENTERING_XR = 0,
  99204. /**
  99205. * Transitioning to non XR mode
  99206. */
  99207. EXITING_XR = 1,
  99208. /**
  99209. * In XR mode and presenting
  99210. */
  99211. IN_XR = 2,
  99212. /**
  99213. * Not entered XR mode
  99214. */
  99215. NOT_IN_XR = 3
  99216. }
  99217. /**
  99218. * Helper class used to enable XR
  99219. * @see https://doc.babylonjs.com/how_to/webxr
  99220. */
  99221. export class WebXRExperienceHelper implements IDisposable {
  99222. private scene;
  99223. /**
  99224. * 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
  99225. */
  99226. container: AbstractMesh;
  99227. /**
  99228. * Camera used to render xr content
  99229. */
  99230. camera: WebXRCamera;
  99231. /**
  99232. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99233. */
  99234. state: WebXRState;
  99235. private _setState;
  99236. private static _TmpVector;
  99237. /**
  99238. * Fires when the state of the experience helper has changed
  99239. */
  99240. onStateChangedObservable: Observable<WebXRState>;
  99241. /** @hidden */
  99242. _sessionManager: WebXRSessionManager;
  99243. private _nonVRCamera;
  99244. private _originalSceneAutoClear;
  99245. private _supported;
  99246. /**
  99247. * Creates the experience helper
  99248. * @param scene the scene to attach the experience helper to
  99249. * @returns a promise for the experience helper
  99250. */
  99251. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99252. /**
  99253. * Creates a WebXRExperienceHelper
  99254. * @param scene The scene the helper should be created in
  99255. */
  99256. private constructor();
  99257. /**
  99258. * Exits XR mode and returns the scene to its original state
  99259. * @returns promise that resolves after xr mode has exited
  99260. */
  99261. exitXRAsync(): Promise<void>;
  99262. /**
  99263. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99264. * @param sessionCreationOptions options for the XR session
  99265. * @param frameOfReference frame of reference of the XR session
  99266. * @returns promise that resolves after xr mode has entered
  99267. */
  99268. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99269. /**
  99270. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99271. * @param ray ray to cast into the environment
  99272. * @returns Promise which resolves with a collision point in the environment if it exists
  99273. */
  99274. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99275. /**
  99276. * Updates the global position of the camera by moving the camera's container
  99277. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99278. * @param position The desired global position of the camera
  99279. */
  99280. setPositionOfCameraUsingContainer(position: Vector3): void;
  99281. /**
  99282. * Rotates the xr camera by rotating the camera's container around the camera's position
  99283. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99284. * @param rotation the desired quaternion rotation to apply to the camera
  99285. */
  99286. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99287. /**
  99288. * Checks if the creation options are supported by the xr session
  99289. * @param options creation options
  99290. * @returns true if supported
  99291. */
  99292. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99293. /**
  99294. * Disposes of the experience helper
  99295. */
  99296. dispose(): void;
  99297. }
  99298. }
  99299. declare module BABYLON {
  99300. /**
  99301. * Button which can be used to enter a different mode of XR
  99302. */
  99303. export class WebXREnterExitUIButton {
  99304. /** button element */
  99305. element: HTMLElement;
  99306. /** XR initialization options for the button */
  99307. initializationOptions: XRSessionCreationOptions;
  99308. /**
  99309. * Creates a WebXREnterExitUIButton
  99310. * @param element button element
  99311. * @param initializationOptions XR initialization options for the button
  99312. */
  99313. constructor(
  99314. /** button element */
  99315. element: HTMLElement,
  99316. /** XR initialization options for the button */
  99317. initializationOptions: XRSessionCreationOptions);
  99318. /**
  99319. * Overwritable function which can be used to update the button's visuals when the state changes
  99320. * @param activeButton the current active button in the UI
  99321. */
  99322. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99323. }
  99324. /**
  99325. * Options to create the webXR UI
  99326. */
  99327. export class WebXREnterExitUIOptions {
  99328. /**
  99329. * Context to enter xr with
  99330. */
  99331. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99332. /**
  99333. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99334. */
  99335. customButtons?: Array<WebXREnterExitUIButton>;
  99336. }
  99337. /**
  99338. * UI to allow the user to enter/exit XR mode
  99339. */
  99340. export class WebXREnterExitUI implements IDisposable {
  99341. private scene;
  99342. private _overlay;
  99343. private _buttons;
  99344. private _activeButton;
  99345. /**
  99346. * Fired every time the active button is changed.
  99347. *
  99348. * When xr is entered via a button that launches xr that button will be the callback parameter
  99349. *
  99350. * When exiting xr the callback parameter will be null)
  99351. */
  99352. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99353. /**
  99354. * Creates UI to allow the user to enter/exit XR mode
  99355. * @param scene the scene to add the ui to
  99356. * @param helper the xr experience helper to enter/exit xr with
  99357. * @param options options to configure the UI
  99358. * @returns the created ui
  99359. */
  99360. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99361. private constructor();
  99362. private _updateButtons;
  99363. /**
  99364. * Disposes of the object
  99365. */
  99366. dispose(): void;
  99367. }
  99368. }
  99369. declare module BABYLON {
  99370. /**
  99371. * Represents an XR input
  99372. */
  99373. export class WebXRController {
  99374. /**
  99375. * 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
  99376. */
  99377. grip?: AbstractMesh;
  99378. /**
  99379. * Pointer which can be used to select objects or attach a visible laser to
  99380. */
  99381. pointer: AbstractMesh;
  99382. /**
  99383. * Creates the controller
  99384. * @see https://doc.babylonjs.com/how_to/webxr
  99385. * @param scene the scene which the controller should be associated to
  99386. */
  99387. constructor(scene: Scene);
  99388. /**
  99389. * Disposes of the object
  99390. */
  99391. dispose(): void;
  99392. }
  99393. /**
  99394. * XR input used to track XR inputs such as controllers/rays
  99395. */
  99396. export class WebXRInput implements IDisposable {
  99397. private helper;
  99398. /**
  99399. * XR controllers being tracked
  99400. */
  99401. controllers: Array<WebXRController>;
  99402. private _tmpMatrix;
  99403. private _frameObserver;
  99404. /**
  99405. * Initializes the WebXRInput
  99406. * @param helper experience helper which the input should be created for
  99407. */
  99408. constructor(helper: WebXRExperienceHelper);
  99409. /**
  99410. * Disposes of the object
  99411. */
  99412. dispose(): void;
  99413. }
  99414. }
  99415. declare module BABYLON {
  99416. /**
  99417. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99418. */
  99419. export class WebXRManagedOutputCanvas implements IDisposable {
  99420. private _canvas;
  99421. /**
  99422. * xrpresent context of the canvas which can be used to display/mirror xr content
  99423. */
  99424. canvasContext: Nullable<WebGLRenderingContext>;
  99425. /**
  99426. * Initializes the canvas to be added/removed upon entering/exiting xr
  99427. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99428. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99429. */
  99430. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99431. /**
  99432. * Disposes of the object
  99433. */
  99434. dispose(): void;
  99435. private _setManagedOutputCanvas;
  99436. private _addCanvas;
  99437. private _removeCanvas;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Contains an array of blocks representing the octree
  99443. */
  99444. export interface IOctreeContainer<T> {
  99445. /**
  99446. * Blocks within the octree
  99447. */
  99448. blocks: Array<OctreeBlock<T>>;
  99449. }
  99450. /**
  99451. * Class used to store a cell in an octree
  99452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99453. */
  99454. export class OctreeBlock<T> {
  99455. /**
  99456. * Gets the content of the current block
  99457. */
  99458. entries: T[];
  99459. /**
  99460. * Gets the list of block children
  99461. */
  99462. blocks: Array<OctreeBlock<T>>;
  99463. private _depth;
  99464. private _maxDepth;
  99465. private _capacity;
  99466. private _minPoint;
  99467. private _maxPoint;
  99468. private _boundingVectors;
  99469. private _creationFunc;
  99470. /**
  99471. * Creates a new block
  99472. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99473. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99474. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99475. * @param depth defines the current depth of this block in the octree
  99476. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99477. * @param creationFunc defines a callback to call when an element is added to the block
  99478. */
  99479. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99480. /**
  99481. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99482. */
  99483. readonly capacity: number;
  99484. /**
  99485. * Gets the minimum vector (in world space) of the block's bounding box
  99486. */
  99487. readonly minPoint: Vector3;
  99488. /**
  99489. * Gets the maximum vector (in world space) of the block's bounding box
  99490. */
  99491. readonly maxPoint: Vector3;
  99492. /**
  99493. * Add a new element to this block
  99494. * @param entry defines the element to add
  99495. */
  99496. addEntry(entry: T): void;
  99497. /**
  99498. * Remove an element from this block
  99499. * @param entry defines the element to remove
  99500. */
  99501. removeEntry(entry: T): void;
  99502. /**
  99503. * Add an array of elements to this block
  99504. * @param entries defines the array of elements to add
  99505. */
  99506. addEntries(entries: T[]): void;
  99507. /**
  99508. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99509. * @param frustumPlanes defines the frustum planes to test
  99510. * @param selection defines the array to store current content if selection is positive
  99511. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99512. */
  99513. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99514. /**
  99515. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99516. * @param sphereCenter defines the bounding sphere center
  99517. * @param sphereRadius defines the bounding sphere radius
  99518. * @param selection defines the array to store current content if selection is positive
  99519. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99520. */
  99521. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99522. /**
  99523. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99524. * @param ray defines the ray to test with
  99525. * @param selection defines the array to store current content if selection is positive
  99526. */
  99527. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99528. /**
  99529. * Subdivide the content into child blocks (this block will then be empty)
  99530. */
  99531. createInnerBlocks(): void;
  99532. /**
  99533. * @hidden
  99534. */
  99535. 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;
  99536. }
  99537. }
  99538. declare module BABYLON {
  99539. /**
  99540. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99542. */
  99543. export class Octree<T> {
  99544. /** 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.) */
  99545. maxDepth: number;
  99546. /**
  99547. * Blocks within the octree containing objects
  99548. */
  99549. blocks: Array<OctreeBlock<T>>;
  99550. /**
  99551. * Content stored in the octree
  99552. */
  99553. dynamicContent: T[];
  99554. private _maxBlockCapacity;
  99555. private _selectionContent;
  99556. private _creationFunc;
  99557. /**
  99558. * Creates a octree
  99559. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99560. * @param creationFunc function to be used to instatiate the octree
  99561. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99562. * @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.)
  99563. */
  99564. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99565. /** 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.) */
  99566. maxDepth?: number);
  99567. /**
  99568. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99569. * @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);
  99570. * @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);
  99571. * @param entries meshes to be added to the octree blocks
  99572. */
  99573. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99574. /**
  99575. * Adds a mesh to the octree
  99576. * @param entry Mesh to add to the octree
  99577. */
  99578. addMesh(entry: T): void;
  99579. /**
  99580. * Remove an element from the octree
  99581. * @param entry defines the element to remove
  99582. */
  99583. removeMesh(entry: T): void;
  99584. /**
  99585. * Selects an array of meshes within the frustum
  99586. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99587. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99588. * @returns array of meshes within the frustum
  99589. */
  99590. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99591. /**
  99592. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99593. * @param sphereCenter defines the bounding sphere center
  99594. * @param sphereRadius defines the bounding sphere radius
  99595. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99596. * @returns an array of objects that intersect the sphere
  99597. */
  99598. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99599. /**
  99600. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99601. * @param ray defines the ray to test with
  99602. * @returns array of intersected objects
  99603. */
  99604. intersectsRay(ray: Ray): SmartArray<T>;
  99605. /**
  99606. * Adds a mesh into the octree block if it intersects the block
  99607. */
  99608. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99609. /**
  99610. * Adds a submesh into the octree block if it intersects the block
  99611. */
  99612. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99613. }
  99614. }
  99615. declare module BABYLON {
  99616. interface Scene {
  99617. /**
  99618. * @hidden
  99619. * Backing Filed
  99620. */
  99621. _selectionOctree: Octree<AbstractMesh>;
  99622. /**
  99623. * Gets the octree used to boost mesh selection (picking)
  99624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99625. */
  99626. selectionOctree: Octree<AbstractMesh>;
  99627. /**
  99628. * Creates or updates the octree used to boost selection (picking)
  99629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99630. * @param maxCapacity defines the maximum capacity per leaf
  99631. * @param maxDepth defines the maximum depth of the octree
  99632. * @returns an octree of AbstractMesh
  99633. */
  99634. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99635. }
  99636. interface AbstractMesh {
  99637. /**
  99638. * @hidden
  99639. * Backing Field
  99640. */
  99641. _submeshesOctree: Octree<SubMesh>;
  99642. /**
  99643. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99644. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99645. * @param maxCapacity defines the maximum size of each block (64 by default)
  99646. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99647. * @returns the new octree
  99648. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99650. */
  99651. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99652. }
  99653. /**
  99654. * Defines the octree scene component responsible to manage any octrees
  99655. * in a given scene.
  99656. */
  99657. export class OctreeSceneComponent {
  99658. /**
  99659. * The component name helpfull to identify the component in the list of scene components.
  99660. */
  99661. readonly name: string;
  99662. /**
  99663. * The scene the component belongs to.
  99664. */
  99665. scene: Scene;
  99666. /**
  99667. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99668. */
  99669. readonly checksIsEnabled: boolean;
  99670. /**
  99671. * Creates a new instance of the component for the given scene
  99672. * @param scene Defines the scene to register the component in
  99673. */
  99674. constructor(scene: Scene);
  99675. /**
  99676. * Registers the component in a given scene
  99677. */
  99678. register(): void;
  99679. /**
  99680. * Return the list of active meshes
  99681. * @returns the list of active meshes
  99682. */
  99683. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99684. /**
  99685. * Return the list of active sub meshes
  99686. * @param mesh The mesh to get the candidates sub meshes from
  99687. * @returns the list of active sub meshes
  99688. */
  99689. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99690. private _tempRay;
  99691. /**
  99692. * Return the list of sub meshes intersecting with a given local ray
  99693. * @param mesh defines the mesh to find the submesh for
  99694. * @param localRay defines the ray in local space
  99695. * @returns the list of intersecting sub meshes
  99696. */
  99697. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99698. /**
  99699. * Return the list of sub meshes colliding with a collider
  99700. * @param mesh defines the mesh to find the submesh for
  99701. * @param collider defines the collider to evaluate the collision against
  99702. * @returns the list of colliding sub meshes
  99703. */
  99704. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99705. /**
  99706. * Rebuilds the elements related to this component in case of
  99707. * context lost for instance.
  99708. */
  99709. rebuild(): void;
  99710. /**
  99711. * Disposes the component and the associated ressources.
  99712. */
  99713. dispose(): void;
  99714. }
  99715. }
  99716. declare module BABYLON {
  99717. /**
  99718. * Renders a layer on top of an existing scene
  99719. */
  99720. export class UtilityLayerRenderer implements IDisposable {
  99721. /** the original scene that will be rendered on top of */
  99722. originalScene: Scene;
  99723. private _pointerCaptures;
  99724. private _lastPointerEvents;
  99725. private static _DefaultUtilityLayer;
  99726. private static _DefaultKeepDepthUtilityLayer;
  99727. private _sharedGizmoLight;
  99728. /**
  99729. * @hidden
  99730. * Light which used by gizmos to get light shading
  99731. */
  99732. _getSharedGizmoLight(): HemisphericLight;
  99733. /**
  99734. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99735. */
  99736. pickUtilitySceneFirst: boolean;
  99737. /**
  99738. * 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)
  99739. */
  99740. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99741. /**
  99742. * 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)
  99743. */
  99744. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99745. /**
  99746. * The scene that is rendered on top of the original scene
  99747. */
  99748. utilityLayerScene: Scene;
  99749. /**
  99750. * If the utility layer should automatically be rendered on top of existing scene
  99751. */
  99752. shouldRender: boolean;
  99753. /**
  99754. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99755. */
  99756. onlyCheckPointerDownEvents: boolean;
  99757. /**
  99758. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99759. */
  99760. processAllEvents: boolean;
  99761. /**
  99762. * Observable raised when the pointer move from the utility layer scene to the main scene
  99763. */
  99764. onPointerOutObservable: Observable<number>;
  99765. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99766. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99767. private _afterRenderObserver;
  99768. private _sceneDisposeObserver;
  99769. private _originalPointerObserver;
  99770. /**
  99771. * Instantiates a UtilityLayerRenderer
  99772. * @param originalScene the original scene that will be rendered on top of
  99773. * @param handleEvents boolean indicating if the utility layer should handle events
  99774. */
  99775. constructor(
  99776. /** the original scene that will be rendered on top of */
  99777. originalScene: Scene, handleEvents?: boolean);
  99778. private _notifyObservers;
  99779. /**
  99780. * Renders the utility layers scene on top of the original scene
  99781. */
  99782. render(): void;
  99783. /**
  99784. * Disposes of the renderer
  99785. */
  99786. dispose(): void;
  99787. private _updateCamera;
  99788. }
  99789. }
  99790. declare module BABYLON {
  99791. /**
  99792. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99793. */
  99794. export class Gizmo implements IDisposable {
  99795. /** The utility layer the gizmo will be added to */
  99796. gizmoLayer: UtilityLayerRenderer;
  99797. /**
  99798. * The root mesh of the gizmo
  99799. */
  99800. _rootMesh: Mesh;
  99801. private _attachedMesh;
  99802. /**
  99803. * Ratio for the scale of the gizmo (Default: 1)
  99804. */
  99805. scaleRatio: number;
  99806. private _tmpMatrix;
  99807. /**
  99808. * If a custom mesh has been set (Default: false)
  99809. */
  99810. protected _customMeshSet: boolean;
  99811. /**
  99812. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99813. * * When set, interactions will be enabled
  99814. */
  99815. attachedMesh: Nullable<AbstractMesh>;
  99816. /**
  99817. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99818. * @param mesh The mesh to replace the default mesh of the gizmo
  99819. */
  99820. setCustomMesh(mesh: Mesh): void;
  99821. /**
  99822. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99823. */
  99824. updateGizmoRotationToMatchAttachedMesh: boolean;
  99825. /**
  99826. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99827. */
  99828. updateGizmoPositionToMatchAttachedMesh: boolean;
  99829. /**
  99830. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99831. */
  99832. protected _updateScale: boolean;
  99833. protected _interactionsEnabled: boolean;
  99834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99835. private _beforeRenderObserver;
  99836. /**
  99837. * Creates a gizmo
  99838. * @param gizmoLayer The utility layer the gizmo will be added to
  99839. */
  99840. constructor(
  99841. /** The utility layer the gizmo will be added to */
  99842. gizmoLayer?: UtilityLayerRenderer);
  99843. private _tempVector;
  99844. /**
  99845. * @hidden
  99846. * Updates the gizmo to match the attached mesh's position/rotation
  99847. */
  99848. protected _update(): void;
  99849. /**
  99850. * Disposes of the gizmo
  99851. */
  99852. dispose(): void;
  99853. }
  99854. }
  99855. declare module BABYLON {
  99856. /**
  99857. * Single axis drag gizmo
  99858. */
  99859. export class AxisDragGizmo extends Gizmo {
  99860. /**
  99861. * Drag behavior responsible for the gizmos dragging interactions
  99862. */
  99863. dragBehavior: PointerDragBehavior;
  99864. private _pointerObserver;
  99865. /**
  99866. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99867. */
  99868. snapDistance: number;
  99869. /**
  99870. * Event that fires each time the gizmo snaps to a new location.
  99871. * * snapDistance is the the change in distance
  99872. */
  99873. onSnapObservable: Observable<{
  99874. snapDistance: number;
  99875. }>;
  99876. /** @hidden */
  99877. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99878. /** @hidden */
  99879. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99880. /**
  99881. * Creates an AxisDragGizmo
  99882. * @param gizmoLayer The utility layer the gizmo will be added to
  99883. * @param dragAxis The axis which the gizmo will be able to drag on
  99884. * @param color The color of the gizmo
  99885. */
  99886. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99888. /**
  99889. * Disposes of the gizmo
  99890. */
  99891. dispose(): void;
  99892. }
  99893. }
  99894. declare module BABYLON.Debug {
  99895. /**
  99896. * The Axes viewer will show 3 axes in a specific point in space
  99897. */
  99898. export class AxesViewer {
  99899. private _xAxis;
  99900. private _yAxis;
  99901. private _zAxis;
  99902. private _scaleLinesFactor;
  99903. private _instanced;
  99904. /**
  99905. * Gets the hosting scene
  99906. */
  99907. scene: Scene;
  99908. /**
  99909. * Gets or sets a number used to scale line length
  99910. */
  99911. scaleLines: number;
  99912. /** Gets the node hierarchy used to render x-axis */
  99913. readonly xAxis: TransformNode;
  99914. /** Gets the node hierarchy used to render y-axis */
  99915. readonly yAxis: TransformNode;
  99916. /** Gets the node hierarchy used to render z-axis */
  99917. readonly zAxis: TransformNode;
  99918. /**
  99919. * Creates a new AxesViewer
  99920. * @param scene defines the hosting scene
  99921. * @param scaleLines defines a number used to scale line length (1 by default)
  99922. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99923. * @param xAxis defines the node hierarchy used to render the x-axis
  99924. * @param yAxis defines the node hierarchy used to render the y-axis
  99925. * @param zAxis defines the node hierarchy used to render the z-axis
  99926. */
  99927. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99928. /**
  99929. * Force the viewer to update
  99930. * @param position defines the position of the viewer
  99931. * @param xaxis defines the x axis of the viewer
  99932. * @param yaxis defines the y axis of the viewer
  99933. * @param zaxis defines the z axis of the viewer
  99934. */
  99935. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99936. /**
  99937. * Creates an instance of this axes viewer.
  99938. * @returns a new axes viewer with instanced meshes
  99939. */
  99940. createInstance(): AxesViewer;
  99941. /** Releases resources */
  99942. dispose(): void;
  99943. private static _SetRenderingGroupId;
  99944. }
  99945. }
  99946. declare module BABYLON.Debug {
  99947. /**
  99948. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99949. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99950. */
  99951. export class BoneAxesViewer extends AxesViewer {
  99952. /**
  99953. * Gets or sets the target mesh where to display the axes viewer
  99954. */
  99955. mesh: Nullable<Mesh>;
  99956. /**
  99957. * Gets or sets the target bone where to display the axes viewer
  99958. */
  99959. bone: Nullable<Bone>;
  99960. /** Gets current position */
  99961. pos: Vector3;
  99962. /** Gets direction of X axis */
  99963. xaxis: Vector3;
  99964. /** Gets direction of Y axis */
  99965. yaxis: Vector3;
  99966. /** Gets direction of Z axis */
  99967. zaxis: Vector3;
  99968. /**
  99969. * Creates a new BoneAxesViewer
  99970. * @param scene defines the hosting scene
  99971. * @param bone defines the target bone
  99972. * @param mesh defines the target mesh
  99973. * @param scaleLines defines a scaling factor for line length (1 by default)
  99974. */
  99975. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99976. /**
  99977. * Force the viewer to update
  99978. */
  99979. update(): void;
  99980. /** Releases resources */
  99981. dispose(): void;
  99982. }
  99983. }
  99984. declare module BABYLON {
  99985. /**
  99986. * Interface used to define scene explorer extensibility option
  99987. */
  99988. export interface IExplorerExtensibilityOption {
  99989. /**
  99990. * Define the option label
  99991. */
  99992. label: string;
  99993. /**
  99994. * Defines the action to execute on click
  99995. */
  99996. action: (entity: any) => void;
  99997. }
  99998. /**
  99999. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100000. */
  100001. export interface IExplorerExtensibilityGroup {
  100002. /**
  100003. * Defines a predicate to test if a given type mut be extended
  100004. */
  100005. predicate: (entity: any) => boolean;
  100006. /**
  100007. * Gets the list of options added to a type
  100008. */
  100009. entries: IExplorerExtensibilityOption[];
  100010. }
  100011. /**
  100012. * Interface used to define the options to use to create the Inspector
  100013. */
  100014. export interface IInspectorOptions {
  100015. /**
  100016. * Display in overlay mode (default: false)
  100017. */
  100018. overlay?: boolean;
  100019. /**
  100020. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100021. */
  100022. globalRoot?: HTMLElement;
  100023. /**
  100024. * Display the Scene explorer
  100025. */
  100026. showExplorer?: boolean;
  100027. /**
  100028. * Display the property inspector
  100029. */
  100030. showInspector?: boolean;
  100031. /**
  100032. * Display in embed mode (both panes on the right)
  100033. */
  100034. embedMode?: boolean;
  100035. /**
  100036. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100037. */
  100038. handleResize?: boolean;
  100039. /**
  100040. * Allow the panes to popup (default: true)
  100041. */
  100042. enablePopup?: boolean;
  100043. /**
  100044. * Allow the panes to be closed by users (default: true)
  100045. */
  100046. enableClose?: boolean;
  100047. /**
  100048. * Optional list of extensibility entries
  100049. */
  100050. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100051. /**
  100052. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100053. */
  100054. inspectorURL?: string;
  100055. }
  100056. interface Scene {
  100057. /**
  100058. * @hidden
  100059. * Backing field
  100060. */
  100061. _debugLayer: DebugLayer;
  100062. /**
  100063. * Gets the debug layer (aka Inspector) associated with the scene
  100064. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100065. */
  100066. debugLayer: DebugLayer;
  100067. }
  100068. /**
  100069. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100070. * what is happening in your scene
  100071. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100072. */
  100073. export class DebugLayer {
  100074. /**
  100075. * Define the url to get the inspector script from.
  100076. * By default it uses the babylonjs CDN.
  100077. * @ignoreNaming
  100078. */
  100079. static InspectorURL: string;
  100080. private _scene;
  100081. private BJSINSPECTOR;
  100082. /**
  100083. * Observable triggered when a property is changed through the inspector.
  100084. */
  100085. onPropertyChangedObservable: Observable<{
  100086. object: any;
  100087. property: string;
  100088. value: any;
  100089. initialValue: any;
  100090. }>;
  100091. /**
  100092. * Instantiates a new debug layer.
  100093. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100094. * what is happening in your scene
  100095. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100096. * @param scene Defines the scene to inspect
  100097. */
  100098. constructor(scene: Scene);
  100099. /** Creates the inspector window. */
  100100. private _createInspector;
  100101. /**
  100102. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100103. * @param entity defines the entity to select
  100104. * @param lineContainerTitle defines the specific block to highlight
  100105. */
  100106. select(entity: any, lineContainerTitle?: string): void;
  100107. /** Get the inspector from bundle or global */
  100108. private _getGlobalInspector;
  100109. /**
  100110. * Get if the inspector is visible or not.
  100111. * @returns true if visible otherwise, false
  100112. */
  100113. isVisible(): boolean;
  100114. /**
  100115. * Hide the inspector and close its window.
  100116. */
  100117. hide(): void;
  100118. /**
  100119. * Launch the debugLayer.
  100120. * @param config Define the configuration of the inspector
  100121. * @return a promise fulfilled when the debug layer is visible
  100122. */
  100123. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100124. }
  100125. }
  100126. declare module BABYLON {
  100127. /**
  100128. * Class containing static functions to help procedurally build meshes
  100129. */
  100130. export class BoxBuilder {
  100131. /**
  100132. * Creates a box mesh
  100133. * * The parameter `size` sets the size (float) of each box side (default 1)
  100134. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100135. * * 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)
  100136. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100140. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100141. * @param name defines the name of the mesh
  100142. * @param options defines the options used to create the mesh
  100143. * @param scene defines the hosting scene
  100144. * @returns the box mesh
  100145. */
  100146. static CreateBox(name: string, options: {
  100147. size?: number;
  100148. width?: number;
  100149. height?: number;
  100150. depth?: number;
  100151. faceUV?: Vector4[];
  100152. faceColors?: Color4[];
  100153. sideOrientation?: number;
  100154. frontUVs?: Vector4;
  100155. backUVs?: Vector4;
  100156. updatable?: boolean;
  100157. }, scene?: Nullable<Scene>): Mesh;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. /**
  100162. * Class containing static functions to help procedurally build meshes
  100163. */
  100164. export class SphereBuilder {
  100165. /**
  100166. * Creates a sphere mesh
  100167. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100168. * * 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`)
  100169. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100170. * * 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
  100171. * * 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)
  100172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100175. * @param name defines the name of the mesh
  100176. * @param options defines the options used to create the mesh
  100177. * @param scene defines the hosting scene
  100178. * @returns the sphere mesh
  100179. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100180. */
  100181. static CreateSphere(name: string, options: {
  100182. segments?: number;
  100183. diameter?: number;
  100184. diameterX?: number;
  100185. diameterY?: number;
  100186. diameterZ?: number;
  100187. arc?: number;
  100188. slice?: number;
  100189. sideOrientation?: number;
  100190. frontUVs?: Vector4;
  100191. backUVs?: Vector4;
  100192. updatable?: boolean;
  100193. }, scene: any): Mesh;
  100194. }
  100195. }
  100196. declare module BABYLON.Debug {
  100197. /**
  100198. * Used to show the physics impostor around the specific mesh
  100199. */
  100200. export class PhysicsViewer {
  100201. /** @hidden */
  100202. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100203. /** @hidden */
  100204. protected _meshes: Array<Nullable<AbstractMesh>>;
  100205. /** @hidden */
  100206. protected _scene: Nullable<Scene>;
  100207. /** @hidden */
  100208. protected _numMeshes: number;
  100209. /** @hidden */
  100210. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100211. private _renderFunction;
  100212. private _utilityLayer;
  100213. private _debugBoxMesh;
  100214. private _debugSphereMesh;
  100215. private _debugMaterial;
  100216. private _debugMeshMeshes;
  100217. /**
  100218. * Creates a new PhysicsViewer
  100219. * @param scene defines the hosting scene
  100220. */
  100221. constructor(scene: Scene);
  100222. /** @hidden */
  100223. protected _updateDebugMeshes(): void;
  100224. /**
  100225. * Renders a specified physic impostor
  100226. * @param impostor defines the impostor to render
  100227. * @param targetMesh defines the mesh represented by the impostor
  100228. * @returns the new debug mesh used to render the impostor
  100229. */
  100230. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100231. /**
  100232. * Hides a specified physic impostor
  100233. * @param impostor defines the impostor to hide
  100234. */
  100235. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100236. private _getDebugMaterial;
  100237. private _getDebugBoxMesh;
  100238. private _getDebugSphereMesh;
  100239. private _getDebugMeshMesh;
  100240. private _getDebugMesh;
  100241. /** Releases all resources */
  100242. dispose(): void;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * Class containing static functions to help procedurally build meshes
  100248. */
  100249. export class LinesBuilder {
  100250. /**
  100251. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100252. * * 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
  100253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100254. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100255. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100256. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100257. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100258. * * 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
  100259. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100262. * @param name defines the name of the new line system
  100263. * @param options defines the options used to create the line system
  100264. * @param scene defines the hosting scene
  100265. * @returns a new line system mesh
  100266. */
  100267. static CreateLineSystem(name: string, options: {
  100268. lines: Vector3[][];
  100269. updatable?: boolean;
  100270. instance?: Nullable<LinesMesh>;
  100271. colors?: Nullable<Color4[][]>;
  100272. useVertexAlpha?: boolean;
  100273. }, scene: Nullable<Scene>): LinesMesh;
  100274. /**
  100275. * Creates a line mesh
  100276. * 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
  100277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100278. * * The parameter `points` is an array successive Vector3
  100279. * * 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
  100280. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100281. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100282. * * When updating an instance, remember that only point positions can change, not the number of points
  100283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100285. * @param name defines the name of the new line system
  100286. * @param options defines the options used to create the line system
  100287. * @param scene defines the hosting scene
  100288. * @returns a new line mesh
  100289. */
  100290. static CreateLines(name: string, options: {
  100291. points: Vector3[];
  100292. updatable?: boolean;
  100293. instance?: Nullable<LinesMesh>;
  100294. colors?: Color4[];
  100295. useVertexAlpha?: boolean;
  100296. }, scene?: Nullable<Scene>): LinesMesh;
  100297. /**
  100298. * Creates a dashed line mesh
  100299. * * 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
  100300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100301. * * The parameter `points` is an array successive Vector3
  100302. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100303. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100304. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100305. * * 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
  100306. * * When updating an instance, remember that only point positions can change, not the number of points
  100307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100308. * @param name defines the name of the mesh
  100309. * @param options defines the options used to create the mesh
  100310. * @param scene defines the hosting scene
  100311. * @returns the dashed line mesh
  100312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100313. */
  100314. static CreateDashedLines(name: string, options: {
  100315. points: Vector3[];
  100316. dashSize?: number;
  100317. gapSize?: number;
  100318. dashNb?: number;
  100319. updatable?: boolean;
  100320. instance?: LinesMesh;
  100321. }, scene?: Nullable<Scene>): LinesMesh;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100327. * in order to better appreciate the issue one might have.
  100328. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100329. */
  100330. export class RayHelper {
  100331. /**
  100332. * Defines the ray we are currently tryin to visualize.
  100333. */
  100334. ray: Nullable<Ray>;
  100335. private _renderPoints;
  100336. private _renderLine;
  100337. private _renderFunction;
  100338. private _scene;
  100339. private _updateToMeshFunction;
  100340. private _attachedToMesh;
  100341. private _meshSpaceDirection;
  100342. private _meshSpaceOrigin;
  100343. /**
  100344. * Helper function to create a colored helper in a scene in one line.
  100345. * @param ray Defines the ray we are currently tryin to visualize
  100346. * @param scene Defines the scene the ray is used in
  100347. * @param color Defines the color we want to see the ray in
  100348. * @returns The newly created ray helper.
  100349. */
  100350. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100351. /**
  100352. * Instantiate a new ray helper.
  100353. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100354. * in order to better appreciate the issue one might have.
  100355. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100356. * @param ray Defines the ray we are currently tryin to visualize
  100357. */
  100358. constructor(ray: Ray);
  100359. /**
  100360. * Shows the ray we are willing to debug.
  100361. * @param scene Defines the scene the ray needs to be rendered in
  100362. * @param color Defines the color the ray needs to be rendered in
  100363. */
  100364. show(scene: Scene, color?: Color3): void;
  100365. /**
  100366. * Hides the ray we are debugging.
  100367. */
  100368. hide(): void;
  100369. private _render;
  100370. /**
  100371. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100372. * @param mesh Defines the mesh we want the helper attached to
  100373. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100374. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100375. * @param length Defines the length of the ray
  100376. */
  100377. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100378. /**
  100379. * Detach the ray helper from the mesh it has previously been attached to.
  100380. */
  100381. detachFromMesh(): void;
  100382. private _updateToMesh;
  100383. /**
  100384. * Dispose the helper and release its associated resources.
  100385. */
  100386. dispose(): void;
  100387. }
  100388. }
  100389. declare module BABYLON.Debug {
  100390. /**
  100391. * Class used to render a debug view of a given skeleton
  100392. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100393. */
  100394. export class SkeletonViewer {
  100395. /** defines the skeleton to render */
  100396. skeleton: Skeleton;
  100397. /** defines the mesh attached to the skeleton */
  100398. mesh: AbstractMesh;
  100399. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100400. autoUpdateBonesMatrices: boolean;
  100401. /** defines the rendering group id to use with the viewer */
  100402. renderingGroupId: number;
  100403. /** Gets or sets the color used to render the skeleton */
  100404. color: Color3;
  100405. private _scene;
  100406. private _debugLines;
  100407. private _debugMesh;
  100408. private _isEnabled;
  100409. private _renderFunction;
  100410. private _utilityLayer;
  100411. /**
  100412. * Returns the mesh used to render the bones
  100413. */
  100414. readonly debugMesh: Nullable<LinesMesh>;
  100415. /**
  100416. * Creates a new SkeletonViewer
  100417. * @param skeleton defines the skeleton to render
  100418. * @param mesh defines the mesh attached to the skeleton
  100419. * @param scene defines the hosting scene
  100420. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100421. * @param renderingGroupId defines the rendering group id to use with the viewer
  100422. */
  100423. constructor(
  100424. /** defines the skeleton to render */
  100425. skeleton: Skeleton,
  100426. /** defines the mesh attached to the skeleton */
  100427. mesh: AbstractMesh, scene: Scene,
  100428. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100429. autoUpdateBonesMatrices?: boolean,
  100430. /** defines the rendering group id to use with the viewer */
  100431. renderingGroupId?: number);
  100432. /** Gets or sets a boolean indicating if the viewer is enabled */
  100433. isEnabled: boolean;
  100434. private _getBonePosition;
  100435. private _getLinesForBonesWithLength;
  100436. private _getLinesForBonesNoLength;
  100437. /** Update the viewer to sync with current skeleton state */
  100438. update(): void;
  100439. /** Release associated resources */
  100440. dispose(): void;
  100441. }
  100442. }
  100443. declare module BABYLON {
  100444. /**
  100445. * Options to create the null engine
  100446. */
  100447. export class NullEngineOptions {
  100448. /**
  100449. * Render width (Default: 512)
  100450. */
  100451. renderWidth: number;
  100452. /**
  100453. * Render height (Default: 256)
  100454. */
  100455. renderHeight: number;
  100456. /**
  100457. * Texture size (Default: 512)
  100458. */
  100459. textureSize: number;
  100460. /**
  100461. * If delta time between frames should be constant
  100462. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100463. */
  100464. deterministicLockstep: boolean;
  100465. /**
  100466. * Maximum about of steps between frames (Default: 4)
  100467. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100468. */
  100469. lockstepMaxSteps: number;
  100470. }
  100471. /**
  100472. * The null engine class provides support for headless version of babylon.js.
  100473. * This can be used in server side scenario or for testing purposes
  100474. */
  100475. export class NullEngine extends Engine {
  100476. private _options;
  100477. /**
  100478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100479. */
  100480. isDeterministicLockStep(): boolean;
  100481. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100482. getLockstepMaxSteps(): number;
  100483. /**
  100484. * Sets hardware scaling, used to save performance if needed
  100485. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100486. */
  100487. getHardwareScalingLevel(): number;
  100488. constructor(options?: NullEngineOptions);
  100489. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100490. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100491. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100492. getRenderWidth(useScreen?: boolean): number;
  100493. getRenderHeight(useScreen?: boolean): number;
  100494. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100495. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100496. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100497. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100498. bindSamplers(effect: Effect): void;
  100499. enableEffect(effect: Effect): void;
  100500. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100501. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100502. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100503. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100504. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100505. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100506. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100507. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100508. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100509. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100510. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100511. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100512. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100513. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100514. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100515. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100516. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100517. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100518. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100519. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100520. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100521. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100522. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100523. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100524. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100525. bindBuffers(vertexBuffers: {
  100526. [key: string]: VertexBuffer;
  100527. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100528. wipeCaches(bruteForce?: boolean): void;
  100529. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100530. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100531. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100532. /** @hidden */
  100533. _createTexture(): WebGLTexture;
  100534. /** @hidden */
  100535. _releaseTexture(texture: InternalTexture): void;
  100536. 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;
  100537. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100538. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100540. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100541. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100542. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100543. areAllEffectsReady(): boolean;
  100544. /**
  100545. * @hidden
  100546. * Get the current error code of the webGL context
  100547. * @returns the error code
  100548. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100549. */
  100550. getError(): number;
  100551. /** @hidden */
  100552. _getUnpackAlignement(): number;
  100553. /** @hidden */
  100554. _unpackFlipY(value: boolean): void;
  100555. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100556. /**
  100557. * Updates a dynamic vertex buffer.
  100558. * @param vertexBuffer the vertex buffer to update
  100559. * @param data the data used to update the vertex buffer
  100560. * @param byteOffset the byte offset of the data (optional)
  100561. * @param byteLength the byte length of the data (optional)
  100562. */
  100563. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100564. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100565. /** @hidden */
  100566. _bindTexture(channel: number, texture: InternalTexture): void;
  100567. /** @hidden */
  100568. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100569. releaseEffects(): void;
  100570. displayLoadingUI(): void;
  100571. hideLoadingUI(): void;
  100572. /** @hidden */
  100573. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100574. /** @hidden */
  100575. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100576. /** @hidden */
  100577. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100578. /** @hidden */
  100579. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100580. }
  100581. }
  100582. declare module BABYLON {
  100583. /** @hidden */
  100584. export class _OcclusionDataStorage {
  100585. /** @hidden */
  100586. occlusionInternalRetryCounter: number;
  100587. /** @hidden */
  100588. isOcclusionQueryInProgress: boolean;
  100589. /** @hidden */
  100590. isOccluded: boolean;
  100591. /** @hidden */
  100592. occlusionRetryCount: number;
  100593. /** @hidden */
  100594. occlusionType: number;
  100595. /** @hidden */
  100596. occlusionQueryAlgorithmType: number;
  100597. }
  100598. interface Engine {
  100599. /**
  100600. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100601. * @return the new query
  100602. */
  100603. createQuery(): WebGLQuery;
  100604. /**
  100605. * Delete and release a webGL query
  100606. * @param query defines the query to delete
  100607. * @return the current engine
  100608. */
  100609. deleteQuery(query: WebGLQuery): Engine;
  100610. /**
  100611. * Check if a given query has resolved and got its value
  100612. * @param query defines the query to check
  100613. * @returns true if the query got its value
  100614. */
  100615. isQueryResultAvailable(query: WebGLQuery): boolean;
  100616. /**
  100617. * Gets the value of a given query
  100618. * @param query defines the query to check
  100619. * @returns the value of the query
  100620. */
  100621. getQueryResult(query: WebGLQuery): number;
  100622. /**
  100623. * Initiates an occlusion query
  100624. * @param algorithmType defines the algorithm to use
  100625. * @param query defines the query to use
  100626. * @returns the current engine
  100627. * @see http://doc.babylonjs.com/features/occlusionquery
  100628. */
  100629. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100630. /**
  100631. * Ends an occlusion query
  100632. * @see http://doc.babylonjs.com/features/occlusionquery
  100633. * @param algorithmType defines the algorithm to use
  100634. * @returns the current engine
  100635. */
  100636. endOcclusionQuery(algorithmType: number): Engine;
  100637. /**
  100638. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100639. * Please note that only one query can be issued at a time
  100640. * @returns a time token used to track the time span
  100641. */
  100642. startTimeQuery(): Nullable<_TimeToken>;
  100643. /**
  100644. * Ends a time query
  100645. * @param token defines the token used to measure the time span
  100646. * @returns the time spent (in ns)
  100647. */
  100648. endTimeQuery(token: _TimeToken): int;
  100649. /** @hidden */
  100650. _currentNonTimestampToken: Nullable<_TimeToken>;
  100651. /** @hidden */
  100652. _createTimeQuery(): WebGLQuery;
  100653. /** @hidden */
  100654. _deleteTimeQuery(query: WebGLQuery): void;
  100655. /** @hidden */
  100656. _getGlAlgorithmType(algorithmType: number): number;
  100657. /** @hidden */
  100658. _getTimeQueryResult(query: WebGLQuery): any;
  100659. /** @hidden */
  100660. _getTimeQueryAvailability(query: WebGLQuery): any;
  100661. }
  100662. interface AbstractMesh {
  100663. /**
  100664. * Backing filed
  100665. * @hidden
  100666. */
  100667. __occlusionDataStorage: _OcclusionDataStorage;
  100668. /**
  100669. * Access property
  100670. * @hidden
  100671. */
  100672. _occlusionDataStorage: _OcclusionDataStorage;
  100673. /**
  100674. * 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.
  100675. * The default value is -1 which means don't break the query and wait till the result
  100676. * @see http://doc.babylonjs.com/features/occlusionquery
  100677. */
  100678. occlusionRetryCount: number;
  100679. /**
  100680. * 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:
  100681. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100682. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100683. * * 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.
  100684. * @see http://doc.babylonjs.com/features/occlusionquery
  100685. */
  100686. occlusionType: number;
  100687. /**
  100688. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100689. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100690. * * 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.
  100691. * @see http://doc.babylonjs.com/features/occlusionquery
  100692. */
  100693. occlusionQueryAlgorithmType: number;
  100694. /**
  100695. * 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
  100696. * @see http://doc.babylonjs.com/features/occlusionquery
  100697. */
  100698. isOccluded: boolean;
  100699. /**
  100700. * Flag to check the progress status of the query
  100701. * @see http://doc.babylonjs.com/features/occlusionquery
  100702. */
  100703. isOcclusionQueryInProgress: boolean;
  100704. }
  100705. }
  100706. declare module BABYLON {
  100707. /** @hidden */
  100708. export var _forceTransformFeedbackToBundle: boolean;
  100709. interface Engine {
  100710. /**
  100711. * Creates a webGL transform feedback object
  100712. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100713. * @returns the webGL transform feedback object
  100714. */
  100715. createTransformFeedback(): WebGLTransformFeedback;
  100716. /**
  100717. * Delete a webGL transform feedback object
  100718. * @param value defines the webGL transform feedback object to delete
  100719. */
  100720. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100721. /**
  100722. * Bind a webGL transform feedback object to the webgl context
  100723. * @param value defines the webGL transform feedback object to bind
  100724. */
  100725. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100726. /**
  100727. * Begins a transform feedback operation
  100728. * @param usePoints defines if points or triangles must be used
  100729. */
  100730. beginTransformFeedback(usePoints: boolean): void;
  100731. /**
  100732. * Ends a transform feedback operation
  100733. */
  100734. endTransformFeedback(): void;
  100735. /**
  100736. * Specify the varyings to use with transform feedback
  100737. * @param program defines the associated webGL program
  100738. * @param value defines the list of strings representing the varying names
  100739. */
  100740. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100741. /**
  100742. * Bind a webGL buffer for a transform feedback operation
  100743. * @param value defines the webGL buffer to bind
  100744. */
  100745. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * Gather the list of clipboard event types as constants.
  100751. */
  100752. export class ClipboardEventTypes {
  100753. /**
  100754. * The clipboard event is fired when a copy command is active (pressed).
  100755. */
  100756. static readonly COPY: number;
  100757. /**
  100758. * The clipboard event is fired when a cut command is active (pressed).
  100759. */
  100760. static readonly CUT: number;
  100761. /**
  100762. * The clipboard event is fired when a paste command is active (pressed).
  100763. */
  100764. static readonly PASTE: number;
  100765. }
  100766. /**
  100767. * This class is used to store clipboard related info for the onClipboardObservable event.
  100768. */
  100769. export class ClipboardInfo {
  100770. /**
  100771. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100772. */
  100773. type: number;
  100774. /**
  100775. * Defines the related dom event
  100776. */
  100777. event: ClipboardEvent;
  100778. /**
  100779. *Creates an instance of ClipboardInfo.
  100780. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100781. * @param event Defines the related dom event
  100782. */
  100783. constructor(
  100784. /**
  100785. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100786. */
  100787. type: number,
  100788. /**
  100789. * Defines the related dom event
  100790. */
  100791. event: ClipboardEvent);
  100792. /**
  100793. * Get the clipboard event's type from the keycode.
  100794. * @param keyCode Defines the keyCode for the current keyboard event.
  100795. * @return {number}
  100796. */
  100797. static GetTypeFromCharacter(keyCode: number): number;
  100798. }
  100799. }
  100800. declare module BABYLON {
  100801. /**
  100802. * Class used to represent data loading progression
  100803. */
  100804. export class SceneLoaderProgressEvent {
  100805. /** defines if data length to load can be evaluated */
  100806. readonly lengthComputable: boolean;
  100807. /** defines the loaded data length */
  100808. readonly loaded: number;
  100809. /** defines the data length to load */
  100810. readonly total: number;
  100811. /**
  100812. * Create a new progress event
  100813. * @param lengthComputable defines if data length to load can be evaluated
  100814. * @param loaded defines the loaded data length
  100815. * @param total defines the data length to load
  100816. */
  100817. constructor(
  100818. /** defines if data length to load can be evaluated */
  100819. lengthComputable: boolean,
  100820. /** defines the loaded data length */
  100821. loaded: number,
  100822. /** defines the data length to load */
  100823. total: number);
  100824. /**
  100825. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100826. * @param event defines the source event
  100827. * @returns a new SceneLoaderProgressEvent
  100828. */
  100829. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100830. }
  100831. /**
  100832. * Interface used by SceneLoader plugins to define supported file extensions
  100833. */
  100834. export interface ISceneLoaderPluginExtensions {
  100835. /**
  100836. * Defines the list of supported extensions
  100837. */
  100838. [extension: string]: {
  100839. isBinary: boolean;
  100840. };
  100841. }
  100842. /**
  100843. * Interface used by SceneLoader plugin factory
  100844. */
  100845. export interface ISceneLoaderPluginFactory {
  100846. /**
  100847. * Defines the name of the factory
  100848. */
  100849. name: string;
  100850. /**
  100851. * Function called to create a new plugin
  100852. * @return the new plugin
  100853. */
  100854. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100855. /**
  100856. * Boolean indicating if the plugin can direct load specific data
  100857. */
  100858. canDirectLoad?: (data: string) => boolean;
  100859. }
  100860. /**
  100861. * Interface used to define a SceneLoader plugin
  100862. */
  100863. export interface ISceneLoaderPlugin {
  100864. /**
  100865. * The friendly name of this plugin.
  100866. */
  100867. name: string;
  100868. /**
  100869. * The file extensions supported by this plugin.
  100870. */
  100871. extensions: string | ISceneLoaderPluginExtensions;
  100872. /**
  100873. * Import meshes into a scene.
  100874. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100875. * @param scene The scene to import into
  100876. * @param data The data to import
  100877. * @param rootUrl The root url for scene and resources
  100878. * @param meshes The meshes array to import into
  100879. * @param particleSystems The particle systems array to import into
  100880. * @param skeletons The skeletons array to import into
  100881. * @param onError The callback when import fails
  100882. * @returns True if successful or false otherwise
  100883. */
  100884. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100885. /**
  100886. * Load into a scene.
  100887. * @param scene The scene to load into
  100888. * @param data The data to import
  100889. * @param rootUrl The root url for scene and resources
  100890. * @param onError The callback when import fails
  100891. * @returns true if successful or false otherwise
  100892. */
  100893. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100894. /**
  100895. * The callback that returns true if the data can be directly loaded.
  100896. */
  100897. canDirectLoad?: (data: string) => boolean;
  100898. /**
  100899. * The callback that allows custom handling of the root url based on the response url.
  100900. */
  100901. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100902. /**
  100903. * Load into an asset container.
  100904. * @param scene The scene to load into
  100905. * @param data The data to import
  100906. * @param rootUrl The root url for scene and resources
  100907. * @param onError The callback when import fails
  100908. * @returns The loaded asset container
  100909. */
  100910. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100911. }
  100912. /**
  100913. * Interface used to define an async SceneLoader plugin
  100914. */
  100915. export interface ISceneLoaderPluginAsync {
  100916. /**
  100917. * The friendly name of this plugin.
  100918. */
  100919. name: string;
  100920. /**
  100921. * The file extensions supported by this plugin.
  100922. */
  100923. extensions: string | ISceneLoaderPluginExtensions;
  100924. /**
  100925. * Import meshes into a scene.
  100926. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100927. * @param scene The scene to import into
  100928. * @param data The data to import
  100929. * @param rootUrl The root url for scene and resources
  100930. * @param onProgress The callback when the load progresses
  100931. * @param fileName Defines the name of the file to load
  100932. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100933. */
  100934. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100935. meshes: AbstractMesh[];
  100936. particleSystems: IParticleSystem[];
  100937. skeletons: Skeleton[];
  100938. animationGroups: AnimationGroup[];
  100939. }>;
  100940. /**
  100941. * Load into a scene.
  100942. * @param scene The scene to load into
  100943. * @param data The data to import
  100944. * @param rootUrl The root url for scene and resources
  100945. * @param onProgress The callback when the load progresses
  100946. * @param fileName Defines the name of the file to load
  100947. * @returns Nothing
  100948. */
  100949. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100950. /**
  100951. * The callback that returns true if the data can be directly loaded.
  100952. */
  100953. canDirectLoad?: (data: string) => boolean;
  100954. /**
  100955. * The callback that allows custom handling of the root url based on the response url.
  100956. */
  100957. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100958. /**
  100959. * Load into an asset container.
  100960. * @param scene The scene to load into
  100961. * @param data The data to import
  100962. * @param rootUrl The root url for scene and resources
  100963. * @param onProgress The callback when the load progresses
  100964. * @param fileName Defines the name of the file to load
  100965. * @returns The loaded asset container
  100966. */
  100967. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100968. }
  100969. /**
  100970. * Class used to load scene from various file formats using registered plugins
  100971. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100972. */
  100973. export class SceneLoader {
  100974. /**
  100975. * No logging while loading
  100976. */
  100977. static readonly NO_LOGGING: number;
  100978. /**
  100979. * Minimal logging while loading
  100980. */
  100981. static readonly MINIMAL_LOGGING: number;
  100982. /**
  100983. * Summary logging while loading
  100984. */
  100985. static readonly SUMMARY_LOGGING: number;
  100986. /**
  100987. * Detailled logging while loading
  100988. */
  100989. static readonly DETAILED_LOGGING: number;
  100990. /**
  100991. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100992. */
  100993. static ForceFullSceneLoadingForIncremental: boolean;
  100994. /**
  100995. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100996. */
  100997. static ShowLoadingScreen: boolean;
  100998. /**
  100999. * Defines the current logging level (while loading the scene)
  101000. * @ignorenaming
  101001. */
  101002. static loggingLevel: number;
  101003. /**
  101004. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101005. */
  101006. static CleanBoneMatrixWeights: boolean;
  101007. /**
  101008. * Event raised when a plugin is used to load a scene
  101009. */
  101010. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101011. private static _registeredPlugins;
  101012. private static _getDefaultPlugin;
  101013. private static _getPluginForExtension;
  101014. private static _getPluginForDirectLoad;
  101015. private static _getPluginForFilename;
  101016. private static _getDirectLoad;
  101017. private static _loadData;
  101018. private static _getFileInfo;
  101019. /**
  101020. * Gets a plugin that can load the given extension
  101021. * @param extension defines the extension to load
  101022. * @returns a plugin or null if none works
  101023. */
  101024. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101025. /**
  101026. * Gets a boolean indicating that the given extension can be loaded
  101027. * @param extension defines the extension to load
  101028. * @returns true if the extension is supported
  101029. */
  101030. static IsPluginForExtensionAvailable(extension: string): boolean;
  101031. /**
  101032. * Adds a new plugin to the list of registered plugins
  101033. * @param plugin defines the plugin to add
  101034. */
  101035. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101036. /**
  101037. * Import meshes into a scene
  101038. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101039. * @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)
  101040. * @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)
  101041. * @param scene the instance of BABYLON.Scene to append to
  101042. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101043. * @param onProgress a callback with a progress event for each file being loaded
  101044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101045. * @param pluginExtension the extension used to determine the plugin
  101046. * @returns The loaded plugin
  101047. */
  101048. 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>;
  101049. /**
  101050. * Import meshes into a scene
  101051. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101052. * @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)
  101053. * @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)
  101054. * @param scene the instance of BABYLON.Scene to append to
  101055. * @param onProgress a callback with a progress event for each file being loaded
  101056. * @param pluginExtension the extension used to determine the plugin
  101057. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101058. */
  101059. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101060. meshes: AbstractMesh[];
  101061. particleSystems: IParticleSystem[];
  101062. skeletons: Skeleton[];
  101063. animationGroups: AnimationGroup[];
  101064. }>;
  101065. /**
  101066. * Load a scene
  101067. * @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)
  101068. * @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)
  101069. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101070. * @param onSuccess a callback with the scene when import succeeds
  101071. * @param onProgress a callback with a progress event for each file being loaded
  101072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101073. * @param pluginExtension the extension used to determine the plugin
  101074. * @returns The loaded plugin
  101075. */
  101076. 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>;
  101077. /**
  101078. * Load a scene
  101079. * @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)
  101080. * @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)
  101081. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101082. * @param onProgress a callback with a progress event for each file being loaded
  101083. * @param pluginExtension the extension used to determine the plugin
  101084. * @returns The loaded scene
  101085. */
  101086. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101087. /**
  101088. * Append a scene
  101089. * @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)
  101090. * @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)
  101091. * @param scene is the instance of BABYLON.Scene to append to
  101092. * @param onSuccess a callback with the scene when import succeeds
  101093. * @param onProgress a callback with a progress event for each file being loaded
  101094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101095. * @param pluginExtension the extension used to determine the plugin
  101096. * @returns The loaded plugin
  101097. */
  101098. 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>;
  101099. /**
  101100. * Append a scene
  101101. * @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)
  101102. * @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)
  101103. * @param scene is the instance of BABYLON.Scene to append to
  101104. * @param onProgress a callback with a progress event for each file being loaded
  101105. * @param pluginExtension the extension used to determine the plugin
  101106. * @returns The given scene
  101107. */
  101108. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101109. /**
  101110. * Load a scene into an asset container
  101111. * @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)
  101112. * @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)
  101113. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101114. * @param onSuccess a callback with the scene when import succeeds
  101115. * @param onProgress a callback with a progress event for each file being loaded
  101116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101117. * @param pluginExtension the extension used to determine the plugin
  101118. * @returns The loaded plugin
  101119. */
  101120. 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>;
  101121. /**
  101122. * Load a scene into an asset container
  101123. * @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)
  101124. * @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)
  101125. * @param scene is the instance of Scene to append to
  101126. * @param onProgress a callback with a progress event for each file being loaded
  101127. * @param pluginExtension the extension used to determine the plugin
  101128. * @returns The loaded asset container
  101129. */
  101130. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101131. }
  101132. }
  101133. declare module BABYLON {
  101134. /**
  101135. * Google Daydream controller
  101136. */
  101137. export class DaydreamController extends WebVRController {
  101138. /**
  101139. * Base Url for the controller model.
  101140. */
  101141. static MODEL_BASE_URL: string;
  101142. /**
  101143. * File name for the controller model.
  101144. */
  101145. static MODEL_FILENAME: string;
  101146. /**
  101147. * Gamepad Id prefix used to identify Daydream Controller.
  101148. */
  101149. static readonly GAMEPAD_ID_PREFIX: string;
  101150. /**
  101151. * Creates a new DaydreamController from a gamepad
  101152. * @param vrGamepad the gamepad that the controller should be created from
  101153. */
  101154. constructor(vrGamepad: any);
  101155. /**
  101156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101157. * @param scene scene in which to add meshes
  101158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101159. */
  101160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101161. /**
  101162. * Called once for each button that changed state since the last frame
  101163. * @param buttonIdx Which button index changed
  101164. * @param state New state of the button
  101165. * @param changes Which properties on the state changed since last frame
  101166. */
  101167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101168. }
  101169. }
  101170. declare module BABYLON {
  101171. /**
  101172. * Gear VR Controller
  101173. */
  101174. export class GearVRController extends WebVRController {
  101175. /**
  101176. * Base Url for the controller model.
  101177. */
  101178. static MODEL_BASE_URL: string;
  101179. /**
  101180. * File name for the controller model.
  101181. */
  101182. static MODEL_FILENAME: string;
  101183. /**
  101184. * Gamepad Id prefix used to identify this controller.
  101185. */
  101186. static readonly GAMEPAD_ID_PREFIX: string;
  101187. private readonly _buttonIndexToObservableNameMap;
  101188. /**
  101189. * Creates a new GearVRController from a gamepad
  101190. * @param vrGamepad the gamepad that the controller should be created from
  101191. */
  101192. constructor(vrGamepad: any);
  101193. /**
  101194. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101195. * @param scene scene in which to add meshes
  101196. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101197. */
  101198. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101199. /**
  101200. * Called once for each button that changed state since the last frame
  101201. * @param buttonIdx Which button index changed
  101202. * @param state New state of the button
  101203. * @param changes Which properties on the state changed since last frame
  101204. */
  101205. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101206. }
  101207. }
  101208. declare module BABYLON {
  101209. /**
  101210. * Generic Controller
  101211. */
  101212. export class GenericController extends WebVRController {
  101213. /**
  101214. * Base Url for the controller model.
  101215. */
  101216. static readonly MODEL_BASE_URL: string;
  101217. /**
  101218. * File name for the controller model.
  101219. */
  101220. static readonly MODEL_FILENAME: string;
  101221. /**
  101222. * Creates a new GenericController from a gamepad
  101223. * @param vrGamepad the gamepad that the controller should be created from
  101224. */
  101225. constructor(vrGamepad: any);
  101226. /**
  101227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101228. * @param scene scene in which to add meshes
  101229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101230. */
  101231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101232. /**
  101233. * Called once for each button that changed state since the last frame
  101234. * @param buttonIdx Which button index changed
  101235. * @param state New state of the button
  101236. * @param changes Which properties on the state changed since last frame
  101237. */
  101238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101239. }
  101240. }
  101241. declare module BABYLON {
  101242. /**
  101243. * Oculus Touch Controller
  101244. */
  101245. export class OculusTouchController extends WebVRController {
  101246. /**
  101247. * Base Url for the controller model.
  101248. */
  101249. static MODEL_BASE_URL: string;
  101250. /**
  101251. * File name for the left controller model.
  101252. */
  101253. static MODEL_LEFT_FILENAME: string;
  101254. /**
  101255. * File name for the right controller model.
  101256. */
  101257. static MODEL_RIGHT_FILENAME: string;
  101258. /**
  101259. * Fired when the secondary trigger on this controller is modified
  101260. */
  101261. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101262. /**
  101263. * Fired when the thumb rest on this controller is modified
  101264. */
  101265. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101266. /**
  101267. * Creates a new OculusTouchController from a gamepad
  101268. * @param vrGamepad the gamepad that the controller should be created from
  101269. */
  101270. constructor(vrGamepad: any);
  101271. /**
  101272. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101273. * @param scene scene in which to add meshes
  101274. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101275. */
  101276. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101277. /**
  101278. * Fired when the A button on this controller is modified
  101279. */
  101280. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101281. /**
  101282. * Fired when the B button on this controller is modified
  101283. */
  101284. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101285. /**
  101286. * Fired when the X button on this controller is modified
  101287. */
  101288. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101289. /**
  101290. * Fired when the Y button on this controller is modified
  101291. */
  101292. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101293. /**
  101294. * Called once for each button that changed state since the last frame
  101295. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101296. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101297. * 2) secondary trigger (same)
  101298. * 3) A (right) X (left), touch, pressed = value
  101299. * 4) B / Y
  101300. * 5) thumb rest
  101301. * @param buttonIdx Which button index changed
  101302. * @param state New state of the button
  101303. * @param changes Which properties on the state changed since last frame
  101304. */
  101305. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101306. }
  101307. }
  101308. declare module BABYLON {
  101309. /**
  101310. * Vive Controller
  101311. */
  101312. export class ViveController extends WebVRController {
  101313. /**
  101314. * Base Url for the controller model.
  101315. */
  101316. static MODEL_BASE_URL: string;
  101317. /**
  101318. * File name for the controller model.
  101319. */
  101320. static MODEL_FILENAME: string;
  101321. /**
  101322. * Creates a new ViveController from a gamepad
  101323. * @param vrGamepad the gamepad that the controller should be created from
  101324. */
  101325. constructor(vrGamepad: any);
  101326. /**
  101327. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101328. * @param scene scene in which to add meshes
  101329. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101330. */
  101331. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101332. /**
  101333. * Fired when the left button on this controller is modified
  101334. */
  101335. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101336. /**
  101337. * Fired when the right button on this controller is modified
  101338. */
  101339. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101340. /**
  101341. * Fired when the menu button on this controller is modified
  101342. */
  101343. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101344. /**
  101345. * Called once for each button that changed state since the last frame
  101346. * Vive mapping:
  101347. * 0: touchpad
  101348. * 1: trigger
  101349. * 2: left AND right buttons
  101350. * 3: menu button
  101351. * @param buttonIdx Which button index changed
  101352. * @param state New state of the button
  101353. * @param changes Which properties on the state changed since last frame
  101354. */
  101355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101356. }
  101357. }
  101358. declare module BABYLON {
  101359. /**
  101360. * Defines the WindowsMotionController object that the state of the windows motion controller
  101361. */
  101362. export class WindowsMotionController extends WebVRController {
  101363. /**
  101364. * The base url used to load the left and right controller models
  101365. */
  101366. static MODEL_BASE_URL: string;
  101367. /**
  101368. * The name of the left controller model file
  101369. */
  101370. static MODEL_LEFT_FILENAME: string;
  101371. /**
  101372. * The name of the right controller model file
  101373. */
  101374. static MODEL_RIGHT_FILENAME: string;
  101375. /**
  101376. * The controller name prefix for this controller type
  101377. */
  101378. static readonly GAMEPAD_ID_PREFIX: string;
  101379. /**
  101380. * The controller id pattern for this controller type
  101381. */
  101382. private static readonly GAMEPAD_ID_PATTERN;
  101383. private _loadedMeshInfo;
  101384. private readonly _mapping;
  101385. /**
  101386. * Fired when the trackpad on this controller is clicked
  101387. */
  101388. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101389. /**
  101390. * Fired when the trackpad on this controller is modified
  101391. */
  101392. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101393. /**
  101394. * The current x and y values of this controller's trackpad
  101395. */
  101396. trackpad: StickValues;
  101397. /**
  101398. * Creates a new WindowsMotionController from a gamepad
  101399. * @param vrGamepad the gamepad that the controller should be created from
  101400. */
  101401. constructor(vrGamepad: any);
  101402. /**
  101403. * Fired when the trigger on this controller is modified
  101404. */
  101405. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101406. /**
  101407. * Fired when the menu button on this controller is modified
  101408. */
  101409. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101410. /**
  101411. * Fired when the grip button on this controller is modified
  101412. */
  101413. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101414. /**
  101415. * Fired when the thumbstick button on this controller is modified
  101416. */
  101417. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101418. /**
  101419. * Fired when the touchpad button on this controller is modified
  101420. */
  101421. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101422. /**
  101423. * Fired when the touchpad values on this controller are modified
  101424. */
  101425. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101426. private _updateTrackpad;
  101427. /**
  101428. * Called once per frame by the engine.
  101429. */
  101430. update(): void;
  101431. /**
  101432. * Called once for each button that changed state since the last frame
  101433. * @param buttonIdx Which button index changed
  101434. * @param state New state of the button
  101435. * @param changes Which properties on the state changed since last frame
  101436. */
  101437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101438. /**
  101439. * Moves the buttons on the controller mesh based on their current state
  101440. * @param buttonName the name of the button to move
  101441. * @param buttonValue the value of the button which determines the buttons new position
  101442. */
  101443. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101444. /**
  101445. * Moves the axis on the controller mesh based on its current state
  101446. * @param axis the index of the axis
  101447. * @param axisValue the value of the axis which determines the meshes new position
  101448. * @hidden
  101449. */
  101450. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101451. /**
  101452. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101453. * @param scene scene in which to add meshes
  101454. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101455. */
  101456. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101457. /**
  101458. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101459. * can be transformed by button presses and axes values, based on this._mapping.
  101460. *
  101461. * @param scene scene in which the meshes exist
  101462. * @param meshes list of meshes that make up the controller model to process
  101463. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101464. */
  101465. private processModel;
  101466. private createMeshInfo;
  101467. /**
  101468. * Gets the ray of the controller in the direction the controller is pointing
  101469. * @param length the length the resulting ray should be
  101470. * @returns a ray in the direction the controller is pointing
  101471. */
  101472. getForwardRay(length?: number): Ray;
  101473. /**
  101474. * Disposes of the controller
  101475. */
  101476. dispose(): void;
  101477. }
  101478. }
  101479. declare module BABYLON {
  101480. /**
  101481. * Single axis scale gizmo
  101482. */
  101483. export class AxisScaleGizmo extends Gizmo {
  101484. private _coloredMaterial;
  101485. /**
  101486. * Drag behavior responsible for the gizmos dragging interactions
  101487. */
  101488. dragBehavior: PointerDragBehavior;
  101489. private _pointerObserver;
  101490. /**
  101491. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101492. */
  101493. snapDistance: number;
  101494. /**
  101495. * Event that fires each time the gizmo snaps to a new location.
  101496. * * snapDistance is the the change in distance
  101497. */
  101498. onSnapObservable: Observable<{
  101499. snapDistance: number;
  101500. }>;
  101501. /**
  101502. * If the scaling operation should be done on all axis (default: false)
  101503. */
  101504. uniformScaling: boolean;
  101505. /**
  101506. * Creates an AxisScaleGizmo
  101507. * @param gizmoLayer The utility layer the gizmo will be added to
  101508. * @param dragAxis The axis which the gizmo will be able to scale on
  101509. * @param color The color of the gizmo
  101510. */
  101511. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101512. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101513. /**
  101514. * Disposes of the gizmo
  101515. */
  101516. dispose(): void;
  101517. /**
  101518. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101519. * @param mesh The mesh to replace the default mesh of the gizmo
  101520. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101521. */
  101522. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101523. }
  101524. }
  101525. declare module BABYLON {
  101526. /**
  101527. * Bounding box gizmo
  101528. */
  101529. export class BoundingBoxGizmo extends Gizmo {
  101530. private _lineBoundingBox;
  101531. private _rotateSpheresParent;
  101532. private _scaleBoxesParent;
  101533. private _boundingDimensions;
  101534. private _renderObserver;
  101535. private _pointerObserver;
  101536. private _scaleDragSpeed;
  101537. private _tmpQuaternion;
  101538. private _tmpVector;
  101539. private _tmpRotationMatrix;
  101540. /**
  101541. * 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)
  101542. */
  101543. ignoreChildren: boolean;
  101544. /**
  101545. * 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)
  101546. */
  101547. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101548. /**
  101549. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101550. */
  101551. rotationSphereSize: number;
  101552. /**
  101553. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101554. */
  101555. scaleBoxSize: number;
  101556. /**
  101557. * 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)
  101558. */
  101559. fixedDragMeshScreenSize: boolean;
  101560. /**
  101561. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101562. */
  101563. fixedDragMeshScreenSizeDistanceFactor: number;
  101564. /**
  101565. * Fired when a rotation sphere or scale box is dragged
  101566. */
  101567. onDragStartObservable: Observable<{}>;
  101568. /**
  101569. * Fired when a scale box is dragged
  101570. */
  101571. onScaleBoxDragObservable: Observable<{}>;
  101572. /**
  101573. * Fired when a scale box drag is ended
  101574. */
  101575. onScaleBoxDragEndObservable: Observable<{}>;
  101576. /**
  101577. * Fired when a rotation sphere is dragged
  101578. */
  101579. onRotationSphereDragObservable: Observable<{}>;
  101580. /**
  101581. * Fired when a rotation sphere drag is ended
  101582. */
  101583. onRotationSphereDragEndObservable: Observable<{}>;
  101584. /**
  101585. * 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)
  101586. */
  101587. scalePivot: Nullable<Vector3>;
  101588. private _anchorMesh;
  101589. private _existingMeshScale;
  101590. private _dragMesh;
  101591. private pointerDragBehavior;
  101592. private coloredMaterial;
  101593. private hoverColoredMaterial;
  101594. /**
  101595. * Sets the color of the bounding box gizmo
  101596. * @param color the color to set
  101597. */
  101598. setColor(color: Color3): void;
  101599. /**
  101600. * Creates an BoundingBoxGizmo
  101601. * @param gizmoLayer The utility layer the gizmo will be added to
  101602. * @param color The color of the gizmo
  101603. */
  101604. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101606. private _selectNode;
  101607. /**
  101608. * Updates the bounding box information for the Gizmo
  101609. */
  101610. updateBoundingBox(): void;
  101611. private _updateRotationSpheres;
  101612. private _updateScaleBoxes;
  101613. /**
  101614. * Enables rotation on the specified axis and disables rotation on the others
  101615. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101616. */
  101617. setEnabledRotationAxis(axis: string): void;
  101618. /**
  101619. * Enables/disables scaling
  101620. * @param enable if scaling should be enabled
  101621. */
  101622. setEnabledScaling(enable: boolean): void;
  101623. private _updateDummy;
  101624. /**
  101625. * Enables a pointer drag behavior on the bounding box of the gizmo
  101626. */
  101627. enableDragBehavior(): void;
  101628. /**
  101629. * Disposes of the gizmo
  101630. */
  101631. dispose(): void;
  101632. /**
  101633. * 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)
  101634. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101635. * @returns the bounding box mesh with the passed in mesh as a child
  101636. */
  101637. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101638. /**
  101639. * CustomMeshes are not supported by this gizmo
  101640. * @param mesh The mesh to replace the default mesh of the gizmo
  101641. */
  101642. setCustomMesh(mesh: Mesh): void;
  101643. }
  101644. }
  101645. declare module BABYLON {
  101646. /**
  101647. * Single plane rotation gizmo
  101648. */
  101649. export class PlaneRotationGizmo extends Gizmo {
  101650. /**
  101651. * Drag behavior responsible for the gizmos dragging interactions
  101652. */
  101653. dragBehavior: PointerDragBehavior;
  101654. private _pointerObserver;
  101655. /**
  101656. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101657. */
  101658. snapDistance: number;
  101659. /**
  101660. * Event that fires each time the gizmo snaps to a new location.
  101661. * * snapDistance is the the change in distance
  101662. */
  101663. onSnapObservable: Observable<{
  101664. snapDistance: number;
  101665. }>;
  101666. /**
  101667. * Creates a PlaneRotationGizmo
  101668. * @param gizmoLayer The utility layer the gizmo will be added to
  101669. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101670. * @param color The color of the gizmo
  101671. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101672. */
  101673. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101675. /**
  101676. * Disposes of the gizmo
  101677. */
  101678. dispose(): void;
  101679. }
  101680. }
  101681. declare module BABYLON {
  101682. /**
  101683. * Gizmo that enables rotating a mesh along 3 axis
  101684. */
  101685. export class RotationGizmo extends Gizmo {
  101686. /**
  101687. * Internal gizmo used for interactions on the x axis
  101688. */
  101689. xGizmo: PlaneRotationGizmo;
  101690. /**
  101691. * Internal gizmo used for interactions on the y axis
  101692. */
  101693. yGizmo: PlaneRotationGizmo;
  101694. /**
  101695. * Internal gizmo used for interactions on the z axis
  101696. */
  101697. zGizmo: PlaneRotationGizmo;
  101698. /** Fires an event when any of it's sub gizmos are dragged */
  101699. onDragStartObservable: Observable<{}>;
  101700. /** Fires an event when any of it's sub gizmos are released from dragging */
  101701. onDragEndObservable: Observable<{}>;
  101702. attachedMesh: Nullable<AbstractMesh>;
  101703. /**
  101704. * Creates a RotationGizmo
  101705. * @param gizmoLayer The utility layer the gizmo will be added to
  101706. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101707. */
  101708. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101709. updateGizmoRotationToMatchAttachedMesh: boolean;
  101710. /**
  101711. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101712. */
  101713. snapDistance: number;
  101714. /**
  101715. * Ratio for the scale of the gizmo (Default: 1)
  101716. */
  101717. scaleRatio: number;
  101718. /**
  101719. * Disposes of the gizmo
  101720. */
  101721. dispose(): void;
  101722. /**
  101723. * CustomMeshes are not supported by this gizmo
  101724. * @param mesh The mesh to replace the default mesh of the gizmo
  101725. */
  101726. setCustomMesh(mesh: Mesh): void;
  101727. }
  101728. }
  101729. declare module BABYLON {
  101730. /**
  101731. * Gizmo that enables dragging a mesh along 3 axis
  101732. */
  101733. export class PositionGizmo extends Gizmo {
  101734. /**
  101735. * Internal gizmo used for interactions on the x axis
  101736. */
  101737. xGizmo: AxisDragGizmo;
  101738. /**
  101739. * Internal gizmo used for interactions on the y axis
  101740. */
  101741. yGizmo: AxisDragGizmo;
  101742. /**
  101743. * Internal gizmo used for interactions on the z axis
  101744. */
  101745. zGizmo: AxisDragGizmo;
  101746. /** Fires an event when any of it's sub gizmos are dragged */
  101747. onDragStartObservable: Observable<{}>;
  101748. /** Fires an event when any of it's sub gizmos are released from dragging */
  101749. onDragEndObservable: Observable<{}>;
  101750. attachedMesh: Nullable<AbstractMesh>;
  101751. /**
  101752. * Creates a PositionGizmo
  101753. * @param gizmoLayer The utility layer the gizmo will be added to
  101754. */
  101755. constructor(gizmoLayer?: UtilityLayerRenderer);
  101756. updateGizmoRotationToMatchAttachedMesh: boolean;
  101757. /**
  101758. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101759. */
  101760. snapDistance: number;
  101761. /**
  101762. * Ratio for the scale of the gizmo (Default: 1)
  101763. */
  101764. scaleRatio: number;
  101765. /**
  101766. * Disposes of the gizmo
  101767. */
  101768. dispose(): void;
  101769. /**
  101770. * CustomMeshes are not supported by this gizmo
  101771. * @param mesh The mesh to replace the default mesh of the gizmo
  101772. */
  101773. setCustomMesh(mesh: Mesh): void;
  101774. }
  101775. }
  101776. declare module BABYLON {
  101777. /**
  101778. * Class containing static functions to help procedurally build meshes
  101779. */
  101780. export class PolyhedronBuilder {
  101781. /**
  101782. * Creates a polyhedron mesh
  101783. * * 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
  101784. * * The parameter `size` (positive float, default 1) sets the polygon size
  101785. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101786. * * 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`
  101787. * * 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
  101788. * * 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)`)
  101789. * * 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
  101790. * * 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
  101791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101794. * @param name defines the name of the mesh
  101795. * @param options defines the options used to create the mesh
  101796. * @param scene defines the hosting scene
  101797. * @returns the polyhedron mesh
  101798. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101799. */
  101800. static CreatePolyhedron(name: string, options: {
  101801. type?: number;
  101802. size?: number;
  101803. sizeX?: number;
  101804. sizeY?: number;
  101805. sizeZ?: number;
  101806. custom?: any;
  101807. faceUV?: Vector4[];
  101808. faceColors?: Color4[];
  101809. flat?: boolean;
  101810. updatable?: boolean;
  101811. sideOrientation?: number;
  101812. frontUVs?: Vector4;
  101813. backUVs?: Vector4;
  101814. }, scene?: Nullable<Scene>): Mesh;
  101815. }
  101816. }
  101817. declare module BABYLON {
  101818. /**
  101819. * Gizmo that enables scaling a mesh along 3 axis
  101820. */
  101821. export class ScaleGizmo extends Gizmo {
  101822. /**
  101823. * Internal gizmo used for interactions on the x axis
  101824. */
  101825. xGizmo: AxisScaleGizmo;
  101826. /**
  101827. * Internal gizmo used for interactions on the y axis
  101828. */
  101829. yGizmo: AxisScaleGizmo;
  101830. /**
  101831. * Internal gizmo used for interactions on the z axis
  101832. */
  101833. zGizmo: AxisScaleGizmo;
  101834. /**
  101835. * Internal gizmo used to scale all axis equally
  101836. */
  101837. uniformScaleGizmo: AxisScaleGizmo;
  101838. /** Fires an event when any of it's sub gizmos are dragged */
  101839. onDragStartObservable: Observable<{}>;
  101840. /** Fires an event when any of it's sub gizmos are released from dragging */
  101841. onDragEndObservable: Observable<{}>;
  101842. attachedMesh: Nullable<AbstractMesh>;
  101843. /**
  101844. * Creates a ScaleGizmo
  101845. * @param gizmoLayer The utility layer the gizmo will be added to
  101846. */
  101847. constructor(gizmoLayer?: UtilityLayerRenderer);
  101848. updateGizmoRotationToMatchAttachedMesh: boolean;
  101849. /**
  101850. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101851. */
  101852. snapDistance: number;
  101853. /**
  101854. * Ratio for the scale of the gizmo (Default: 1)
  101855. */
  101856. scaleRatio: number;
  101857. /**
  101858. * Disposes of the gizmo
  101859. */
  101860. dispose(): void;
  101861. }
  101862. }
  101863. declare module BABYLON {
  101864. /**
  101865. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101866. */
  101867. export class GizmoManager implements IDisposable {
  101868. private scene;
  101869. /**
  101870. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101871. */
  101872. gizmos: {
  101873. positionGizmo: Nullable<PositionGizmo>;
  101874. rotationGizmo: Nullable<RotationGizmo>;
  101875. scaleGizmo: Nullable<ScaleGizmo>;
  101876. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101877. };
  101878. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101879. clearGizmoOnEmptyPointerEvent: boolean;
  101880. /** Fires an event when the manager is attached to a mesh */
  101881. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101882. private _gizmosEnabled;
  101883. private _pointerObserver;
  101884. private _attachedMesh;
  101885. private _boundingBoxColor;
  101886. private _defaultUtilityLayer;
  101887. private _defaultKeepDepthUtilityLayer;
  101888. /**
  101889. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101890. */
  101891. boundingBoxDragBehavior: SixDofDragBehavior;
  101892. /**
  101893. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101894. */
  101895. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101896. /**
  101897. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101898. */
  101899. usePointerToAttachGizmos: boolean;
  101900. /**
  101901. * Instatiates a gizmo manager
  101902. * @param scene the scene to overlay the gizmos on top of
  101903. */
  101904. constructor(scene: Scene);
  101905. /**
  101906. * Attaches a set of gizmos to the specified mesh
  101907. * @param mesh The mesh the gizmo's should be attached to
  101908. */
  101909. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101910. /**
  101911. * If the position gizmo is enabled
  101912. */
  101913. positionGizmoEnabled: boolean;
  101914. /**
  101915. * If the rotation gizmo is enabled
  101916. */
  101917. rotationGizmoEnabled: boolean;
  101918. /**
  101919. * If the scale gizmo is enabled
  101920. */
  101921. scaleGizmoEnabled: boolean;
  101922. /**
  101923. * If the boundingBox gizmo is enabled
  101924. */
  101925. boundingBoxGizmoEnabled: boolean;
  101926. /**
  101927. * Disposes of the gizmo manager
  101928. */
  101929. dispose(): void;
  101930. }
  101931. }
  101932. declare module BABYLON {
  101933. /**
  101934. * A directional light is defined by a direction (what a surprise!).
  101935. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101936. * 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.
  101937. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101938. */
  101939. export class DirectionalLight extends ShadowLight {
  101940. private _shadowFrustumSize;
  101941. /**
  101942. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101943. */
  101944. /**
  101945. * Specifies a fix frustum size for the shadow generation.
  101946. */
  101947. shadowFrustumSize: number;
  101948. private _shadowOrthoScale;
  101949. /**
  101950. * Gets the shadow projection scale against the optimal computed one.
  101951. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101952. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101953. */
  101954. /**
  101955. * Sets the shadow projection scale against the optimal computed one.
  101956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101958. */
  101959. shadowOrthoScale: number;
  101960. /**
  101961. * Automatically compute the projection matrix to best fit (including all the casters)
  101962. * on each frame.
  101963. */
  101964. autoUpdateExtends: boolean;
  101965. private _orthoLeft;
  101966. private _orthoRight;
  101967. private _orthoTop;
  101968. private _orthoBottom;
  101969. /**
  101970. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101971. * The directional light is emitted from everywhere in the given direction.
  101972. * It can cast shadows.
  101973. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101974. * @param name The friendly name of the light
  101975. * @param direction The direction of the light
  101976. * @param scene The scene the light belongs to
  101977. */
  101978. constructor(name: string, direction: Vector3, scene: Scene);
  101979. /**
  101980. * Returns the string "DirectionalLight".
  101981. * @return The class name
  101982. */
  101983. getClassName(): string;
  101984. /**
  101985. * Returns the integer 1.
  101986. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101987. */
  101988. getTypeID(): number;
  101989. /**
  101990. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101991. * Returns the DirectionalLight Shadow projection matrix.
  101992. */
  101993. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101994. /**
  101995. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101996. * Returns the DirectionalLight Shadow projection matrix.
  101997. */
  101998. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101999. /**
  102000. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102001. * Returns the DirectionalLight Shadow projection matrix.
  102002. */
  102003. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102004. protected _buildUniformLayout(): void;
  102005. /**
  102006. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102007. * @param effect The effect to update
  102008. * @param lightIndex The index of the light in the effect to update
  102009. * @returns The directional light
  102010. */
  102011. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102012. /**
  102013. * Gets the minZ used for shadow according to both the scene and the light.
  102014. *
  102015. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102016. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102017. * @param activeCamera The camera we are returning the min for
  102018. * @returns the depth min z
  102019. */
  102020. getDepthMinZ(activeCamera: Camera): number;
  102021. /**
  102022. * Gets the maxZ used for shadow according to both the scene and the light.
  102023. *
  102024. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102025. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102026. * @param activeCamera The camera we are returning the max for
  102027. * @returns the depth max z
  102028. */
  102029. getDepthMaxZ(activeCamera: Camera): number;
  102030. /**
  102031. * Prepares the list of defines specific to the light type.
  102032. * @param defines the list of defines
  102033. * @param lightIndex defines the index of the light for the effect
  102034. */
  102035. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102036. }
  102037. }
  102038. declare module BABYLON {
  102039. /**
  102040. * Class containing static functions to help procedurally build meshes
  102041. */
  102042. export class HemisphereBuilder {
  102043. /**
  102044. * Creates a hemisphere mesh
  102045. * @param name defines the name of the mesh
  102046. * @param options defines the options used to create the mesh
  102047. * @param scene defines the hosting scene
  102048. * @returns the hemisphere mesh
  102049. */
  102050. static CreateHemisphere(name: string, options: {
  102051. segments?: number;
  102052. diameter?: number;
  102053. sideOrientation?: number;
  102054. }, scene: any): Mesh;
  102055. }
  102056. }
  102057. declare module BABYLON {
  102058. /**
  102059. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102060. * These values define a cone of light starting from the position, emitting toward the direction.
  102061. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102062. * and the exponent defines the speed of the decay of the light with distance (reach).
  102063. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102064. */
  102065. export class SpotLight extends ShadowLight {
  102066. private _angle;
  102067. private _innerAngle;
  102068. private _cosHalfAngle;
  102069. private _lightAngleScale;
  102070. private _lightAngleOffset;
  102071. /**
  102072. * Gets the cone angle of the spot light in Radians.
  102073. */
  102074. /**
  102075. * Sets the cone angle of the spot light in Radians.
  102076. */
  102077. angle: number;
  102078. /**
  102079. * Only used in gltf falloff mode, this defines the angle where
  102080. * the directional falloff will start before cutting at angle which could be seen
  102081. * as outer angle.
  102082. */
  102083. /**
  102084. * Only used in gltf falloff mode, this defines the angle where
  102085. * the directional falloff will start before cutting at angle which could be seen
  102086. * as outer angle.
  102087. */
  102088. innerAngle: number;
  102089. private _shadowAngleScale;
  102090. /**
  102091. * Allows scaling the angle of the light for shadow generation only.
  102092. */
  102093. /**
  102094. * Allows scaling the angle of the light for shadow generation only.
  102095. */
  102096. shadowAngleScale: number;
  102097. /**
  102098. * The light decay speed with the distance from the emission spot.
  102099. */
  102100. exponent: number;
  102101. private _projectionTextureMatrix;
  102102. /**
  102103. * Allows reading the projecton texture
  102104. */
  102105. readonly projectionTextureMatrix: Matrix;
  102106. protected _projectionTextureLightNear: number;
  102107. /**
  102108. * Gets the near clip of the Spotlight for texture projection.
  102109. */
  102110. /**
  102111. * Sets the near clip of the Spotlight for texture projection.
  102112. */
  102113. projectionTextureLightNear: number;
  102114. protected _projectionTextureLightFar: number;
  102115. /**
  102116. * Gets the far clip of the Spotlight for texture projection.
  102117. */
  102118. /**
  102119. * Sets the far clip of the Spotlight for texture projection.
  102120. */
  102121. projectionTextureLightFar: number;
  102122. protected _projectionTextureUpDirection: Vector3;
  102123. /**
  102124. * Gets the Up vector of the Spotlight for texture projection.
  102125. */
  102126. /**
  102127. * Sets the Up vector of the Spotlight for texture projection.
  102128. */
  102129. projectionTextureUpDirection: Vector3;
  102130. private _projectionTexture;
  102131. /**
  102132. * Gets the projection texture of the light.
  102133. */
  102134. /**
  102135. * Sets the projection texture of the light.
  102136. */
  102137. projectionTexture: Nullable<BaseTexture>;
  102138. private _projectionTextureViewLightDirty;
  102139. private _projectionTextureProjectionLightDirty;
  102140. private _projectionTextureDirty;
  102141. private _projectionTextureViewTargetVector;
  102142. private _projectionTextureViewLightMatrix;
  102143. private _projectionTextureProjectionLightMatrix;
  102144. private _projectionTextureScalingMatrix;
  102145. /**
  102146. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102147. * It can cast shadows.
  102148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102149. * @param name The light friendly name
  102150. * @param position The position of the spot light in the scene
  102151. * @param direction The direction of the light in the scene
  102152. * @param angle The cone angle of the light in Radians
  102153. * @param exponent The light decay speed with the distance from the emission spot
  102154. * @param scene The scene the lights belongs to
  102155. */
  102156. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102157. /**
  102158. * Returns the string "SpotLight".
  102159. * @returns the class name
  102160. */
  102161. getClassName(): string;
  102162. /**
  102163. * Returns the integer 2.
  102164. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102165. */
  102166. getTypeID(): number;
  102167. /**
  102168. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102169. */
  102170. protected _setDirection(value: Vector3): void;
  102171. /**
  102172. * Overrides the position setter to recompute the projection texture view light Matrix.
  102173. */
  102174. protected _setPosition(value: Vector3): void;
  102175. /**
  102176. * 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.
  102177. * Returns the SpotLight.
  102178. */
  102179. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102180. protected _computeProjectionTextureViewLightMatrix(): void;
  102181. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102182. /**
  102183. * Main function for light texture projection matrix computing.
  102184. */
  102185. protected _computeProjectionTextureMatrix(): void;
  102186. protected _buildUniformLayout(): void;
  102187. private _computeAngleValues;
  102188. /**
  102189. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102190. * @param effect The effect to update
  102191. * @param lightIndex The index of the light in the effect to update
  102192. * @returns The spot light
  102193. */
  102194. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102195. /**
  102196. * Disposes the light and the associated resources.
  102197. */
  102198. dispose(): void;
  102199. /**
  102200. * Prepares the list of defines specific to the light type.
  102201. * @param defines the list of defines
  102202. * @param lightIndex defines the index of the light for the effect
  102203. */
  102204. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102205. }
  102206. }
  102207. declare module BABYLON {
  102208. /**
  102209. * Gizmo that enables viewing a light
  102210. */
  102211. export class LightGizmo extends Gizmo {
  102212. private _lightMesh;
  102213. private _material;
  102214. /**
  102215. * Creates a LightGizmo
  102216. * @param gizmoLayer The utility layer the gizmo will be added to
  102217. */
  102218. constructor(gizmoLayer?: UtilityLayerRenderer);
  102219. private _light;
  102220. /**
  102221. * The light that the gizmo is attached to
  102222. */
  102223. light: Nullable<Light>;
  102224. /**
  102225. * @hidden
  102226. * Updates the gizmo to match the attached mesh's position/rotation
  102227. */
  102228. protected _update(): void;
  102229. private static _Scale;
  102230. /**
  102231. * Creates the lines for a light mesh
  102232. */
  102233. private static _createLightLines;
  102234. private static _CreateHemisphericLightMesh;
  102235. private static _CreatePointLightMesh;
  102236. private static _CreateSpotLightMesh;
  102237. private static _CreateDirectionalLightMesh;
  102238. }
  102239. }
  102240. declare module BABYLON {
  102241. /** @hidden */
  102242. export var backgroundFragmentDeclaration: {
  102243. name: string;
  102244. shader: string;
  102245. };
  102246. }
  102247. declare module BABYLON {
  102248. /** @hidden */
  102249. export var backgroundUboDeclaration: {
  102250. name: string;
  102251. shader: string;
  102252. };
  102253. }
  102254. declare module BABYLON {
  102255. /** @hidden */
  102256. export var backgroundPixelShader: {
  102257. name: string;
  102258. shader: string;
  102259. };
  102260. }
  102261. declare module BABYLON {
  102262. /** @hidden */
  102263. export var backgroundVertexDeclaration: {
  102264. name: string;
  102265. shader: string;
  102266. };
  102267. }
  102268. declare module BABYLON {
  102269. /** @hidden */
  102270. export var backgroundVertexShader: {
  102271. name: string;
  102272. shader: string;
  102273. };
  102274. }
  102275. declare module BABYLON {
  102276. /**
  102277. * Background material used to create an efficient environement around your scene.
  102278. */
  102279. export class BackgroundMaterial extends PushMaterial {
  102280. /**
  102281. * Standard reflectance value at parallel view angle.
  102282. */
  102283. static StandardReflectance0: number;
  102284. /**
  102285. * Standard reflectance value at grazing angle.
  102286. */
  102287. static StandardReflectance90: number;
  102288. protected _primaryColor: Color3;
  102289. /**
  102290. * Key light Color (multiply against the environement texture)
  102291. */
  102292. primaryColor: Color3;
  102293. protected __perceptualColor: Nullable<Color3>;
  102294. /**
  102295. * Experimental Internal Use Only.
  102296. *
  102297. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102298. * This acts as a helper to set the primary color to a more "human friendly" value.
  102299. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102300. * output color as close as possible from the chosen value.
  102301. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102302. * part of lighting setup.)
  102303. */
  102304. _perceptualColor: Nullable<Color3>;
  102305. protected _primaryColorShadowLevel: float;
  102306. /**
  102307. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102308. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102309. */
  102310. primaryColorShadowLevel: float;
  102311. protected _primaryColorHighlightLevel: float;
  102312. /**
  102313. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102314. * The primary color is used at the level chosen to define what the white area would look.
  102315. */
  102316. primaryColorHighlightLevel: float;
  102317. protected _reflectionTexture: Nullable<BaseTexture>;
  102318. /**
  102319. * Reflection Texture used in the material.
  102320. * Should be author in a specific way for the best result (refer to the documentation).
  102321. */
  102322. reflectionTexture: Nullable<BaseTexture>;
  102323. protected _reflectionBlur: float;
  102324. /**
  102325. * Reflection Texture level of blur.
  102326. *
  102327. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102328. * texture twice.
  102329. */
  102330. reflectionBlur: float;
  102331. protected _diffuseTexture: Nullable<BaseTexture>;
  102332. /**
  102333. * Diffuse Texture used in the material.
  102334. * Should be author in a specific way for the best result (refer to the documentation).
  102335. */
  102336. diffuseTexture: Nullable<BaseTexture>;
  102337. protected _shadowLights: Nullable<IShadowLight[]>;
  102338. /**
  102339. * Specify the list of lights casting shadow on the material.
  102340. * All scene shadow lights will be included if null.
  102341. */
  102342. shadowLights: Nullable<IShadowLight[]>;
  102343. protected _shadowLevel: float;
  102344. /**
  102345. * Helps adjusting the shadow to a softer level if required.
  102346. * 0 means black shadows and 1 means no shadows.
  102347. */
  102348. shadowLevel: float;
  102349. protected _sceneCenter: Vector3;
  102350. /**
  102351. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102352. * It is usually zero but might be interesting to modify according to your setup.
  102353. */
  102354. sceneCenter: Vector3;
  102355. protected _opacityFresnel: boolean;
  102356. /**
  102357. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102358. * This helps ensuring a nice transition when the camera goes under the ground.
  102359. */
  102360. opacityFresnel: boolean;
  102361. protected _reflectionFresnel: boolean;
  102362. /**
  102363. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102364. * This helps adding a mirror texture on the ground.
  102365. */
  102366. reflectionFresnel: boolean;
  102367. protected _reflectionFalloffDistance: number;
  102368. /**
  102369. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102370. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102371. */
  102372. reflectionFalloffDistance: number;
  102373. protected _reflectionAmount: number;
  102374. /**
  102375. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102376. */
  102377. reflectionAmount: number;
  102378. protected _reflectionReflectance0: number;
  102379. /**
  102380. * This specifies the weight of the reflection at grazing angle.
  102381. */
  102382. reflectionReflectance0: number;
  102383. protected _reflectionReflectance90: number;
  102384. /**
  102385. * This specifies the weight of the reflection at a perpendicular point of view.
  102386. */
  102387. reflectionReflectance90: number;
  102388. /**
  102389. * Sets the reflection reflectance fresnel values according to the default standard
  102390. * empirically know to work well :-)
  102391. */
  102392. reflectionStandardFresnelWeight: number;
  102393. protected _useRGBColor: boolean;
  102394. /**
  102395. * Helps to directly use the maps channels instead of their level.
  102396. */
  102397. useRGBColor: boolean;
  102398. protected _enableNoise: boolean;
  102399. /**
  102400. * This helps reducing the banding effect that could occur on the background.
  102401. */
  102402. enableNoise: boolean;
  102403. /**
  102404. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102405. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102406. * Recommended to be keep at 1.0 except for special cases.
  102407. */
  102408. fovMultiplier: number;
  102409. private _fovMultiplier;
  102410. /**
  102411. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102412. */
  102413. useEquirectangularFOV: boolean;
  102414. private _maxSimultaneousLights;
  102415. /**
  102416. * Number of Simultaneous lights allowed on the material.
  102417. */
  102418. maxSimultaneousLights: int;
  102419. /**
  102420. * Default configuration related to image processing available in the Background Material.
  102421. */
  102422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102423. /**
  102424. * Keep track of the image processing observer to allow dispose and replace.
  102425. */
  102426. private _imageProcessingObserver;
  102427. /**
  102428. * Attaches a new image processing configuration to the PBR Material.
  102429. * @param configuration (if null the scene configuration will be use)
  102430. */
  102431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102432. /**
  102433. * Gets the image processing configuration used either in this material.
  102434. */
  102435. /**
  102436. * Sets the Default image processing configuration used either in the this material.
  102437. *
  102438. * If sets to null, the scene one is in use.
  102439. */
  102440. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102441. /**
  102442. * Gets wether the color curves effect is enabled.
  102443. */
  102444. /**
  102445. * Sets wether the color curves effect is enabled.
  102446. */
  102447. cameraColorCurvesEnabled: boolean;
  102448. /**
  102449. * Gets wether the color grading effect is enabled.
  102450. */
  102451. /**
  102452. * Gets wether the color grading effect is enabled.
  102453. */
  102454. cameraColorGradingEnabled: boolean;
  102455. /**
  102456. * Gets wether tonemapping is enabled or not.
  102457. */
  102458. /**
  102459. * Sets wether tonemapping is enabled or not
  102460. */
  102461. cameraToneMappingEnabled: boolean;
  102462. /**
  102463. * The camera exposure used on this material.
  102464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102465. * This corresponds to a photographic exposure.
  102466. */
  102467. /**
  102468. * The camera exposure used on this material.
  102469. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102470. * This corresponds to a photographic exposure.
  102471. */
  102472. cameraExposure: float;
  102473. /**
  102474. * Gets The camera contrast used on this material.
  102475. */
  102476. /**
  102477. * Sets The camera contrast used on this material.
  102478. */
  102479. cameraContrast: float;
  102480. /**
  102481. * Gets the Color Grading 2D Lookup Texture.
  102482. */
  102483. /**
  102484. * Sets the Color Grading 2D Lookup Texture.
  102485. */
  102486. cameraColorGradingTexture: Nullable<BaseTexture>;
  102487. /**
  102488. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102489. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102490. * 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;
  102491. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102492. */
  102493. /**
  102494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102496. * 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;
  102497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102498. */
  102499. cameraColorCurves: Nullable<ColorCurves>;
  102500. /**
  102501. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102502. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102503. */
  102504. switchToBGR: boolean;
  102505. private _renderTargets;
  102506. private _reflectionControls;
  102507. private _white;
  102508. private _primaryShadowColor;
  102509. private _primaryHighlightColor;
  102510. /**
  102511. * Instantiates a Background Material in the given scene
  102512. * @param name The friendly name of the material
  102513. * @param scene The scene to add the material to
  102514. */
  102515. constructor(name: string, scene: Scene);
  102516. /**
  102517. * Gets a boolean indicating that current material needs to register RTT
  102518. */
  102519. readonly hasRenderTargetTextures: boolean;
  102520. /**
  102521. * The entire material has been created in order to prevent overdraw.
  102522. * @returns false
  102523. */
  102524. needAlphaTesting(): boolean;
  102525. /**
  102526. * The entire material has been created in order to prevent overdraw.
  102527. * @returns true if blending is enable
  102528. */
  102529. needAlphaBlending(): boolean;
  102530. /**
  102531. * Checks wether the material is ready to be rendered for a given mesh.
  102532. * @param mesh The mesh to render
  102533. * @param subMesh The submesh to check against
  102534. * @param useInstances Specify wether or not the material is used with instances
  102535. * @returns true if all the dependencies are ready (Textures, Effects...)
  102536. */
  102537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102538. /**
  102539. * Compute the primary color according to the chosen perceptual color.
  102540. */
  102541. private _computePrimaryColorFromPerceptualColor;
  102542. /**
  102543. * Compute the highlights and shadow colors according to their chosen levels.
  102544. */
  102545. private _computePrimaryColors;
  102546. /**
  102547. * Build the uniform buffer used in the material.
  102548. */
  102549. buildUniformLayout(): void;
  102550. /**
  102551. * Unbind the material.
  102552. */
  102553. unbind(): void;
  102554. /**
  102555. * Bind only the world matrix to the material.
  102556. * @param world The world matrix to bind.
  102557. */
  102558. bindOnlyWorldMatrix(world: Matrix): void;
  102559. /**
  102560. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102561. * @param world The world matrix to bind.
  102562. * @param subMesh The submesh to bind for.
  102563. */
  102564. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102565. /**
  102566. * Dispose the material.
  102567. * @param forceDisposeEffect Force disposal of the associated effect.
  102568. * @param forceDisposeTextures Force disposal of the associated textures.
  102569. */
  102570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102571. /**
  102572. * Clones the material.
  102573. * @param name The cloned name.
  102574. * @returns The cloned material.
  102575. */
  102576. clone(name: string): BackgroundMaterial;
  102577. /**
  102578. * Serializes the current material to its JSON representation.
  102579. * @returns The JSON representation.
  102580. */
  102581. serialize(): any;
  102582. /**
  102583. * Gets the class name of the material
  102584. * @returns "BackgroundMaterial"
  102585. */
  102586. getClassName(): string;
  102587. /**
  102588. * Parse a JSON input to create back a background material.
  102589. * @param source The JSON data to parse
  102590. * @param scene The scene to create the parsed material in
  102591. * @param rootUrl The root url of the assets the material depends upon
  102592. * @returns the instantiated BackgroundMaterial.
  102593. */
  102594. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /**
  102599. * Represents the different options available during the creation of
  102600. * a Environment helper.
  102601. *
  102602. * This can control the default ground, skybox and image processing setup of your scene.
  102603. */
  102604. export interface IEnvironmentHelperOptions {
  102605. /**
  102606. * Specifies wether or not to create a ground.
  102607. * True by default.
  102608. */
  102609. createGround: boolean;
  102610. /**
  102611. * Specifies the ground size.
  102612. * 15 by default.
  102613. */
  102614. groundSize: number;
  102615. /**
  102616. * The texture used on the ground for the main color.
  102617. * Comes from the BabylonJS CDN by default.
  102618. *
  102619. * Remarks: Can be either a texture or a url.
  102620. */
  102621. groundTexture: string | BaseTexture;
  102622. /**
  102623. * The color mixed in the ground texture by default.
  102624. * BabylonJS clearColor by default.
  102625. */
  102626. groundColor: Color3;
  102627. /**
  102628. * Specifies the ground opacity.
  102629. * 1 by default.
  102630. */
  102631. groundOpacity: number;
  102632. /**
  102633. * Enables the ground to receive shadows.
  102634. * True by default.
  102635. */
  102636. enableGroundShadow: boolean;
  102637. /**
  102638. * Helps preventing the shadow to be fully black on the ground.
  102639. * 0.5 by default.
  102640. */
  102641. groundShadowLevel: number;
  102642. /**
  102643. * Creates a mirror texture attach to the ground.
  102644. * false by default.
  102645. */
  102646. enableGroundMirror: boolean;
  102647. /**
  102648. * Specifies the ground mirror size ratio.
  102649. * 0.3 by default as the default kernel is 64.
  102650. */
  102651. groundMirrorSizeRatio: number;
  102652. /**
  102653. * Specifies the ground mirror blur kernel size.
  102654. * 64 by default.
  102655. */
  102656. groundMirrorBlurKernel: number;
  102657. /**
  102658. * Specifies the ground mirror visibility amount.
  102659. * 1 by default
  102660. */
  102661. groundMirrorAmount: number;
  102662. /**
  102663. * Specifies the ground mirror reflectance weight.
  102664. * This uses the standard weight of the background material to setup the fresnel effect
  102665. * of the mirror.
  102666. * 1 by default.
  102667. */
  102668. groundMirrorFresnelWeight: number;
  102669. /**
  102670. * Specifies the ground mirror Falloff distance.
  102671. * This can helps reducing the size of the reflection.
  102672. * 0 by Default.
  102673. */
  102674. groundMirrorFallOffDistance: number;
  102675. /**
  102676. * Specifies the ground mirror texture type.
  102677. * Unsigned Int by Default.
  102678. */
  102679. groundMirrorTextureType: number;
  102680. /**
  102681. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102682. * the shown objects.
  102683. */
  102684. groundYBias: number;
  102685. /**
  102686. * Specifies wether or not to create a skybox.
  102687. * True by default.
  102688. */
  102689. createSkybox: boolean;
  102690. /**
  102691. * Specifies the skybox size.
  102692. * 20 by default.
  102693. */
  102694. skyboxSize: number;
  102695. /**
  102696. * The texture used on the skybox for the main color.
  102697. * Comes from the BabylonJS CDN by default.
  102698. *
  102699. * Remarks: Can be either a texture or a url.
  102700. */
  102701. skyboxTexture: string | BaseTexture;
  102702. /**
  102703. * The color mixed in the skybox texture by default.
  102704. * BabylonJS clearColor by default.
  102705. */
  102706. skyboxColor: Color3;
  102707. /**
  102708. * The background rotation around the Y axis of the scene.
  102709. * This helps aligning the key lights of your scene with the background.
  102710. * 0 by default.
  102711. */
  102712. backgroundYRotation: number;
  102713. /**
  102714. * Compute automatically the size of the elements to best fit with the scene.
  102715. */
  102716. sizeAuto: boolean;
  102717. /**
  102718. * Default position of the rootMesh if autoSize is not true.
  102719. */
  102720. rootPosition: Vector3;
  102721. /**
  102722. * Sets up the image processing in the scene.
  102723. * true by default.
  102724. */
  102725. setupImageProcessing: boolean;
  102726. /**
  102727. * The texture used as your environment texture in the scene.
  102728. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102729. *
  102730. * Remarks: Can be either a texture or a url.
  102731. */
  102732. environmentTexture: string | BaseTexture;
  102733. /**
  102734. * The value of the exposure to apply to the scene.
  102735. * 0.6 by default if setupImageProcessing is true.
  102736. */
  102737. cameraExposure: number;
  102738. /**
  102739. * The value of the contrast to apply to the scene.
  102740. * 1.6 by default if setupImageProcessing is true.
  102741. */
  102742. cameraContrast: number;
  102743. /**
  102744. * Specifies wether or not tonemapping should be enabled in the scene.
  102745. * true by default if setupImageProcessing is true.
  102746. */
  102747. toneMappingEnabled: boolean;
  102748. }
  102749. /**
  102750. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102751. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102752. * It also helps with the default setup of your imageProcessing configuration.
  102753. */
  102754. export class EnvironmentHelper {
  102755. /**
  102756. * Default ground texture URL.
  102757. */
  102758. private static _groundTextureCDNUrl;
  102759. /**
  102760. * Default skybox texture URL.
  102761. */
  102762. private static _skyboxTextureCDNUrl;
  102763. /**
  102764. * Default environment texture URL.
  102765. */
  102766. private static _environmentTextureCDNUrl;
  102767. /**
  102768. * Creates the default options for the helper.
  102769. */
  102770. private static _getDefaultOptions;
  102771. private _rootMesh;
  102772. /**
  102773. * Gets the root mesh created by the helper.
  102774. */
  102775. readonly rootMesh: Mesh;
  102776. private _skybox;
  102777. /**
  102778. * Gets the skybox created by the helper.
  102779. */
  102780. readonly skybox: Nullable<Mesh>;
  102781. private _skyboxTexture;
  102782. /**
  102783. * Gets the skybox texture created by the helper.
  102784. */
  102785. readonly skyboxTexture: Nullable<BaseTexture>;
  102786. private _skyboxMaterial;
  102787. /**
  102788. * Gets the skybox material created by the helper.
  102789. */
  102790. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102791. private _ground;
  102792. /**
  102793. * Gets the ground mesh created by the helper.
  102794. */
  102795. readonly ground: Nullable<Mesh>;
  102796. private _groundTexture;
  102797. /**
  102798. * Gets the ground texture created by the helper.
  102799. */
  102800. readonly groundTexture: Nullable<BaseTexture>;
  102801. private _groundMirror;
  102802. /**
  102803. * Gets the ground mirror created by the helper.
  102804. */
  102805. readonly groundMirror: Nullable<MirrorTexture>;
  102806. /**
  102807. * Gets the ground mirror render list to helps pushing the meshes
  102808. * you wish in the ground reflection.
  102809. */
  102810. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102811. private _groundMaterial;
  102812. /**
  102813. * Gets the ground material created by the helper.
  102814. */
  102815. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102816. /**
  102817. * Stores the creation options.
  102818. */
  102819. private readonly _scene;
  102820. private _options;
  102821. /**
  102822. * This observable will be notified with any error during the creation of the environment,
  102823. * mainly texture creation errors.
  102824. */
  102825. onErrorObservable: Observable<{
  102826. message?: string;
  102827. exception?: any;
  102828. }>;
  102829. /**
  102830. * constructor
  102831. * @param options Defines the options we want to customize the helper
  102832. * @param scene The scene to add the material to
  102833. */
  102834. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102835. /**
  102836. * Updates the background according to the new options
  102837. * @param options
  102838. */
  102839. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102840. /**
  102841. * Sets the primary color of all the available elements.
  102842. * @param color the main color to affect to the ground and the background
  102843. */
  102844. setMainColor(color: Color3): void;
  102845. /**
  102846. * Setup the image processing according to the specified options.
  102847. */
  102848. private _setupImageProcessing;
  102849. /**
  102850. * Setup the environment texture according to the specified options.
  102851. */
  102852. private _setupEnvironmentTexture;
  102853. /**
  102854. * Setup the background according to the specified options.
  102855. */
  102856. private _setupBackground;
  102857. /**
  102858. * Get the scene sizes according to the setup.
  102859. */
  102860. private _getSceneSize;
  102861. /**
  102862. * Setup the ground according to the specified options.
  102863. */
  102864. private _setupGround;
  102865. /**
  102866. * Setup the ground material according to the specified options.
  102867. */
  102868. private _setupGroundMaterial;
  102869. /**
  102870. * Setup the ground diffuse texture according to the specified options.
  102871. */
  102872. private _setupGroundDiffuseTexture;
  102873. /**
  102874. * Setup the ground mirror texture according to the specified options.
  102875. */
  102876. private _setupGroundMirrorTexture;
  102877. /**
  102878. * Setup the ground to receive the mirror texture.
  102879. */
  102880. private _setupMirrorInGroundMaterial;
  102881. /**
  102882. * Setup the skybox according to the specified options.
  102883. */
  102884. private _setupSkybox;
  102885. /**
  102886. * Setup the skybox material according to the specified options.
  102887. */
  102888. private _setupSkyboxMaterial;
  102889. /**
  102890. * Setup the skybox reflection texture according to the specified options.
  102891. */
  102892. private _setupSkyboxReflectionTexture;
  102893. private _errorHandler;
  102894. /**
  102895. * Dispose all the elements created by the Helper.
  102896. */
  102897. dispose(): void;
  102898. }
  102899. }
  102900. declare module BABYLON {
  102901. /**
  102902. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102903. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102904. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102905. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102906. */
  102907. export class PhotoDome extends TransformNode {
  102908. private _useDirectMapping;
  102909. /**
  102910. * The texture being displayed on the sphere
  102911. */
  102912. protected _photoTexture: Texture;
  102913. /**
  102914. * Gets or sets the texture being displayed on the sphere
  102915. */
  102916. photoTexture: Texture;
  102917. /**
  102918. * Observable raised when an error occured while loading the 360 image
  102919. */
  102920. onLoadErrorObservable: Observable<string>;
  102921. /**
  102922. * The skybox material
  102923. */
  102924. protected _material: BackgroundMaterial;
  102925. /**
  102926. * The surface used for the skybox
  102927. */
  102928. protected _mesh: Mesh;
  102929. /**
  102930. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102931. * Also see the options.resolution property.
  102932. */
  102933. fovMultiplier: number;
  102934. /**
  102935. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102936. * @param name Element's name, child elements will append suffixes for their own names.
  102937. * @param urlsOfPhoto defines the url of the photo to display
  102938. * @param options defines an object containing optional or exposed sub element properties
  102939. * @param onError defines a callback called when an error occured while loading the texture
  102940. */
  102941. constructor(name: string, urlOfPhoto: string, options: {
  102942. resolution?: number;
  102943. size?: number;
  102944. useDirectMapping?: boolean;
  102945. faceForward?: boolean;
  102946. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102947. /**
  102948. * Releases resources associated with this node.
  102949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102951. */
  102952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102953. }
  102954. }
  102955. declare module BABYLON {
  102956. /** @hidden */
  102957. export var rgbdDecodePixelShader: {
  102958. name: string;
  102959. shader: string;
  102960. };
  102961. }
  102962. declare module BABYLON {
  102963. /**
  102964. * Class used to host texture specific utilities
  102965. */
  102966. export class BRDFTextureTools {
  102967. /**
  102968. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102969. * @param texture the texture to expand.
  102970. */
  102971. private static _ExpandDefaultBRDFTexture;
  102972. /**
  102973. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102974. * @param scene defines the hosting scene
  102975. * @returns the environment BRDF texture
  102976. */
  102977. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102978. private static _environmentBRDFBase64Texture;
  102979. }
  102980. }
  102981. declare module BABYLON {
  102982. /**
  102983. * @hidden
  102984. */
  102985. export interface IMaterialClearCoatDefines {
  102986. CLEARCOAT: boolean;
  102987. CLEARCOAT_DEFAULTIOR: boolean;
  102988. CLEARCOAT_TEXTURE: boolean;
  102989. CLEARCOAT_TEXTUREDIRECTUV: number;
  102990. CLEARCOAT_BUMP: boolean;
  102991. CLEARCOAT_BUMPDIRECTUV: number;
  102992. CLEARCOAT_TINT: boolean;
  102993. CLEARCOAT_TINT_TEXTURE: boolean;
  102994. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102995. /** @hidden */
  102996. _areTexturesDirty: boolean;
  102997. }
  102998. /**
  102999. * Define the code related to the clear coat parameters of the pbr material.
  103000. */
  103001. export class PBRClearCoatConfiguration {
  103002. /**
  103003. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103004. * The default fits with a polyurethane material.
  103005. */
  103006. private static readonly _DefaultIndiceOfRefraction;
  103007. private _isEnabled;
  103008. /**
  103009. * Defines if the clear coat is enabled in the material.
  103010. */
  103011. isEnabled: boolean;
  103012. /**
  103013. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103014. */
  103015. intensity: number;
  103016. /**
  103017. * Defines the clear coat layer roughness.
  103018. */
  103019. roughness: number;
  103020. private _indiceOfRefraction;
  103021. /**
  103022. * Defines the indice of refraction of the clear coat.
  103023. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103024. * The default fits with a polyurethane material.
  103025. * Changing the default value is more performance intensive.
  103026. */
  103027. indiceOfRefraction: number;
  103028. private _texture;
  103029. /**
  103030. * Stores the clear coat values in a texture.
  103031. */
  103032. texture: Nullable<BaseTexture>;
  103033. private _bumpTexture;
  103034. /**
  103035. * Define the clear coat specific bump texture.
  103036. */
  103037. bumpTexture: Nullable<BaseTexture>;
  103038. private _isTintEnabled;
  103039. /**
  103040. * Defines if the clear coat tint is enabled in the material.
  103041. */
  103042. isTintEnabled: boolean;
  103043. /**
  103044. * Defines the clear coat tint of the material.
  103045. * This is only use if tint is enabled
  103046. */
  103047. tintColor: Color3;
  103048. /**
  103049. * Defines the distance at which the tint color should be found in the
  103050. * clear coat media.
  103051. * This is only use if tint is enabled
  103052. */
  103053. tintColorAtDistance: number;
  103054. /**
  103055. * Defines the clear coat layer thickness.
  103056. * This is only use if tint is enabled
  103057. */
  103058. tintThickness: number;
  103059. private _tintTexture;
  103060. /**
  103061. * Stores the clear tint values in a texture.
  103062. * rgb is tint
  103063. * a is a thickness factor
  103064. */
  103065. tintTexture: Nullable<BaseTexture>;
  103066. /** @hidden */
  103067. private _internalMarkAllSubMeshesAsTexturesDirty;
  103068. /** @hidden */
  103069. _markAllSubMeshesAsTexturesDirty(): void;
  103070. /**
  103071. * Instantiate a new istance of clear coat configuration.
  103072. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103073. */
  103074. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103075. /**
  103076. * Gets wehter the submesh is ready to be used or not.
  103077. * @param defines the list of "defines" to update.
  103078. * @param scene defines the scene the material belongs to.
  103079. * @param engine defines the engine the material belongs to.
  103080. * @param disableBumpMap defines wether the material disables bump or not.
  103081. * @returns - boolean indicating that the submesh is ready or not.
  103082. */
  103083. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103084. /**
  103085. * Checks to see if a texture is used in the material.
  103086. * @param defines the list of "defines" to update.
  103087. * @param scene defines the scene to the material belongs to.
  103088. */
  103089. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103090. /**
  103091. * Binds the material data.
  103092. * @param uniformBuffer defines the Uniform buffer to fill in.
  103093. * @param scene defines the scene the material belongs to.
  103094. * @param engine defines the engine the material belongs to.
  103095. * @param disableBumpMap defines wether the material disables bump or not.
  103096. * @param isFrozen defines wether the material is frozen or not.
  103097. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103098. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103099. */
  103100. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103101. /**
  103102. * Checks to see if a texture is used in the material.
  103103. * @param texture - Base texture to use.
  103104. * @returns - Boolean specifying if a texture is used in the material.
  103105. */
  103106. hasTexture(texture: BaseTexture): boolean;
  103107. /**
  103108. * Returns an array of the actively used textures.
  103109. * @param activeTextures Array of BaseTextures
  103110. */
  103111. getActiveTextures(activeTextures: BaseTexture[]): void;
  103112. /**
  103113. * Returns the animatable textures.
  103114. * @param animatables Array of animatable textures.
  103115. */
  103116. getAnimatables(animatables: IAnimatable[]): void;
  103117. /**
  103118. * Disposes the resources of the material.
  103119. * @param forceDisposeTextures - Forces the disposal of all textures.
  103120. */
  103121. dispose(forceDisposeTextures?: boolean): void;
  103122. /**
  103123. * Get the current class name of the texture useful for serialization or dynamic coding.
  103124. * @returns "PBRClearCoatConfiguration"
  103125. */
  103126. getClassName(): string;
  103127. /**
  103128. * Add fallbacks to the effect fallbacks list.
  103129. * @param defines defines the Base texture to use.
  103130. * @param fallbacks defines the current fallback list.
  103131. * @param currentRank defines the current fallback rank.
  103132. * @returns the new fallback rank.
  103133. */
  103134. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103135. /**
  103136. * Add the required uniforms to the current list.
  103137. * @param uniforms defines the current uniform list.
  103138. */
  103139. static AddUniforms(uniforms: string[]): void;
  103140. /**
  103141. * Add the required samplers to the current list.
  103142. * @param samplers defines the current sampler list.
  103143. */
  103144. static AddSamplers(samplers: string[]): void;
  103145. /**
  103146. * Add the required uniforms to the current buffer.
  103147. * @param uniformBuffer defines the current uniform buffer.
  103148. */
  103149. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103150. /**
  103151. * Makes a duplicate of the current configuration into another one.
  103152. * @param clearCoatConfiguration define the config where to copy the info
  103153. */
  103154. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103155. /**
  103156. * Serializes this clear coat configuration.
  103157. * @returns - An object with the serialized config.
  103158. */
  103159. serialize(): any;
  103160. /**
  103161. * Parses a Clear Coat Configuration from a serialized object.
  103162. * @param source - Serialized object.
  103163. */
  103164. parse(source: any): void;
  103165. }
  103166. }
  103167. declare module BABYLON {
  103168. /**
  103169. * @hidden
  103170. */
  103171. export interface IMaterialAnisotropicDefines {
  103172. ANISOTROPIC: boolean;
  103173. ANISOTROPIC_TEXTURE: boolean;
  103174. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103175. MAINUV1: boolean;
  103176. _areTexturesDirty: boolean;
  103177. _needUVs: boolean;
  103178. }
  103179. /**
  103180. * Define the code related to the anisotropic parameters of the pbr material.
  103181. */
  103182. export class PBRAnisotropicConfiguration {
  103183. private _isEnabled;
  103184. /**
  103185. * Defines if the anisotropy is enabled in the material.
  103186. */
  103187. isEnabled: boolean;
  103188. /**
  103189. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103190. */
  103191. intensity: number;
  103192. /**
  103193. * Defines if the effect is along the tangents, bitangents or in between.
  103194. * By default, the effect is "strectching" the highlights along the tangents.
  103195. */
  103196. direction: Vector2;
  103197. private _texture;
  103198. /**
  103199. * Stores the anisotropy values in a texture.
  103200. * rg is direction (like normal from -1 to 1)
  103201. * b is a intensity
  103202. */
  103203. texture: Nullable<BaseTexture>;
  103204. /** @hidden */
  103205. private _internalMarkAllSubMeshesAsTexturesDirty;
  103206. /** @hidden */
  103207. _markAllSubMeshesAsTexturesDirty(): void;
  103208. /**
  103209. * Instantiate a new istance of anisotropy configuration.
  103210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103211. */
  103212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103213. /**
  103214. * Specifies that the submesh is ready to be used.
  103215. * @param defines the list of "defines" to update.
  103216. * @param scene defines the scene the material belongs to.
  103217. * @returns - boolean indicating that the submesh is ready or not.
  103218. */
  103219. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103220. /**
  103221. * Checks to see if a texture is used in the material.
  103222. * @param defines the list of "defines" to update.
  103223. * @param mesh the mesh we are preparing the defines for.
  103224. * @param scene defines the scene the material belongs to.
  103225. */
  103226. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103227. /**
  103228. * Binds the material data.
  103229. * @param uniformBuffer defines the Uniform buffer to fill in.
  103230. * @param scene defines the scene the material belongs to.
  103231. * @param isFrozen defines wether the material is frozen or not.
  103232. */
  103233. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103234. /**
  103235. * Checks to see if a texture is used in the material.
  103236. * @param texture - Base texture to use.
  103237. * @returns - Boolean specifying if a texture is used in the material.
  103238. */
  103239. hasTexture(texture: BaseTexture): boolean;
  103240. /**
  103241. * Returns an array of the actively used textures.
  103242. * @param activeTextures Array of BaseTextures
  103243. */
  103244. getActiveTextures(activeTextures: BaseTexture[]): void;
  103245. /**
  103246. * Returns the animatable textures.
  103247. * @param animatables Array of animatable textures.
  103248. */
  103249. getAnimatables(animatables: IAnimatable[]): void;
  103250. /**
  103251. * Disposes the resources of the material.
  103252. * @param forceDisposeTextures - Forces the disposal of all textures.
  103253. */
  103254. dispose(forceDisposeTextures?: boolean): void;
  103255. /**
  103256. * Get the current class name of the texture useful for serialization or dynamic coding.
  103257. * @returns "PBRAnisotropicConfiguration"
  103258. */
  103259. getClassName(): string;
  103260. /**
  103261. * Add fallbacks to the effect fallbacks list.
  103262. * @param defines defines the Base texture to use.
  103263. * @param fallbacks defines the current fallback list.
  103264. * @param currentRank defines the current fallback rank.
  103265. * @returns the new fallback rank.
  103266. */
  103267. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103268. /**
  103269. * Add the required uniforms to the current list.
  103270. * @param uniforms defines the current uniform list.
  103271. */
  103272. static AddUniforms(uniforms: string[]): void;
  103273. /**
  103274. * Add the required uniforms to the current buffer.
  103275. * @param uniformBuffer defines the current uniform buffer.
  103276. */
  103277. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103278. /**
  103279. * Add the required samplers to the current list.
  103280. * @param samplers defines the current sampler list.
  103281. */
  103282. static AddSamplers(samplers: string[]): void;
  103283. /**
  103284. * Makes a duplicate of the current configuration into another one.
  103285. * @param anisotropicConfiguration define the config where to copy the info
  103286. */
  103287. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103288. /**
  103289. * Serializes this anisotropy configuration.
  103290. * @returns - An object with the serialized config.
  103291. */
  103292. serialize(): any;
  103293. /**
  103294. * Parses a anisotropy Configuration from a serialized object.
  103295. * @param source - Serialized object.
  103296. */
  103297. parse(source: any): void;
  103298. }
  103299. }
  103300. declare module BABYLON {
  103301. /**
  103302. * @hidden
  103303. */
  103304. export interface IMaterialBRDFDefines {
  103305. BRDF_V_HEIGHT_CORRELATED: boolean;
  103306. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103307. /** @hidden */
  103308. _areMiscDirty: boolean;
  103309. }
  103310. /**
  103311. * Define the code related to the BRDF parameters of the pbr material.
  103312. */
  103313. export class PBRBRDFConfiguration {
  103314. /**
  103315. * Default value used for the energy conservation.
  103316. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103317. */
  103318. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103319. /**
  103320. * Default value used for the Smith Visibility Height Correlated mode.
  103321. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103322. */
  103323. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103324. private _useEnergyConservation;
  103325. /**
  103326. * Defines if the material uses energy conservation.
  103327. */
  103328. useEnergyConservation: boolean;
  103329. private _useSmithVisibilityHeightCorrelated;
  103330. /**
  103331. * LEGACY Mode set to false
  103332. * Defines if the material uses height smith correlated visibility term.
  103333. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103334. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103335. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103336. * Not relying on height correlated will also disable energy conservation.
  103337. */
  103338. useSmithVisibilityHeightCorrelated: boolean;
  103339. /** @hidden */
  103340. private _internalMarkAllSubMeshesAsMiscDirty;
  103341. /** @hidden */
  103342. _markAllSubMeshesAsMiscDirty(): void;
  103343. /**
  103344. * Instantiate a new istance of clear coat configuration.
  103345. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103346. */
  103347. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103348. /**
  103349. * Checks to see if a texture is used in the material.
  103350. * @param defines the list of "defines" to update.
  103351. */
  103352. prepareDefines(defines: IMaterialBRDFDefines): void;
  103353. /**
  103354. * Get the current class name of the texture useful for serialization or dynamic coding.
  103355. * @returns "PBRClearCoatConfiguration"
  103356. */
  103357. getClassName(): string;
  103358. /**
  103359. * Makes a duplicate of the current configuration into another one.
  103360. * @param brdfConfiguration define the config where to copy the info
  103361. */
  103362. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103363. /**
  103364. * Serializes this BRDF configuration.
  103365. * @returns - An object with the serialized config.
  103366. */
  103367. serialize(): any;
  103368. /**
  103369. * Parses a BRDF Configuration from a serialized object.
  103370. * @param source - Serialized object.
  103371. */
  103372. parse(source: any): void;
  103373. }
  103374. }
  103375. declare module BABYLON {
  103376. /**
  103377. * @hidden
  103378. */
  103379. export interface IMaterialSheenDefines {
  103380. SHEEN: boolean;
  103381. SHEEN_TEXTURE: boolean;
  103382. SHEEN_TEXTUREDIRECTUV: number;
  103383. SHEEN_LINKWITHALBEDO: boolean;
  103384. /** @hidden */
  103385. _areTexturesDirty: boolean;
  103386. }
  103387. /**
  103388. * Define the code related to the Sheen parameters of the pbr material.
  103389. */
  103390. export class PBRSheenConfiguration {
  103391. private _isEnabled;
  103392. /**
  103393. * Defines if the material uses sheen.
  103394. */
  103395. isEnabled: boolean;
  103396. private _linkSheenWithAlbedo;
  103397. /**
  103398. * Defines if the sheen is linked to the sheen color.
  103399. */
  103400. linkSheenWithAlbedo: boolean;
  103401. /**
  103402. * Defines the sheen intensity.
  103403. */
  103404. intensity: number;
  103405. /**
  103406. * Defines the sheen color.
  103407. */
  103408. color: Color3;
  103409. private _texture;
  103410. /**
  103411. * Stores the sheen tint values in a texture.
  103412. * rgb is tint
  103413. * a is a intensity
  103414. */
  103415. texture: Nullable<BaseTexture>;
  103416. /** @hidden */
  103417. private _internalMarkAllSubMeshesAsTexturesDirty;
  103418. /** @hidden */
  103419. _markAllSubMeshesAsTexturesDirty(): void;
  103420. /**
  103421. * Instantiate a new istance of clear coat configuration.
  103422. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103423. */
  103424. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103425. /**
  103426. * Specifies that the submesh is ready to be used.
  103427. * @param defines the list of "defines" to update.
  103428. * @param scene defines the scene the material belongs to.
  103429. * @returns - boolean indicating that the submesh is ready or not.
  103430. */
  103431. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103432. /**
  103433. * Checks to see if a texture is used in the material.
  103434. * @param defines the list of "defines" to update.
  103435. * @param scene defines the scene the material belongs to.
  103436. */
  103437. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103438. /**
  103439. * Binds the material data.
  103440. * @param uniformBuffer defines the Uniform buffer to fill in.
  103441. * @param scene defines the scene the material belongs to.
  103442. * @param isFrozen defines wether the material is frozen or not.
  103443. */
  103444. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103445. /**
  103446. * Checks to see if a texture is used in the material.
  103447. * @param texture - Base texture to use.
  103448. * @returns - Boolean specifying if a texture is used in the material.
  103449. */
  103450. hasTexture(texture: BaseTexture): boolean;
  103451. /**
  103452. * Returns an array of the actively used textures.
  103453. * @param activeTextures Array of BaseTextures
  103454. */
  103455. getActiveTextures(activeTextures: BaseTexture[]): void;
  103456. /**
  103457. * Returns the animatable textures.
  103458. * @param animatables Array of animatable textures.
  103459. */
  103460. getAnimatables(animatables: IAnimatable[]): void;
  103461. /**
  103462. * Disposes the resources of the material.
  103463. * @param forceDisposeTextures - Forces the disposal of all textures.
  103464. */
  103465. dispose(forceDisposeTextures?: boolean): void;
  103466. /**
  103467. * Get the current class name of the texture useful for serialization or dynamic coding.
  103468. * @returns "PBRSheenConfiguration"
  103469. */
  103470. getClassName(): string;
  103471. /**
  103472. * Add fallbacks to the effect fallbacks list.
  103473. * @param defines defines the Base texture to use.
  103474. * @param fallbacks defines the current fallback list.
  103475. * @param currentRank defines the current fallback rank.
  103476. * @returns the new fallback rank.
  103477. */
  103478. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103479. /**
  103480. * Add the required uniforms to the current list.
  103481. * @param uniforms defines the current uniform list.
  103482. */
  103483. static AddUniforms(uniforms: string[]): void;
  103484. /**
  103485. * Add the required uniforms to the current buffer.
  103486. * @param uniformBuffer defines the current uniform buffer.
  103487. */
  103488. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103489. /**
  103490. * Add the required samplers to the current list.
  103491. * @param samplers defines the current sampler list.
  103492. */
  103493. static AddSamplers(samplers: string[]): void;
  103494. /**
  103495. * Makes a duplicate of the current configuration into another one.
  103496. * @param sheenConfiguration define the config where to copy the info
  103497. */
  103498. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103499. /**
  103500. * Serializes this BRDF configuration.
  103501. * @returns - An object with the serialized config.
  103502. */
  103503. serialize(): any;
  103504. /**
  103505. * Parses a Sheen Configuration from a serialized object.
  103506. * @param source - Serialized object.
  103507. */
  103508. parse(source: any): void;
  103509. }
  103510. }
  103511. declare module BABYLON {
  103512. /**
  103513. * @hidden
  103514. */
  103515. export interface IMaterialSubSurfaceDefines {
  103516. SUBSURFACE: boolean;
  103517. SS_REFRACTION: boolean;
  103518. SS_TRANSLUCENCY: boolean;
  103519. SS_SCATERRING: boolean;
  103520. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103521. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103522. SS_REFRACTIONMAP_3D: boolean;
  103523. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103524. SS_LODINREFRACTIONALPHA: boolean;
  103525. SS_GAMMAREFRACTION: boolean;
  103526. SS_RGBDREFRACTION: boolean;
  103527. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103528. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103529. /** @hidden */
  103530. _areTexturesDirty: boolean;
  103531. }
  103532. /**
  103533. * Define the code related to the sub surface parameters of the pbr material.
  103534. */
  103535. export class PBRSubSurfaceConfiguration {
  103536. private _isRefractionEnabled;
  103537. /**
  103538. * Defines if the refraction is enabled in the material.
  103539. */
  103540. isRefractionEnabled: boolean;
  103541. private _isTranslucencyEnabled;
  103542. /**
  103543. * Defines if the translucency is enabled in the material.
  103544. */
  103545. isTranslucencyEnabled: boolean;
  103546. private _isScatteringEnabled;
  103547. /**
  103548. * Defines the refraction intensity of the material.
  103549. * The refraction when enabled replaces the Diffuse part of the material.
  103550. * The intensity helps transitionning between diffuse and refraction.
  103551. */
  103552. refractionIntensity: number;
  103553. /**
  103554. * Defines the translucency intensity of the material.
  103555. * When translucency has been enabled, this defines how much of the "translucency"
  103556. * is addded to the diffuse part of the material.
  103557. */
  103558. translucencyIntensity: number;
  103559. /**
  103560. * Defines the scattering intensity of the material.
  103561. * When scattering has been enabled, this defines how much of the "scattered light"
  103562. * is addded to the diffuse part of the material.
  103563. */
  103564. scatteringIntensity: number;
  103565. private _thicknessTexture;
  103566. /**
  103567. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103568. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103569. * 0 would mean minimumThickness
  103570. * 1 would mean maximumThickness
  103571. * The other channels might be use as a mask to vary the different effects intensity.
  103572. */
  103573. thicknessTexture: Nullable<BaseTexture>;
  103574. private _refractionTexture;
  103575. /**
  103576. * Defines the texture to use for refraction.
  103577. */
  103578. refractionTexture: Nullable<BaseTexture>;
  103579. private _indexOfRefraction;
  103580. /**
  103581. * Defines the indice of refraction used in the material.
  103582. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103583. */
  103584. indexOfRefraction: number;
  103585. private _invertRefractionY;
  103586. /**
  103587. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103588. */
  103589. invertRefractionY: boolean;
  103590. private _linkRefractionWithTransparency;
  103591. /**
  103592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103593. * Materials half opaque for instance using refraction could benefit from this control.
  103594. */
  103595. linkRefractionWithTransparency: boolean;
  103596. /**
  103597. * Defines the minimum thickness stored in the thickness map.
  103598. * If no thickness map is defined, this value will be used to simulate thickness.
  103599. */
  103600. minimumThickness: number;
  103601. /**
  103602. * Defines the maximum thickness stored in the thickness map.
  103603. */
  103604. maximumThickness: number;
  103605. /**
  103606. * Defines the volume tint of the material.
  103607. * This is used for both translucency and scattering.
  103608. */
  103609. tintColor: Color3;
  103610. /**
  103611. * Defines the distance at which the tint color should be found in the media.
  103612. * This is used for refraction only.
  103613. */
  103614. tintColorAtDistance: number;
  103615. /**
  103616. * Defines how far each channel transmit through the media.
  103617. * It is defined as a color to simplify it selection.
  103618. */
  103619. diffusionDistance: Color3;
  103620. private _useMaskFromThicknessTexture;
  103621. /**
  103622. * Stores the intensity of the different subsurface effects in the thickness texture.
  103623. * * the green channel is the translucency intensity.
  103624. * * the blue channel is the scattering intensity.
  103625. * * the alpha channel is the refraction intensity.
  103626. */
  103627. useMaskFromThicknessTexture: boolean;
  103628. /** @hidden */
  103629. private _internalMarkAllSubMeshesAsTexturesDirty;
  103630. /** @hidden */
  103631. _markAllSubMeshesAsTexturesDirty(): void;
  103632. /**
  103633. * Instantiate a new istance of sub surface configuration.
  103634. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103635. */
  103636. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103637. /**
  103638. * Gets wehter the submesh is ready to be used or not.
  103639. * @param defines the list of "defines" to update.
  103640. * @param scene defines the scene the material belongs to.
  103641. * @returns - boolean indicating that the submesh is ready or not.
  103642. */
  103643. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103644. /**
  103645. * Checks to see if a texture is used in the material.
  103646. * @param defines the list of "defines" to update.
  103647. * @param scene defines the scene to the material belongs to.
  103648. */
  103649. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103650. /**
  103651. * Binds the material data.
  103652. * @param uniformBuffer defines the Uniform buffer to fill in.
  103653. * @param scene defines the scene the material belongs to.
  103654. * @param engine defines the engine the material belongs to.
  103655. * @param isFrozen defines wether the material is frozen or not.
  103656. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103657. */
  103658. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103659. /**
  103660. * Unbinds the material from the mesh.
  103661. * @param activeEffect defines the effect that should be unbound from.
  103662. * @returns true if unbound, otherwise false
  103663. */
  103664. unbind(activeEffect: Effect): boolean;
  103665. /**
  103666. * Returns the texture used for refraction or null if none is used.
  103667. * @param scene defines the scene the material belongs to.
  103668. * @returns - Refraction texture if present. If no refraction texture and refraction
  103669. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103670. */
  103671. private _getRefractionTexture;
  103672. /**
  103673. * Returns true if alpha blending should be disabled.
  103674. */
  103675. readonly disableAlphaBlending: boolean;
  103676. /**
  103677. * Fills the list of render target textures.
  103678. * @param renderTargets the list of render targets to update
  103679. */
  103680. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103681. /**
  103682. * Checks to see if a texture is used in the material.
  103683. * @param texture - Base texture to use.
  103684. * @returns - Boolean specifying if a texture is used in the material.
  103685. */
  103686. hasTexture(texture: BaseTexture): boolean;
  103687. /**
  103688. * Gets a boolean indicating that current material needs to register RTT
  103689. * @returns true if this uses a render target otherwise false.
  103690. */
  103691. hasRenderTargetTextures(): boolean;
  103692. /**
  103693. * Returns an array of the actively used textures.
  103694. * @param activeTextures Array of BaseTextures
  103695. */
  103696. getActiveTextures(activeTextures: BaseTexture[]): void;
  103697. /**
  103698. * Returns the animatable textures.
  103699. * @param animatables Array of animatable textures.
  103700. */
  103701. getAnimatables(animatables: IAnimatable[]): void;
  103702. /**
  103703. * Disposes the resources of the material.
  103704. * @param forceDisposeTextures - Forces the disposal of all textures.
  103705. */
  103706. dispose(forceDisposeTextures?: boolean): void;
  103707. /**
  103708. * Get the current class name of the texture useful for serialization or dynamic coding.
  103709. * @returns "PBRSubSurfaceConfiguration"
  103710. */
  103711. getClassName(): string;
  103712. /**
  103713. * Add fallbacks to the effect fallbacks list.
  103714. * @param defines defines the Base texture to use.
  103715. * @param fallbacks defines the current fallback list.
  103716. * @param currentRank defines the current fallback rank.
  103717. * @returns the new fallback rank.
  103718. */
  103719. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103720. /**
  103721. * Add the required uniforms to the current list.
  103722. * @param uniforms defines the current uniform list.
  103723. */
  103724. static AddUniforms(uniforms: string[]): void;
  103725. /**
  103726. * Add the required samplers to the current list.
  103727. * @param samplers defines the current sampler list.
  103728. */
  103729. static AddSamplers(samplers: string[]): void;
  103730. /**
  103731. * Add the required uniforms to the current buffer.
  103732. * @param uniformBuffer defines the current uniform buffer.
  103733. */
  103734. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103735. /**
  103736. * Makes a duplicate of the current configuration into another one.
  103737. * @param configuration define the config where to copy the info
  103738. */
  103739. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103740. /**
  103741. * Serializes this Sub Surface configuration.
  103742. * @returns - An object with the serialized config.
  103743. */
  103744. serialize(): any;
  103745. /**
  103746. * Parses a Sub Surface Configuration from a serialized object.
  103747. * @param source - Serialized object.
  103748. */
  103749. parse(source: any): void;
  103750. }
  103751. }
  103752. declare module BABYLON {
  103753. /** @hidden */
  103754. export var pbrFragmentDeclaration: {
  103755. name: string;
  103756. shader: string;
  103757. };
  103758. }
  103759. declare module BABYLON {
  103760. /** @hidden */
  103761. export var pbrUboDeclaration: {
  103762. name: string;
  103763. shader: string;
  103764. };
  103765. }
  103766. declare module BABYLON {
  103767. /** @hidden */
  103768. export var pbrFragmentExtraDeclaration: {
  103769. name: string;
  103770. shader: string;
  103771. };
  103772. }
  103773. declare module BABYLON {
  103774. /** @hidden */
  103775. export var pbrFragmentSamplersDeclaration: {
  103776. name: string;
  103777. shader: string;
  103778. };
  103779. }
  103780. declare module BABYLON {
  103781. /** @hidden */
  103782. export var pbrHelperFunctions: {
  103783. name: string;
  103784. shader: string;
  103785. };
  103786. }
  103787. declare module BABYLON {
  103788. /** @hidden */
  103789. export var harmonicsFunctions: {
  103790. name: string;
  103791. shader: string;
  103792. };
  103793. }
  103794. declare module BABYLON {
  103795. /** @hidden */
  103796. export var pbrDirectLightingSetupFunctions: {
  103797. name: string;
  103798. shader: string;
  103799. };
  103800. }
  103801. declare module BABYLON {
  103802. /** @hidden */
  103803. export var pbrDirectLightingFalloffFunctions: {
  103804. name: string;
  103805. shader: string;
  103806. };
  103807. }
  103808. declare module BABYLON {
  103809. /** @hidden */
  103810. export var pbrBRDFFunctions: {
  103811. name: string;
  103812. shader: string;
  103813. };
  103814. }
  103815. declare module BABYLON {
  103816. /** @hidden */
  103817. export var pbrDirectLightingFunctions: {
  103818. name: string;
  103819. shader: string;
  103820. };
  103821. }
  103822. declare module BABYLON {
  103823. /** @hidden */
  103824. export var pbrIBLFunctions: {
  103825. name: string;
  103826. shader: string;
  103827. };
  103828. }
  103829. declare module BABYLON {
  103830. /** @hidden */
  103831. export var pbrDebug: {
  103832. name: string;
  103833. shader: string;
  103834. };
  103835. }
  103836. declare module BABYLON {
  103837. /** @hidden */
  103838. export var pbrPixelShader: {
  103839. name: string;
  103840. shader: string;
  103841. };
  103842. }
  103843. declare module BABYLON {
  103844. /** @hidden */
  103845. export var pbrVertexDeclaration: {
  103846. name: string;
  103847. shader: string;
  103848. };
  103849. }
  103850. declare module BABYLON {
  103851. /** @hidden */
  103852. export var pbrVertexShader: {
  103853. name: string;
  103854. shader: string;
  103855. };
  103856. }
  103857. declare module BABYLON {
  103858. /**
  103859. * Manages the defines for the PBR Material.
  103860. * @hidden
  103861. */
  103862. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103863. PBR: boolean;
  103864. MAINUV1: boolean;
  103865. MAINUV2: boolean;
  103866. UV1: boolean;
  103867. UV2: boolean;
  103868. ALBEDO: boolean;
  103869. ALBEDODIRECTUV: number;
  103870. VERTEXCOLOR: boolean;
  103871. AMBIENT: boolean;
  103872. AMBIENTDIRECTUV: number;
  103873. AMBIENTINGRAYSCALE: boolean;
  103874. OPACITY: boolean;
  103875. VERTEXALPHA: boolean;
  103876. OPACITYDIRECTUV: number;
  103877. OPACITYRGB: boolean;
  103878. ALPHATEST: boolean;
  103879. DEPTHPREPASS: boolean;
  103880. ALPHABLEND: boolean;
  103881. ALPHAFROMALBEDO: boolean;
  103882. ALPHATESTVALUE: string;
  103883. SPECULAROVERALPHA: boolean;
  103884. RADIANCEOVERALPHA: boolean;
  103885. ALPHAFRESNEL: boolean;
  103886. LINEARALPHAFRESNEL: boolean;
  103887. PREMULTIPLYALPHA: boolean;
  103888. EMISSIVE: boolean;
  103889. EMISSIVEDIRECTUV: number;
  103890. REFLECTIVITY: boolean;
  103891. REFLECTIVITYDIRECTUV: number;
  103892. SPECULARTERM: boolean;
  103893. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103894. MICROSURFACEAUTOMATIC: boolean;
  103895. LODBASEDMICROSFURACE: boolean;
  103896. MICROSURFACEMAP: boolean;
  103897. MICROSURFACEMAPDIRECTUV: number;
  103898. METALLICWORKFLOW: boolean;
  103899. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103900. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103901. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103902. AOSTOREINMETALMAPRED: boolean;
  103903. ENVIRONMENTBRDF: boolean;
  103904. ENVIRONMENTBRDF_RGBD: boolean;
  103905. NORMAL: boolean;
  103906. TANGENT: boolean;
  103907. BUMP: boolean;
  103908. BUMPDIRECTUV: number;
  103909. OBJECTSPACE_NORMALMAP: boolean;
  103910. PARALLAX: boolean;
  103911. PARALLAXOCCLUSION: boolean;
  103912. NORMALXYSCALE: boolean;
  103913. LIGHTMAP: boolean;
  103914. LIGHTMAPDIRECTUV: number;
  103915. USELIGHTMAPASSHADOWMAP: boolean;
  103916. GAMMALIGHTMAP: boolean;
  103917. REFLECTION: boolean;
  103918. REFLECTIONMAP_3D: boolean;
  103919. REFLECTIONMAP_SPHERICAL: boolean;
  103920. REFLECTIONMAP_PLANAR: boolean;
  103921. REFLECTIONMAP_CUBIC: boolean;
  103922. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103923. REFLECTIONMAP_PROJECTION: boolean;
  103924. REFLECTIONMAP_SKYBOX: boolean;
  103925. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103926. REFLECTIONMAP_EXPLICIT: boolean;
  103927. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103928. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103929. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103930. INVERTCUBICMAP: boolean;
  103931. USESPHERICALFROMREFLECTIONMAP: boolean;
  103932. USESPHERICALINVERTEX: boolean;
  103933. REFLECTIONMAP_OPPOSITEZ: boolean;
  103934. LODINREFLECTIONALPHA: boolean;
  103935. GAMMAREFLECTION: boolean;
  103936. RGBDREFLECTION: boolean;
  103937. RADIANCEOCCLUSION: boolean;
  103938. HORIZONOCCLUSION: boolean;
  103939. INSTANCES: boolean;
  103940. NUM_BONE_INFLUENCERS: number;
  103941. BonesPerMesh: number;
  103942. BONETEXTURE: boolean;
  103943. NONUNIFORMSCALING: boolean;
  103944. MORPHTARGETS: boolean;
  103945. MORPHTARGETS_NORMAL: boolean;
  103946. MORPHTARGETS_TANGENT: boolean;
  103947. NUM_MORPH_INFLUENCERS: number;
  103948. IMAGEPROCESSING: boolean;
  103949. VIGNETTE: boolean;
  103950. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103951. VIGNETTEBLENDMODEOPAQUE: boolean;
  103952. TONEMAPPING: boolean;
  103953. TONEMAPPING_ACES: boolean;
  103954. CONTRAST: boolean;
  103955. COLORCURVES: boolean;
  103956. COLORGRADING: boolean;
  103957. COLORGRADING3D: boolean;
  103958. SAMPLER3DGREENDEPTH: boolean;
  103959. SAMPLER3DBGRMAP: boolean;
  103960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103961. EXPOSURE: boolean;
  103962. MULTIVIEW: boolean;
  103963. USEPHYSICALLIGHTFALLOFF: boolean;
  103964. USEGLTFLIGHTFALLOFF: boolean;
  103965. TWOSIDEDLIGHTING: boolean;
  103966. SHADOWFLOAT: boolean;
  103967. CLIPPLANE: boolean;
  103968. CLIPPLANE2: boolean;
  103969. CLIPPLANE3: boolean;
  103970. CLIPPLANE4: boolean;
  103971. POINTSIZE: boolean;
  103972. FOG: boolean;
  103973. LOGARITHMICDEPTH: boolean;
  103974. FORCENORMALFORWARD: boolean;
  103975. SPECULARAA: boolean;
  103976. CLEARCOAT: boolean;
  103977. CLEARCOAT_DEFAULTIOR: boolean;
  103978. CLEARCOAT_TEXTURE: boolean;
  103979. CLEARCOAT_TEXTUREDIRECTUV: number;
  103980. CLEARCOAT_BUMP: boolean;
  103981. CLEARCOAT_BUMPDIRECTUV: number;
  103982. CLEARCOAT_TINT: boolean;
  103983. CLEARCOAT_TINT_TEXTURE: boolean;
  103984. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103985. ANISOTROPIC: boolean;
  103986. ANISOTROPIC_TEXTURE: boolean;
  103987. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103988. BRDF_V_HEIGHT_CORRELATED: boolean;
  103989. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103990. SHEEN: boolean;
  103991. SHEEN_TEXTURE: boolean;
  103992. SHEEN_TEXTUREDIRECTUV: number;
  103993. SHEEN_LINKWITHALBEDO: boolean;
  103994. SUBSURFACE: boolean;
  103995. SS_REFRACTION: boolean;
  103996. SS_TRANSLUCENCY: boolean;
  103997. SS_SCATERRING: boolean;
  103998. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103999. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104000. SS_REFRACTIONMAP_3D: boolean;
  104001. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104002. SS_LODINREFRACTIONALPHA: boolean;
  104003. SS_GAMMAREFRACTION: boolean;
  104004. SS_RGBDREFRACTION: boolean;
  104005. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104006. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104007. UNLIT: boolean;
  104008. DEBUGMODE: number;
  104009. /**
  104010. * Initializes the PBR Material defines.
  104011. */
  104012. constructor();
  104013. /**
  104014. * Resets the PBR Material defines.
  104015. */
  104016. reset(): void;
  104017. }
  104018. /**
  104019. * The Physically based material base class of BJS.
  104020. *
  104021. * This offers the main features of a standard PBR material.
  104022. * For more information, please refer to the documentation :
  104023. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104024. */
  104025. export abstract class PBRBaseMaterial extends PushMaterial {
  104026. /**
  104027. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104028. */
  104029. static readonly PBRMATERIAL_OPAQUE: number;
  104030. /**
  104031. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104032. */
  104033. static readonly PBRMATERIAL_ALPHATEST: number;
  104034. /**
  104035. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104036. */
  104037. static readonly PBRMATERIAL_ALPHABLEND: number;
  104038. /**
  104039. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104040. * They are also discarded below the alpha cutoff threshold to improve performances.
  104041. */
  104042. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104043. /**
  104044. * Defines the default value of how much AO map is occluding the analytical lights
  104045. * (point spot...).
  104046. */
  104047. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104048. /**
  104049. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104050. */
  104051. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104052. /**
  104053. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104054. * to enhance interoperability with other engines.
  104055. */
  104056. static readonly LIGHTFALLOFF_GLTF: number;
  104057. /**
  104058. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104059. * to enhance interoperability with other materials.
  104060. */
  104061. static readonly LIGHTFALLOFF_STANDARD: number;
  104062. /**
  104063. * Intensity of the direct lights e.g. the four lights available in your scene.
  104064. * This impacts both the direct diffuse and specular highlights.
  104065. */
  104066. protected _directIntensity: number;
  104067. /**
  104068. * Intensity of the emissive part of the material.
  104069. * This helps controlling the emissive effect without modifying the emissive color.
  104070. */
  104071. protected _emissiveIntensity: number;
  104072. /**
  104073. * Intensity of the environment e.g. how much the environment will light the object
  104074. * either through harmonics for rough material or through the refelction for shiny ones.
  104075. */
  104076. protected _environmentIntensity: number;
  104077. /**
  104078. * This is a special control allowing the reduction of the specular highlights coming from the
  104079. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104080. */
  104081. protected _specularIntensity: number;
  104082. /**
  104083. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104084. */
  104085. private _lightingInfos;
  104086. /**
  104087. * Debug Control allowing disabling the bump map on this material.
  104088. */
  104089. protected _disableBumpMap: boolean;
  104090. /**
  104091. * AKA Diffuse Texture in standard nomenclature.
  104092. */
  104093. protected _albedoTexture: BaseTexture;
  104094. /**
  104095. * AKA Occlusion Texture in other nomenclature.
  104096. */
  104097. protected _ambientTexture: BaseTexture;
  104098. /**
  104099. * AKA Occlusion Texture Intensity in other nomenclature.
  104100. */
  104101. protected _ambientTextureStrength: number;
  104102. /**
  104103. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104104. * 1 means it completely occludes it
  104105. * 0 mean it has no impact
  104106. */
  104107. protected _ambientTextureImpactOnAnalyticalLights: number;
  104108. /**
  104109. * Stores the alpha values in a texture.
  104110. */
  104111. protected _opacityTexture: BaseTexture;
  104112. /**
  104113. * Stores the reflection values in a texture.
  104114. */
  104115. protected _reflectionTexture: BaseTexture;
  104116. /**
  104117. * Stores the emissive values in a texture.
  104118. */
  104119. protected _emissiveTexture: BaseTexture;
  104120. /**
  104121. * AKA Specular texture in other nomenclature.
  104122. */
  104123. protected _reflectivityTexture: BaseTexture;
  104124. /**
  104125. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104126. */
  104127. protected _metallicTexture: BaseTexture;
  104128. /**
  104129. * Specifies the metallic scalar of the metallic/roughness workflow.
  104130. * Can also be used to scale the metalness values of the metallic texture.
  104131. */
  104132. protected _metallic: Nullable<number>;
  104133. /**
  104134. * Specifies the roughness scalar of the metallic/roughness workflow.
  104135. * Can also be used to scale the roughness values of the metallic texture.
  104136. */
  104137. protected _roughness: Nullable<number>;
  104138. /**
  104139. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104140. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104141. */
  104142. protected _microSurfaceTexture: BaseTexture;
  104143. /**
  104144. * Stores surface normal data used to displace a mesh in a texture.
  104145. */
  104146. protected _bumpTexture: BaseTexture;
  104147. /**
  104148. * Stores the pre-calculated light information of a mesh in a texture.
  104149. */
  104150. protected _lightmapTexture: BaseTexture;
  104151. /**
  104152. * The color of a material in ambient lighting.
  104153. */
  104154. protected _ambientColor: Color3;
  104155. /**
  104156. * AKA Diffuse Color in other nomenclature.
  104157. */
  104158. protected _albedoColor: Color3;
  104159. /**
  104160. * AKA Specular Color in other nomenclature.
  104161. */
  104162. protected _reflectivityColor: Color3;
  104163. /**
  104164. * The color applied when light is reflected from a material.
  104165. */
  104166. protected _reflectionColor: Color3;
  104167. /**
  104168. * The color applied when light is emitted from a material.
  104169. */
  104170. protected _emissiveColor: Color3;
  104171. /**
  104172. * AKA Glossiness in other nomenclature.
  104173. */
  104174. protected _microSurface: number;
  104175. /**
  104176. * Specifies that the material will use the light map as a show map.
  104177. */
  104178. protected _useLightmapAsShadowmap: boolean;
  104179. /**
  104180. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104181. * makes the reflect vector face the model (under horizon).
  104182. */
  104183. protected _useHorizonOcclusion: boolean;
  104184. /**
  104185. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104186. * too much the area relying on ambient texture to define their ambient occlusion.
  104187. */
  104188. protected _useRadianceOcclusion: boolean;
  104189. /**
  104190. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104191. */
  104192. protected _useAlphaFromAlbedoTexture: boolean;
  104193. /**
  104194. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104195. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104196. */
  104197. protected _useSpecularOverAlpha: boolean;
  104198. /**
  104199. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104200. */
  104201. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104202. /**
  104203. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104204. */
  104205. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104206. /**
  104207. * Specifies if the metallic texture contains the roughness information in its green channel.
  104208. */
  104209. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104210. /**
  104211. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104212. */
  104213. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104214. /**
  104215. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104216. */
  104217. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104218. /**
  104219. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104220. */
  104221. protected _useAmbientInGrayScale: boolean;
  104222. /**
  104223. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104224. * The material will try to infer what glossiness each pixel should be.
  104225. */
  104226. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104227. /**
  104228. * Defines the falloff type used in this material.
  104229. * It by default is Physical.
  104230. */
  104231. protected _lightFalloff: number;
  104232. /**
  104233. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104234. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104235. */
  104236. protected _useRadianceOverAlpha: boolean;
  104237. /**
  104238. * Allows using an object space normal map (instead of tangent space).
  104239. */
  104240. protected _useObjectSpaceNormalMap: boolean;
  104241. /**
  104242. * Allows using the bump map in parallax mode.
  104243. */
  104244. protected _useParallax: boolean;
  104245. /**
  104246. * Allows using the bump map in parallax occlusion mode.
  104247. */
  104248. protected _useParallaxOcclusion: boolean;
  104249. /**
  104250. * Controls the scale bias of the parallax mode.
  104251. */
  104252. protected _parallaxScaleBias: number;
  104253. /**
  104254. * If sets to true, disables all the lights affecting the material.
  104255. */
  104256. protected _disableLighting: boolean;
  104257. /**
  104258. * Number of Simultaneous lights allowed on the material.
  104259. */
  104260. protected _maxSimultaneousLights: number;
  104261. /**
  104262. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104263. */
  104264. protected _invertNormalMapX: boolean;
  104265. /**
  104266. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104267. */
  104268. protected _invertNormalMapY: boolean;
  104269. /**
  104270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104271. */
  104272. protected _twoSidedLighting: boolean;
  104273. /**
  104274. * Defines the alpha limits in alpha test mode.
  104275. */
  104276. protected _alphaCutOff: number;
  104277. /**
  104278. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104279. */
  104280. protected _forceAlphaTest: boolean;
  104281. /**
  104282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104283. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104284. */
  104285. protected _useAlphaFresnel: boolean;
  104286. /**
  104287. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104288. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104289. */
  104290. protected _useLinearAlphaFresnel: boolean;
  104291. /**
  104292. * The transparency mode of the material.
  104293. */
  104294. protected _transparencyMode: Nullable<number>;
  104295. /**
  104296. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104297. * from cos thetav and roughness:
  104298. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104299. */
  104300. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104301. /**
  104302. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104303. */
  104304. protected _forceIrradianceInFragment: boolean;
  104305. /**
  104306. * Force normal to face away from face.
  104307. */
  104308. protected _forceNormalForward: boolean;
  104309. /**
  104310. * Enables specular anti aliasing in the PBR shader.
  104311. * It will both interacts on the Geometry for analytical and IBL lighting.
  104312. * It also prefilter the roughness map based on the bump values.
  104313. */
  104314. protected _enableSpecularAntiAliasing: boolean;
  104315. /**
  104316. * Default configuration related to image processing available in the PBR Material.
  104317. */
  104318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104319. /**
  104320. * Keep track of the image processing observer to allow dispose and replace.
  104321. */
  104322. private _imageProcessingObserver;
  104323. /**
  104324. * Attaches a new image processing configuration to the PBR Material.
  104325. * @param configuration
  104326. */
  104327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104328. /**
  104329. * Stores the available render targets.
  104330. */
  104331. private _renderTargets;
  104332. /**
  104333. * Sets the global ambient color for the material used in lighting calculations.
  104334. */
  104335. private _globalAmbientColor;
  104336. /**
  104337. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104338. */
  104339. private _useLogarithmicDepth;
  104340. /**
  104341. * If set to true, no lighting calculations will be applied.
  104342. */
  104343. private _unlit;
  104344. private _debugMode;
  104345. /**
  104346. * @hidden
  104347. * This is reserved for the inspector.
  104348. * Defines the material debug mode.
  104349. * It helps seeing only some components of the material while troubleshooting.
  104350. */
  104351. debugMode: number;
  104352. /**
  104353. * @hidden
  104354. * This is reserved for the inspector.
  104355. * Specify from where on screen the debug mode should start.
  104356. * The value goes from -1 (full screen) to 1 (not visible)
  104357. * It helps with side by side comparison against the final render
  104358. * This defaults to -1
  104359. */
  104360. private debugLimit;
  104361. /**
  104362. * @hidden
  104363. * This is reserved for the inspector.
  104364. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104365. * You can use the factor to better multiply the final value.
  104366. */
  104367. private debugFactor;
  104368. /**
  104369. * Defines the clear coat layer parameters for the material.
  104370. */
  104371. readonly clearCoat: PBRClearCoatConfiguration;
  104372. /**
  104373. * Defines the anisotropic parameters for the material.
  104374. */
  104375. readonly anisotropy: PBRAnisotropicConfiguration;
  104376. /**
  104377. * Defines the BRDF parameters for the material.
  104378. */
  104379. readonly brdf: PBRBRDFConfiguration;
  104380. /**
  104381. * Defines the Sheen parameters for the material.
  104382. */
  104383. readonly sheen: PBRSheenConfiguration;
  104384. /**
  104385. * Defines the SubSurface parameters for the material.
  104386. */
  104387. readonly subSurface: PBRSubSurfaceConfiguration;
  104388. /**
  104389. * Custom callback helping to override the default shader used in the material.
  104390. */
  104391. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104392. /**
  104393. * Instantiates a new PBRMaterial instance.
  104394. *
  104395. * @param name The material name
  104396. * @param scene The scene the material will be use in.
  104397. */
  104398. constructor(name: string, scene: Scene);
  104399. /**
  104400. * Gets a boolean indicating that current material needs to register RTT
  104401. */
  104402. readonly hasRenderTargetTextures: boolean;
  104403. /**
  104404. * Gets the name of the material class.
  104405. */
  104406. getClassName(): string;
  104407. /**
  104408. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104409. */
  104410. /**
  104411. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104412. */
  104413. useLogarithmicDepth: boolean;
  104414. /**
  104415. * Gets the current transparency mode.
  104416. */
  104417. /**
  104418. * Sets the transparency mode of the material.
  104419. *
  104420. * | Value | Type | Description |
  104421. * | ----- | ----------------------------------- | ----------- |
  104422. * | 0 | OPAQUE | |
  104423. * | 1 | ALPHATEST | |
  104424. * | 2 | ALPHABLEND | |
  104425. * | 3 | ALPHATESTANDBLEND | |
  104426. *
  104427. */
  104428. transparencyMode: Nullable<number>;
  104429. /**
  104430. * Returns true if alpha blending should be disabled.
  104431. */
  104432. private readonly _disableAlphaBlending;
  104433. /**
  104434. * Specifies whether or not this material should be rendered in alpha blend mode.
  104435. */
  104436. needAlphaBlending(): boolean;
  104437. /**
  104438. * Specifies if the mesh will require alpha blending.
  104439. * @param mesh - BJS mesh.
  104440. */
  104441. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104442. /**
  104443. * Specifies whether or not this material should be rendered in alpha test mode.
  104444. */
  104445. needAlphaTesting(): boolean;
  104446. /**
  104447. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104448. */
  104449. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104450. /**
  104451. * Gets the texture used for the alpha test.
  104452. */
  104453. getAlphaTestTexture(): BaseTexture;
  104454. /**
  104455. * Specifies that the submesh is ready to be used.
  104456. * @param mesh - BJS mesh.
  104457. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104458. * @param useInstances - Specifies that instances should be used.
  104459. * @returns - boolean indicating that the submesh is ready or not.
  104460. */
  104461. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104462. /**
  104463. * Specifies if the material uses metallic roughness workflow.
  104464. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104465. */
  104466. isMetallicWorkflow(): boolean;
  104467. private _prepareEffect;
  104468. private _prepareDefines;
  104469. /**
  104470. * Force shader compilation
  104471. */
  104472. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104473. clipPlane: boolean;
  104474. }>): void;
  104475. /**
  104476. * Initializes the uniform buffer layout for the shader.
  104477. */
  104478. buildUniformLayout(): void;
  104479. /**
  104480. * Unbinds the material from the mesh
  104481. */
  104482. unbind(): void;
  104483. /**
  104484. * Binds the submesh data.
  104485. * @param world - The world matrix.
  104486. * @param mesh - The BJS mesh.
  104487. * @param subMesh - A submesh of the BJS mesh.
  104488. */
  104489. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104490. /**
  104491. * Returns the animatable textures.
  104492. * @returns - Array of animatable textures.
  104493. */
  104494. getAnimatables(): IAnimatable[];
  104495. /**
  104496. * Returns the texture used for reflections.
  104497. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104498. */
  104499. private _getReflectionTexture;
  104500. /**
  104501. * Returns an array of the actively used textures.
  104502. * @returns - Array of BaseTextures
  104503. */
  104504. getActiveTextures(): BaseTexture[];
  104505. /**
  104506. * Checks to see if a texture is used in the material.
  104507. * @param texture - Base texture to use.
  104508. * @returns - Boolean specifying if a texture is used in the material.
  104509. */
  104510. hasTexture(texture: BaseTexture): boolean;
  104511. /**
  104512. * Disposes the resources of the material.
  104513. * @param forceDisposeEffect - Forces the disposal of effects.
  104514. * @param forceDisposeTextures - Forces the disposal of all textures.
  104515. */
  104516. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104517. }
  104518. }
  104519. declare module BABYLON {
  104520. /**
  104521. * The Physically based material of BJS.
  104522. *
  104523. * This offers the main features of a standard PBR material.
  104524. * For more information, please refer to the documentation :
  104525. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104526. */
  104527. export class PBRMaterial extends PBRBaseMaterial {
  104528. /**
  104529. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104530. */
  104531. static readonly PBRMATERIAL_OPAQUE: number;
  104532. /**
  104533. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104534. */
  104535. static readonly PBRMATERIAL_ALPHATEST: number;
  104536. /**
  104537. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104538. */
  104539. static readonly PBRMATERIAL_ALPHABLEND: number;
  104540. /**
  104541. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104542. * They are also discarded below the alpha cutoff threshold to improve performances.
  104543. */
  104544. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104545. /**
  104546. * Defines the default value of how much AO map is occluding the analytical lights
  104547. * (point spot...).
  104548. */
  104549. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104550. /**
  104551. * Intensity of the direct lights e.g. the four lights available in your scene.
  104552. * This impacts both the direct diffuse and specular highlights.
  104553. */
  104554. directIntensity: number;
  104555. /**
  104556. * Intensity of the emissive part of the material.
  104557. * This helps controlling the emissive effect without modifying the emissive color.
  104558. */
  104559. emissiveIntensity: number;
  104560. /**
  104561. * Intensity of the environment e.g. how much the environment will light the object
  104562. * either through harmonics for rough material or through the refelction for shiny ones.
  104563. */
  104564. environmentIntensity: number;
  104565. /**
  104566. * This is a special control allowing the reduction of the specular highlights coming from the
  104567. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104568. */
  104569. specularIntensity: number;
  104570. /**
  104571. * Debug Control allowing disabling the bump map on this material.
  104572. */
  104573. disableBumpMap: boolean;
  104574. /**
  104575. * AKA Diffuse Texture in standard nomenclature.
  104576. */
  104577. albedoTexture: BaseTexture;
  104578. /**
  104579. * AKA Occlusion Texture in other nomenclature.
  104580. */
  104581. ambientTexture: BaseTexture;
  104582. /**
  104583. * AKA Occlusion Texture Intensity in other nomenclature.
  104584. */
  104585. ambientTextureStrength: number;
  104586. /**
  104587. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104588. * 1 means it completely occludes it
  104589. * 0 mean it has no impact
  104590. */
  104591. ambientTextureImpactOnAnalyticalLights: number;
  104592. /**
  104593. * Stores the alpha values in a texture.
  104594. */
  104595. opacityTexture: BaseTexture;
  104596. /**
  104597. * Stores the reflection values in a texture.
  104598. */
  104599. reflectionTexture: Nullable<BaseTexture>;
  104600. /**
  104601. * Stores the emissive values in a texture.
  104602. */
  104603. emissiveTexture: BaseTexture;
  104604. /**
  104605. * AKA Specular texture in other nomenclature.
  104606. */
  104607. reflectivityTexture: BaseTexture;
  104608. /**
  104609. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104610. */
  104611. metallicTexture: BaseTexture;
  104612. /**
  104613. * Specifies the metallic scalar of the metallic/roughness workflow.
  104614. * Can also be used to scale the metalness values of the metallic texture.
  104615. */
  104616. metallic: Nullable<number>;
  104617. /**
  104618. * Specifies the roughness scalar of the metallic/roughness workflow.
  104619. * Can also be used to scale the roughness values of the metallic texture.
  104620. */
  104621. roughness: Nullable<number>;
  104622. /**
  104623. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104624. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104625. */
  104626. microSurfaceTexture: BaseTexture;
  104627. /**
  104628. * Stores surface normal data used to displace a mesh in a texture.
  104629. */
  104630. bumpTexture: BaseTexture;
  104631. /**
  104632. * Stores the pre-calculated light information of a mesh in a texture.
  104633. */
  104634. lightmapTexture: BaseTexture;
  104635. /**
  104636. * Stores the refracted light information in a texture.
  104637. */
  104638. refractionTexture: Nullable<BaseTexture>;
  104639. /**
  104640. * The color of a material in ambient lighting.
  104641. */
  104642. ambientColor: Color3;
  104643. /**
  104644. * AKA Diffuse Color in other nomenclature.
  104645. */
  104646. albedoColor: Color3;
  104647. /**
  104648. * AKA Specular Color in other nomenclature.
  104649. */
  104650. reflectivityColor: Color3;
  104651. /**
  104652. * The color reflected from the material.
  104653. */
  104654. reflectionColor: Color3;
  104655. /**
  104656. * The color emitted from the material.
  104657. */
  104658. emissiveColor: Color3;
  104659. /**
  104660. * AKA Glossiness in other nomenclature.
  104661. */
  104662. microSurface: number;
  104663. /**
  104664. * source material index of refraction (IOR)' / 'destination material IOR.
  104665. */
  104666. indexOfRefraction: number;
  104667. /**
  104668. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104669. */
  104670. invertRefractionY: boolean;
  104671. /**
  104672. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104673. * Materials half opaque for instance using refraction could benefit from this control.
  104674. */
  104675. linkRefractionWithTransparency: boolean;
  104676. /**
  104677. * If true, the light map contains occlusion information instead of lighting info.
  104678. */
  104679. useLightmapAsShadowmap: boolean;
  104680. /**
  104681. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104682. */
  104683. useAlphaFromAlbedoTexture: boolean;
  104684. /**
  104685. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104686. */
  104687. forceAlphaTest: boolean;
  104688. /**
  104689. * Defines the alpha limits in alpha test mode.
  104690. */
  104691. alphaCutOff: number;
  104692. /**
  104693. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104694. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104695. */
  104696. useSpecularOverAlpha: boolean;
  104697. /**
  104698. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104699. */
  104700. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104701. /**
  104702. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104703. */
  104704. useRoughnessFromMetallicTextureAlpha: boolean;
  104705. /**
  104706. * Specifies if the metallic texture contains the roughness information in its green channel.
  104707. */
  104708. useRoughnessFromMetallicTextureGreen: boolean;
  104709. /**
  104710. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104711. */
  104712. useMetallnessFromMetallicTextureBlue: boolean;
  104713. /**
  104714. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104715. */
  104716. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104717. /**
  104718. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104719. */
  104720. useAmbientInGrayScale: boolean;
  104721. /**
  104722. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104723. * The material will try to infer what glossiness each pixel should be.
  104724. */
  104725. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104726. /**
  104727. * BJS is using an harcoded light falloff based on a manually sets up range.
  104728. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104729. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104730. */
  104731. /**
  104732. * BJS is using an harcoded light falloff based on a manually sets up range.
  104733. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104734. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104735. */
  104736. usePhysicalLightFalloff: boolean;
  104737. /**
  104738. * In order to support the falloff compatibility with gltf, a special mode has been added
  104739. * to reproduce the gltf light falloff.
  104740. */
  104741. /**
  104742. * In order to support the falloff compatibility with gltf, a special mode has been added
  104743. * to reproduce the gltf light falloff.
  104744. */
  104745. useGLTFLightFalloff: boolean;
  104746. /**
  104747. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104748. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104749. */
  104750. useRadianceOverAlpha: boolean;
  104751. /**
  104752. * Allows using an object space normal map (instead of tangent space).
  104753. */
  104754. useObjectSpaceNormalMap: boolean;
  104755. /**
  104756. * Allows using the bump map in parallax mode.
  104757. */
  104758. useParallax: boolean;
  104759. /**
  104760. * Allows using the bump map in parallax occlusion mode.
  104761. */
  104762. useParallaxOcclusion: boolean;
  104763. /**
  104764. * Controls the scale bias of the parallax mode.
  104765. */
  104766. parallaxScaleBias: number;
  104767. /**
  104768. * If sets to true, disables all the lights affecting the material.
  104769. */
  104770. disableLighting: boolean;
  104771. /**
  104772. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104773. */
  104774. forceIrradianceInFragment: boolean;
  104775. /**
  104776. * Number of Simultaneous lights allowed on the material.
  104777. */
  104778. maxSimultaneousLights: number;
  104779. /**
  104780. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104781. */
  104782. invertNormalMapX: boolean;
  104783. /**
  104784. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104785. */
  104786. invertNormalMapY: boolean;
  104787. /**
  104788. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104789. */
  104790. twoSidedLighting: boolean;
  104791. /**
  104792. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104793. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104794. */
  104795. useAlphaFresnel: boolean;
  104796. /**
  104797. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104798. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104799. */
  104800. useLinearAlphaFresnel: boolean;
  104801. /**
  104802. * Let user defines the brdf lookup texture used for IBL.
  104803. * A default 8bit version is embedded but you could point at :
  104804. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104805. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104806. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104807. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104808. */
  104809. environmentBRDFTexture: Nullable<BaseTexture>;
  104810. /**
  104811. * Force normal to face away from face.
  104812. */
  104813. forceNormalForward: boolean;
  104814. /**
  104815. * Enables specular anti aliasing in the PBR shader.
  104816. * It will both interacts on the Geometry for analytical and IBL lighting.
  104817. * It also prefilter the roughness map based on the bump values.
  104818. */
  104819. enableSpecularAntiAliasing: boolean;
  104820. /**
  104821. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104822. * makes the reflect vector face the model (under horizon).
  104823. */
  104824. useHorizonOcclusion: boolean;
  104825. /**
  104826. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104827. * too much the area relying on ambient texture to define their ambient occlusion.
  104828. */
  104829. useRadianceOcclusion: boolean;
  104830. /**
  104831. * If set to true, no lighting calculations will be applied.
  104832. */
  104833. unlit: boolean;
  104834. /**
  104835. * Gets the image processing configuration used either in this material.
  104836. */
  104837. /**
  104838. * Sets the Default image processing configuration used either in the this material.
  104839. *
  104840. * If sets to null, the scene one is in use.
  104841. */
  104842. imageProcessingConfiguration: ImageProcessingConfiguration;
  104843. /**
  104844. * Gets wether the color curves effect is enabled.
  104845. */
  104846. /**
  104847. * Sets wether the color curves effect is enabled.
  104848. */
  104849. cameraColorCurvesEnabled: boolean;
  104850. /**
  104851. * Gets wether the color grading effect is enabled.
  104852. */
  104853. /**
  104854. * Gets wether the color grading effect is enabled.
  104855. */
  104856. cameraColorGradingEnabled: boolean;
  104857. /**
  104858. * Gets wether tonemapping is enabled or not.
  104859. */
  104860. /**
  104861. * Sets wether tonemapping is enabled or not
  104862. */
  104863. cameraToneMappingEnabled: boolean;
  104864. /**
  104865. * The camera exposure used on this material.
  104866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104867. * This corresponds to a photographic exposure.
  104868. */
  104869. /**
  104870. * The camera exposure used on this material.
  104871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104872. * This corresponds to a photographic exposure.
  104873. */
  104874. cameraExposure: number;
  104875. /**
  104876. * Gets The camera contrast used on this material.
  104877. */
  104878. /**
  104879. * Sets The camera contrast used on this material.
  104880. */
  104881. cameraContrast: number;
  104882. /**
  104883. * Gets the Color Grading 2D Lookup Texture.
  104884. */
  104885. /**
  104886. * Sets the Color Grading 2D Lookup Texture.
  104887. */
  104888. cameraColorGradingTexture: Nullable<BaseTexture>;
  104889. /**
  104890. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104891. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104892. * 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;
  104893. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104894. */
  104895. /**
  104896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104898. * 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;
  104899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104900. */
  104901. cameraColorCurves: Nullable<ColorCurves>;
  104902. /**
  104903. * Instantiates a new PBRMaterial instance.
  104904. *
  104905. * @param name The material name
  104906. * @param scene The scene the material will be use in.
  104907. */
  104908. constructor(name: string, scene: Scene);
  104909. /**
  104910. * Returns the name of this material class.
  104911. */
  104912. getClassName(): string;
  104913. /**
  104914. * Makes a duplicate of the current material.
  104915. * @param name - name to use for the new material.
  104916. */
  104917. clone(name: string): PBRMaterial;
  104918. /**
  104919. * Serializes this PBR Material.
  104920. * @returns - An object with the serialized material.
  104921. */
  104922. serialize(): any;
  104923. /**
  104924. * Parses a PBR Material from a serialized object.
  104925. * @param source - Serialized object.
  104926. * @param scene - BJS scene instance.
  104927. * @param rootUrl - url for the scene object
  104928. * @returns - PBRMaterial
  104929. */
  104930. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104931. }
  104932. }
  104933. declare module BABYLON {
  104934. /**
  104935. * Direct draw surface info
  104936. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104937. */
  104938. export interface DDSInfo {
  104939. /**
  104940. * Width of the texture
  104941. */
  104942. width: number;
  104943. /**
  104944. * Width of the texture
  104945. */
  104946. height: number;
  104947. /**
  104948. * Number of Mipmaps for the texture
  104949. * @see https://en.wikipedia.org/wiki/Mipmap
  104950. */
  104951. mipmapCount: number;
  104952. /**
  104953. * If the textures format is a known fourCC format
  104954. * @see https://www.fourcc.org/
  104955. */
  104956. isFourCC: boolean;
  104957. /**
  104958. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104959. */
  104960. isRGB: boolean;
  104961. /**
  104962. * If the texture is a lumincance format
  104963. */
  104964. isLuminance: boolean;
  104965. /**
  104966. * If this is a cube texture
  104967. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104968. */
  104969. isCube: boolean;
  104970. /**
  104971. * If the texture is a compressed format eg. FOURCC_DXT1
  104972. */
  104973. isCompressed: boolean;
  104974. /**
  104975. * The dxgiFormat of the texture
  104976. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104977. */
  104978. dxgiFormat: number;
  104979. /**
  104980. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104981. */
  104982. textureType: number;
  104983. /**
  104984. * Sphericle polynomial created for the dds texture
  104985. */
  104986. sphericalPolynomial?: SphericalPolynomial;
  104987. }
  104988. /**
  104989. * Class used to provide DDS decompression tools
  104990. */
  104991. export class DDSTools {
  104992. /**
  104993. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104994. */
  104995. static StoreLODInAlphaChannel: boolean;
  104996. /**
  104997. * Gets DDS information from an array buffer
  104998. * @param arrayBuffer defines the array buffer to read data from
  104999. * @returns the DDS information
  105000. */
  105001. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105002. private static _FloatView;
  105003. private static _Int32View;
  105004. private static _ToHalfFloat;
  105005. private static _FromHalfFloat;
  105006. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105007. private static _GetHalfFloatRGBAArrayBuffer;
  105008. private static _GetFloatRGBAArrayBuffer;
  105009. private static _GetFloatAsUIntRGBAArrayBuffer;
  105010. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105011. private static _GetRGBAArrayBuffer;
  105012. private static _ExtractLongWordOrder;
  105013. private static _GetRGBArrayBuffer;
  105014. private static _GetLuminanceArrayBuffer;
  105015. /**
  105016. * Uploads DDS Levels to a Babylon Texture
  105017. * @hidden
  105018. */
  105019. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105020. }
  105021. interface Engine {
  105022. /**
  105023. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105024. * @param rootUrl defines the url where the file to load is located
  105025. * @param scene defines the current scene
  105026. * @param lodScale defines scale to apply to the mip map selection
  105027. * @param lodOffset defines offset to apply to the mip map selection
  105028. * @param onLoad defines an optional callback raised when the texture is loaded
  105029. * @param onError defines an optional callback raised if there is an issue to load the texture
  105030. * @param format defines the format of the data
  105031. * @param forcedExtension defines the extension to use to pick the right loader
  105032. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105033. * @returns the cube texture as an InternalTexture
  105034. */
  105035. 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;
  105036. }
  105037. }
  105038. declare module BABYLON {
  105039. /**
  105040. * Implementation of the DDS Texture Loader.
  105041. * @hidden
  105042. */
  105043. export class _DDSTextureLoader implements IInternalTextureLoader {
  105044. /**
  105045. * Defines wether the loader supports cascade loading the different faces.
  105046. */
  105047. readonly supportCascades: boolean;
  105048. /**
  105049. * This returns if the loader support the current file information.
  105050. * @param extension defines the file extension of the file being loaded
  105051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105052. * @param fallback defines the fallback internal texture if any
  105053. * @param isBase64 defines whether the texture is encoded as a base64
  105054. * @param isBuffer defines whether the texture data are stored as a buffer
  105055. * @returns true if the loader can load the specified file
  105056. */
  105057. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105058. /**
  105059. * Transform the url before loading if required.
  105060. * @param rootUrl the url of the texture
  105061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105062. * @returns the transformed texture
  105063. */
  105064. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105065. /**
  105066. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105067. * @param rootUrl the url of the texture
  105068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105069. * @returns the fallback texture
  105070. */
  105071. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105072. /**
  105073. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105074. * @param data contains the texture data
  105075. * @param texture defines the BabylonJS internal texture
  105076. * @param createPolynomials will be true if polynomials have been requested
  105077. * @param onLoad defines the callback to trigger once the texture is ready
  105078. * @param onError defines the callback to trigger in case of error
  105079. */
  105080. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105081. /**
  105082. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105083. * @param data contains the texture data
  105084. * @param texture defines the BabylonJS internal texture
  105085. * @param callback defines the method to call once ready to upload
  105086. */
  105087. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /** @hidden */
  105092. export var rgbdEncodePixelShader: {
  105093. name: string;
  105094. shader: string;
  105095. };
  105096. }
  105097. declare module BABYLON {
  105098. /**
  105099. * Raw texture data and descriptor sufficient for WebGL texture upload
  105100. */
  105101. export interface EnvironmentTextureInfo {
  105102. /**
  105103. * Version of the environment map
  105104. */
  105105. version: number;
  105106. /**
  105107. * Width of image
  105108. */
  105109. width: number;
  105110. /**
  105111. * Irradiance information stored in the file.
  105112. */
  105113. irradiance: any;
  105114. /**
  105115. * Specular information stored in the file.
  105116. */
  105117. specular: any;
  105118. }
  105119. /**
  105120. * Sets of helpers addressing the serialization and deserialization of environment texture
  105121. * stored in a BabylonJS env file.
  105122. * Those files are usually stored as .env files.
  105123. */
  105124. export class EnvironmentTextureTools {
  105125. /**
  105126. * Magic number identifying the env file.
  105127. */
  105128. private static _MagicBytes;
  105129. /**
  105130. * Gets the environment info from an env file.
  105131. * @param data The array buffer containing the .env bytes.
  105132. * @returns the environment file info (the json header) if successfully parsed.
  105133. */
  105134. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105135. /**
  105136. * Creates an environment texture from a loaded cube texture.
  105137. * @param texture defines the cube texture to convert in env file
  105138. * @return a promise containing the environment data if succesfull.
  105139. */
  105140. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105141. /**
  105142. * Creates a JSON representation of the spherical data.
  105143. * @param texture defines the texture containing the polynomials
  105144. * @return the JSON representation of the spherical info
  105145. */
  105146. private static _CreateEnvTextureIrradiance;
  105147. /**
  105148. * Uploads the texture info contained in the env file to the GPU.
  105149. * @param texture defines the internal texture to upload to
  105150. * @param arrayBuffer defines the buffer cotaining the data to load
  105151. * @param info defines the texture info retrieved through the GetEnvInfo method
  105152. * @returns a promise
  105153. */
  105154. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105155. /**
  105156. * Uploads the levels of image data to the GPU.
  105157. * @param texture defines the internal texture to upload to
  105158. * @param imageData defines the array buffer views of image data [mipmap][face]
  105159. * @returns a promise
  105160. */
  105161. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105162. /**
  105163. * Uploads spherical polynomials information to the texture.
  105164. * @param texture defines the texture we are trying to upload the information to
  105165. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105166. */
  105167. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105168. /** @hidden */
  105169. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105170. }
  105171. }
  105172. declare module BABYLON {
  105173. /**
  105174. * Implementation of the ENV Texture Loader.
  105175. * @hidden
  105176. */
  105177. export class _ENVTextureLoader implements IInternalTextureLoader {
  105178. /**
  105179. * Defines wether the loader supports cascade loading the different faces.
  105180. */
  105181. readonly supportCascades: boolean;
  105182. /**
  105183. * This returns if the loader support the current file information.
  105184. * @param extension defines the file extension of the file being loaded
  105185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105186. * @param fallback defines the fallback internal texture if any
  105187. * @param isBase64 defines whether the texture is encoded as a base64
  105188. * @param isBuffer defines whether the texture data are stored as a buffer
  105189. * @returns true if the loader can load the specified file
  105190. */
  105191. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105192. /**
  105193. * Transform the url before loading if required.
  105194. * @param rootUrl the url of the texture
  105195. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105196. * @returns the transformed texture
  105197. */
  105198. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105199. /**
  105200. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105201. * @param rootUrl the url of the texture
  105202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105203. * @returns the fallback texture
  105204. */
  105205. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105206. /**
  105207. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105208. * @param data contains the texture data
  105209. * @param texture defines the BabylonJS internal texture
  105210. * @param createPolynomials will be true if polynomials have been requested
  105211. * @param onLoad defines the callback to trigger once the texture is ready
  105212. * @param onError defines the callback to trigger in case of error
  105213. */
  105214. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105215. /**
  105216. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105217. * @param data contains the texture data
  105218. * @param texture defines the BabylonJS internal texture
  105219. * @param callback defines the method to call once ready to upload
  105220. */
  105221. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105222. }
  105223. }
  105224. declare module BABYLON {
  105225. /**
  105226. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105227. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105228. */
  105229. export class KhronosTextureContainer {
  105230. /** contents of the KTX container file */
  105231. arrayBuffer: any;
  105232. private static HEADER_LEN;
  105233. private static COMPRESSED_2D;
  105234. private static COMPRESSED_3D;
  105235. private static TEX_2D;
  105236. private static TEX_3D;
  105237. /**
  105238. * Gets the openGL type
  105239. */
  105240. glType: number;
  105241. /**
  105242. * Gets the openGL type size
  105243. */
  105244. glTypeSize: number;
  105245. /**
  105246. * Gets the openGL format
  105247. */
  105248. glFormat: number;
  105249. /**
  105250. * Gets the openGL internal format
  105251. */
  105252. glInternalFormat: number;
  105253. /**
  105254. * Gets the base internal format
  105255. */
  105256. glBaseInternalFormat: number;
  105257. /**
  105258. * Gets image width in pixel
  105259. */
  105260. pixelWidth: number;
  105261. /**
  105262. * Gets image height in pixel
  105263. */
  105264. pixelHeight: number;
  105265. /**
  105266. * Gets image depth in pixels
  105267. */
  105268. pixelDepth: number;
  105269. /**
  105270. * Gets the number of array elements
  105271. */
  105272. numberOfArrayElements: number;
  105273. /**
  105274. * Gets the number of faces
  105275. */
  105276. numberOfFaces: number;
  105277. /**
  105278. * Gets the number of mipmap levels
  105279. */
  105280. numberOfMipmapLevels: number;
  105281. /**
  105282. * Gets the bytes of key value data
  105283. */
  105284. bytesOfKeyValueData: number;
  105285. /**
  105286. * Gets the load type
  105287. */
  105288. loadType: number;
  105289. /**
  105290. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105291. */
  105292. isInvalid: boolean;
  105293. /**
  105294. * Creates a new KhronosTextureContainer
  105295. * @param arrayBuffer contents of the KTX container file
  105296. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105297. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105298. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105299. */
  105300. constructor(
  105301. /** contents of the KTX container file */
  105302. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105303. /**
  105304. * Uploads KTX content to a Babylon Texture.
  105305. * It is assumed that the texture has already been created & is currently bound
  105306. * @hidden
  105307. */
  105308. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105309. private _upload2DCompressedLevels;
  105310. }
  105311. }
  105312. declare module BABYLON {
  105313. /**
  105314. * Implementation of the KTX Texture Loader.
  105315. * @hidden
  105316. */
  105317. export class _KTXTextureLoader implements IInternalTextureLoader {
  105318. /**
  105319. * Defines wether the loader supports cascade loading the different faces.
  105320. */
  105321. readonly supportCascades: boolean;
  105322. /**
  105323. * This returns if the loader support the current file information.
  105324. * @param extension defines the file extension of the file being loaded
  105325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105326. * @param fallback defines the fallback internal texture if any
  105327. * @param isBase64 defines whether the texture is encoded as a base64
  105328. * @param isBuffer defines whether the texture data are stored as a buffer
  105329. * @returns true if the loader can load the specified file
  105330. */
  105331. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105332. /**
  105333. * Transform the url before loading if required.
  105334. * @param rootUrl the url of the texture
  105335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105336. * @returns the transformed texture
  105337. */
  105338. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105339. /**
  105340. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105341. * @param rootUrl the url of the texture
  105342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105343. * @returns the fallback texture
  105344. */
  105345. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105346. /**
  105347. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105348. * @param data contains the texture data
  105349. * @param texture defines the BabylonJS internal texture
  105350. * @param createPolynomials will be true if polynomials have been requested
  105351. * @param onLoad defines the callback to trigger once the texture is ready
  105352. * @param onError defines the callback to trigger in case of error
  105353. */
  105354. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105355. /**
  105356. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105357. * @param data contains the texture data
  105358. * @param texture defines the BabylonJS internal texture
  105359. * @param callback defines the method to call once ready to upload
  105360. */
  105361. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105362. }
  105363. }
  105364. declare module BABYLON {
  105365. /** @hidden */
  105366. export var _forceSceneHelpersToBundle: boolean;
  105367. interface Scene {
  105368. /**
  105369. * Creates a default light for the scene.
  105370. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105371. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105372. */
  105373. createDefaultLight(replace?: boolean): void;
  105374. /**
  105375. * Creates a default camera for the scene.
  105376. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105377. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105378. * @param replace has default false, when true replaces the active camera in the scene
  105379. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105380. */
  105381. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105382. /**
  105383. * Creates a default camera and a default light.
  105384. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105385. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105386. * @param replace has the default false, when true replaces the active camera/light in the scene
  105387. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105388. */
  105389. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105390. /**
  105391. * Creates a new sky box
  105392. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105393. * @param environmentTexture defines the texture to use as environment texture
  105394. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105395. * @param scale defines the overall scale of the skybox
  105396. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105397. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105398. * @returns a new mesh holding the sky box
  105399. */
  105400. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105401. /**
  105402. * Creates a new environment
  105403. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105404. * @param options defines the options you can use to configure the environment
  105405. * @returns the new EnvironmentHelper
  105406. */
  105407. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105408. /**
  105409. * Creates a new VREXperienceHelper
  105410. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105411. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105412. * @returns a new VREXperienceHelper
  105413. */
  105414. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105415. /**
  105416. * Creates a new XREXperienceHelper
  105417. * @see http://doc.babylonjs.com/how_to/webxr
  105418. * @returns a promise for a new XREXperienceHelper
  105419. */
  105420. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105421. }
  105422. }
  105423. declare module BABYLON {
  105424. /**
  105425. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105426. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105427. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105428. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105429. */
  105430. export class VideoDome extends TransformNode {
  105431. /**
  105432. * Define the video source as a Monoscopic panoramic 360 video.
  105433. */
  105434. static readonly MODE_MONOSCOPIC: number;
  105435. /**
  105436. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105437. */
  105438. static readonly MODE_TOPBOTTOM: number;
  105439. /**
  105440. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105441. */
  105442. static readonly MODE_SIDEBYSIDE: number;
  105443. private _useDirectMapping;
  105444. /**
  105445. * The video texture being displayed on the sphere
  105446. */
  105447. protected _videoTexture: VideoTexture;
  105448. /**
  105449. * Gets the video texture being displayed on the sphere
  105450. */
  105451. readonly videoTexture: VideoTexture;
  105452. /**
  105453. * The skybox material
  105454. */
  105455. protected _material: BackgroundMaterial;
  105456. /**
  105457. * The surface used for the skybox
  105458. */
  105459. protected _mesh: Mesh;
  105460. /**
  105461. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105462. * Also see the options.resolution property.
  105463. */
  105464. fovMultiplier: number;
  105465. private _videoMode;
  105466. /**
  105467. * Gets or set the current video mode for the video. It can be:
  105468. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105469. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105470. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105471. */
  105472. videoMode: number;
  105473. /**
  105474. * Oberserver used in Stereoscopic VR Mode.
  105475. */
  105476. private _onBeforeCameraRenderObserver;
  105477. /**
  105478. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105479. * @param name Element's name, child elements will append suffixes for their own names.
  105480. * @param urlsOrVideo defines the url(s) or the video element to use
  105481. * @param options An object containing optional or exposed sub element properties
  105482. */
  105483. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105484. resolution?: number;
  105485. clickToPlay?: boolean;
  105486. autoPlay?: boolean;
  105487. loop?: boolean;
  105488. size?: number;
  105489. poster?: string;
  105490. faceForward?: boolean;
  105491. useDirectMapping?: boolean;
  105492. }, scene: Scene);
  105493. private _changeVideoMode;
  105494. /**
  105495. * Releases resources associated with this node.
  105496. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105497. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105498. */
  105499. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105500. }
  105501. }
  105502. declare module BABYLON {
  105503. /**
  105504. * This class can be used to get instrumentation data from a Babylon engine
  105505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105506. */
  105507. export class EngineInstrumentation implements IDisposable {
  105508. /**
  105509. * Define the instrumented engine.
  105510. */
  105511. engine: Engine;
  105512. private _captureGPUFrameTime;
  105513. private _gpuFrameTimeToken;
  105514. private _gpuFrameTime;
  105515. private _captureShaderCompilationTime;
  105516. private _shaderCompilationTime;
  105517. private _onBeginFrameObserver;
  105518. private _onEndFrameObserver;
  105519. private _onBeforeShaderCompilationObserver;
  105520. private _onAfterShaderCompilationObserver;
  105521. /**
  105522. * Gets the perf counter used for GPU frame time
  105523. */
  105524. readonly gpuFrameTimeCounter: PerfCounter;
  105525. /**
  105526. * Gets the GPU frame time capture status
  105527. */
  105528. /**
  105529. * Enable or disable the GPU frame time capture
  105530. */
  105531. captureGPUFrameTime: boolean;
  105532. /**
  105533. * Gets the perf counter used for shader compilation time
  105534. */
  105535. readonly shaderCompilationTimeCounter: PerfCounter;
  105536. /**
  105537. * Gets the shader compilation time capture status
  105538. */
  105539. /**
  105540. * Enable or disable the shader compilation time capture
  105541. */
  105542. captureShaderCompilationTime: boolean;
  105543. /**
  105544. * Instantiates a new engine instrumentation.
  105545. * This class can be used to get instrumentation data from a Babylon engine
  105546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105547. * @param engine Defines the engine to instrument
  105548. */
  105549. constructor(
  105550. /**
  105551. * Define the instrumented engine.
  105552. */
  105553. engine: Engine);
  105554. /**
  105555. * Dispose and release associated resources.
  105556. */
  105557. dispose(): void;
  105558. }
  105559. }
  105560. declare module BABYLON {
  105561. /**
  105562. * This class can be used to get instrumentation data from a Babylon engine
  105563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105564. */
  105565. export class SceneInstrumentation implements IDisposable {
  105566. /**
  105567. * Defines the scene to instrument
  105568. */
  105569. scene: Scene;
  105570. private _captureActiveMeshesEvaluationTime;
  105571. private _activeMeshesEvaluationTime;
  105572. private _captureRenderTargetsRenderTime;
  105573. private _renderTargetsRenderTime;
  105574. private _captureFrameTime;
  105575. private _frameTime;
  105576. private _captureRenderTime;
  105577. private _renderTime;
  105578. private _captureInterFrameTime;
  105579. private _interFrameTime;
  105580. private _captureParticlesRenderTime;
  105581. private _particlesRenderTime;
  105582. private _captureSpritesRenderTime;
  105583. private _spritesRenderTime;
  105584. private _capturePhysicsTime;
  105585. private _physicsTime;
  105586. private _captureAnimationsTime;
  105587. private _animationsTime;
  105588. private _captureCameraRenderTime;
  105589. private _cameraRenderTime;
  105590. private _onBeforeActiveMeshesEvaluationObserver;
  105591. private _onAfterActiveMeshesEvaluationObserver;
  105592. private _onBeforeRenderTargetsRenderObserver;
  105593. private _onAfterRenderTargetsRenderObserver;
  105594. private _onAfterRenderObserver;
  105595. private _onBeforeDrawPhaseObserver;
  105596. private _onAfterDrawPhaseObserver;
  105597. private _onBeforeAnimationsObserver;
  105598. private _onBeforeParticlesRenderingObserver;
  105599. private _onAfterParticlesRenderingObserver;
  105600. private _onBeforeSpritesRenderingObserver;
  105601. private _onAfterSpritesRenderingObserver;
  105602. private _onBeforePhysicsObserver;
  105603. private _onAfterPhysicsObserver;
  105604. private _onAfterAnimationsObserver;
  105605. private _onBeforeCameraRenderObserver;
  105606. private _onAfterCameraRenderObserver;
  105607. /**
  105608. * Gets the perf counter used for active meshes evaluation time
  105609. */
  105610. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105611. /**
  105612. * Gets the active meshes evaluation time capture status
  105613. */
  105614. /**
  105615. * Enable or disable the active meshes evaluation time capture
  105616. */
  105617. captureActiveMeshesEvaluationTime: boolean;
  105618. /**
  105619. * Gets the perf counter used for render targets render time
  105620. */
  105621. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105622. /**
  105623. * Gets the render targets render time capture status
  105624. */
  105625. /**
  105626. * Enable or disable the render targets render time capture
  105627. */
  105628. captureRenderTargetsRenderTime: boolean;
  105629. /**
  105630. * Gets the perf counter used for particles render time
  105631. */
  105632. readonly particlesRenderTimeCounter: PerfCounter;
  105633. /**
  105634. * Gets the particles render time capture status
  105635. */
  105636. /**
  105637. * Enable or disable the particles render time capture
  105638. */
  105639. captureParticlesRenderTime: boolean;
  105640. /**
  105641. * Gets the perf counter used for sprites render time
  105642. */
  105643. readonly spritesRenderTimeCounter: PerfCounter;
  105644. /**
  105645. * Gets the sprites render time capture status
  105646. */
  105647. /**
  105648. * Enable or disable the sprites render time capture
  105649. */
  105650. captureSpritesRenderTime: boolean;
  105651. /**
  105652. * Gets the perf counter used for physics time
  105653. */
  105654. readonly physicsTimeCounter: PerfCounter;
  105655. /**
  105656. * Gets the physics time capture status
  105657. */
  105658. /**
  105659. * Enable or disable the physics time capture
  105660. */
  105661. capturePhysicsTime: boolean;
  105662. /**
  105663. * Gets the perf counter used for animations time
  105664. */
  105665. readonly animationsTimeCounter: PerfCounter;
  105666. /**
  105667. * Gets the animations time capture status
  105668. */
  105669. /**
  105670. * Enable or disable the animations time capture
  105671. */
  105672. captureAnimationsTime: boolean;
  105673. /**
  105674. * Gets the perf counter used for frame time capture
  105675. */
  105676. readonly frameTimeCounter: PerfCounter;
  105677. /**
  105678. * Gets the frame time capture status
  105679. */
  105680. /**
  105681. * Enable or disable the frame time capture
  105682. */
  105683. captureFrameTime: boolean;
  105684. /**
  105685. * Gets the perf counter used for inter-frames time capture
  105686. */
  105687. readonly interFrameTimeCounter: PerfCounter;
  105688. /**
  105689. * Gets the inter-frames time capture status
  105690. */
  105691. /**
  105692. * Enable or disable the inter-frames time capture
  105693. */
  105694. captureInterFrameTime: boolean;
  105695. /**
  105696. * Gets the perf counter used for render time capture
  105697. */
  105698. readonly renderTimeCounter: PerfCounter;
  105699. /**
  105700. * Gets the render time capture status
  105701. */
  105702. /**
  105703. * Enable or disable the render time capture
  105704. */
  105705. captureRenderTime: boolean;
  105706. /**
  105707. * Gets the perf counter used for camera render time capture
  105708. */
  105709. readonly cameraRenderTimeCounter: PerfCounter;
  105710. /**
  105711. * Gets the camera render time capture status
  105712. */
  105713. /**
  105714. * Enable or disable the camera render time capture
  105715. */
  105716. captureCameraRenderTime: boolean;
  105717. /**
  105718. * Gets the perf counter used for draw calls
  105719. */
  105720. readonly drawCallsCounter: PerfCounter;
  105721. /**
  105722. * Gets the perf counter used for texture collisions
  105723. */
  105724. readonly textureCollisionsCounter: PerfCounter;
  105725. /**
  105726. * Instantiates a new scene instrumentation.
  105727. * This class can be used to get instrumentation data from a Babylon engine
  105728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105729. * @param scene Defines the scene to instrument
  105730. */
  105731. constructor(
  105732. /**
  105733. * Defines the scene to instrument
  105734. */
  105735. scene: Scene);
  105736. /**
  105737. * Dispose and release associated resources.
  105738. */
  105739. dispose(): void;
  105740. }
  105741. }
  105742. declare module BABYLON {
  105743. /** @hidden */
  105744. export var glowMapGenerationPixelShader: {
  105745. name: string;
  105746. shader: string;
  105747. };
  105748. }
  105749. declare module BABYLON {
  105750. /** @hidden */
  105751. export var glowMapGenerationVertexShader: {
  105752. name: string;
  105753. shader: string;
  105754. };
  105755. }
  105756. declare module BABYLON {
  105757. /**
  105758. * Effect layer options. This helps customizing the behaviour
  105759. * of the effect layer.
  105760. */
  105761. export interface IEffectLayerOptions {
  105762. /**
  105763. * Multiplication factor apply to the canvas size to compute the render target size
  105764. * used to generated the objects (the smaller the faster).
  105765. */
  105766. mainTextureRatio: number;
  105767. /**
  105768. * Enforces a fixed size texture to ensure effect stability across devices.
  105769. */
  105770. mainTextureFixedSize?: number;
  105771. /**
  105772. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105773. */
  105774. alphaBlendingMode: number;
  105775. /**
  105776. * The camera attached to the layer.
  105777. */
  105778. camera: Nullable<Camera>;
  105779. /**
  105780. * The rendering group to draw the layer in.
  105781. */
  105782. renderingGroupId: number;
  105783. }
  105784. /**
  105785. * The effect layer Helps adding post process effect blended with the main pass.
  105786. *
  105787. * This can be for instance use to generate glow or higlight effects on the scene.
  105788. *
  105789. * The effect layer class can not be used directly and is intented to inherited from to be
  105790. * customized per effects.
  105791. */
  105792. export abstract class EffectLayer {
  105793. private _vertexBuffers;
  105794. private _indexBuffer;
  105795. private _cachedDefines;
  105796. private _effectLayerMapGenerationEffect;
  105797. private _effectLayerOptions;
  105798. private _mergeEffect;
  105799. protected _scene: Scene;
  105800. protected _engine: Engine;
  105801. protected _maxSize: number;
  105802. protected _mainTextureDesiredSize: ISize;
  105803. protected _mainTexture: RenderTargetTexture;
  105804. protected _shouldRender: boolean;
  105805. protected _postProcesses: PostProcess[];
  105806. protected _textures: BaseTexture[];
  105807. protected _emissiveTextureAndColor: {
  105808. texture: Nullable<BaseTexture>;
  105809. color: Color4;
  105810. };
  105811. /**
  105812. * The name of the layer
  105813. */
  105814. name: string;
  105815. /**
  105816. * The clear color of the texture used to generate the glow map.
  105817. */
  105818. neutralColor: Color4;
  105819. /**
  105820. * Specifies wether the highlight layer is enabled or not.
  105821. */
  105822. isEnabled: boolean;
  105823. /**
  105824. * Gets the camera attached to the layer.
  105825. */
  105826. readonly camera: Nullable<Camera>;
  105827. /**
  105828. * Gets the rendering group id the layer should render in.
  105829. */
  105830. readonly renderingGroupId: number;
  105831. /**
  105832. * An event triggered when the effect layer has been disposed.
  105833. */
  105834. onDisposeObservable: Observable<EffectLayer>;
  105835. /**
  105836. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105837. */
  105838. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105839. /**
  105840. * An event triggered when the generated texture is being merged in the scene.
  105841. */
  105842. onBeforeComposeObservable: Observable<EffectLayer>;
  105843. /**
  105844. * An event triggered when the generated texture has been merged in the scene.
  105845. */
  105846. onAfterComposeObservable: Observable<EffectLayer>;
  105847. /**
  105848. * An event triggered when the efffect layer changes its size.
  105849. */
  105850. onSizeChangedObservable: Observable<EffectLayer>;
  105851. /** @hidden */
  105852. static _SceneComponentInitialization: (scene: Scene) => void;
  105853. /**
  105854. * Instantiates a new effect Layer and references it in the scene.
  105855. * @param name The name of the layer
  105856. * @param scene The scene to use the layer in
  105857. */
  105858. constructor(
  105859. /** The Friendly of the effect in the scene */
  105860. name: string, scene: Scene);
  105861. /**
  105862. * Get the effect name of the layer.
  105863. * @return The effect name
  105864. */
  105865. abstract getEffectName(): string;
  105866. /**
  105867. * Checks for the readiness of the element composing the layer.
  105868. * @param subMesh the mesh to check for
  105869. * @param useInstances specify wether or not to use instances to render the mesh
  105870. * @return true if ready otherwise, false
  105871. */
  105872. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105873. /**
  105874. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105875. * @returns true if the effect requires stencil during the main canvas render pass.
  105876. */
  105877. abstract needStencil(): boolean;
  105878. /**
  105879. * Create the merge effect. This is the shader use to blit the information back
  105880. * to the main canvas at the end of the scene rendering.
  105881. * @returns The effect containing the shader used to merge the effect on the main canvas
  105882. */
  105883. protected abstract _createMergeEffect(): Effect;
  105884. /**
  105885. * Creates the render target textures and post processes used in the effect layer.
  105886. */
  105887. protected abstract _createTextureAndPostProcesses(): void;
  105888. /**
  105889. * Implementation specific of rendering the generating effect on the main canvas.
  105890. * @param effect The effect used to render through
  105891. */
  105892. protected abstract _internalRender(effect: Effect): void;
  105893. /**
  105894. * Sets the required values for both the emissive texture and and the main color.
  105895. */
  105896. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105897. /**
  105898. * Free any resources and references associated to a mesh.
  105899. * Internal use
  105900. * @param mesh The mesh to free.
  105901. */
  105902. abstract _disposeMesh(mesh: Mesh): void;
  105903. /**
  105904. * Serializes this layer (Glow or Highlight for example)
  105905. * @returns a serialized layer object
  105906. */
  105907. abstract serialize?(): any;
  105908. /**
  105909. * Initializes the effect layer with the required options.
  105910. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105911. */
  105912. protected _init(options: Partial<IEffectLayerOptions>): void;
  105913. /**
  105914. * Generates the index buffer of the full screen quad blending to the main canvas.
  105915. */
  105916. private _generateIndexBuffer;
  105917. /**
  105918. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105919. */
  105920. private _genrateVertexBuffer;
  105921. /**
  105922. * Sets the main texture desired size which is the closest power of two
  105923. * of the engine canvas size.
  105924. */
  105925. private _setMainTextureSize;
  105926. /**
  105927. * Creates the main texture for the effect layer.
  105928. */
  105929. protected _createMainTexture(): void;
  105930. /**
  105931. * Adds specific effects defines.
  105932. * @param defines The defines to add specifics to.
  105933. */
  105934. protected _addCustomEffectDefines(defines: string[]): void;
  105935. /**
  105936. * Checks for the readiness of the element composing the layer.
  105937. * @param subMesh the mesh to check for
  105938. * @param useInstances specify wether or not to use instances to render the mesh
  105939. * @param emissiveTexture the associated emissive texture used to generate the glow
  105940. * @return true if ready otherwise, false
  105941. */
  105942. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105943. /**
  105944. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105945. */
  105946. render(): void;
  105947. /**
  105948. * Determine if a given mesh will be used in the current effect.
  105949. * @param mesh mesh to test
  105950. * @returns true if the mesh will be used
  105951. */
  105952. hasMesh(mesh: AbstractMesh): boolean;
  105953. /**
  105954. * Returns true if the layer contains information to display, otherwise false.
  105955. * @returns true if the glow layer should be rendered
  105956. */
  105957. shouldRender(): boolean;
  105958. /**
  105959. * Returns true if the mesh should render, otherwise false.
  105960. * @param mesh The mesh to render
  105961. * @returns true if it should render otherwise false
  105962. */
  105963. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105964. /**
  105965. * Returns true if the mesh can be rendered, otherwise false.
  105966. * @param mesh The mesh to render
  105967. * @param material The material used on the mesh
  105968. * @returns true if it can be rendered otherwise false
  105969. */
  105970. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105971. /**
  105972. * Returns true if the mesh should render, otherwise false.
  105973. * @param mesh The mesh to render
  105974. * @returns true if it should render otherwise false
  105975. */
  105976. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105977. /**
  105978. * Renders the submesh passed in parameter to the generation map.
  105979. */
  105980. protected _renderSubMesh(subMesh: SubMesh): void;
  105981. /**
  105982. * Rebuild the required buffers.
  105983. * @hidden Internal use only.
  105984. */
  105985. _rebuild(): void;
  105986. /**
  105987. * Dispose only the render target textures and post process.
  105988. */
  105989. private _disposeTextureAndPostProcesses;
  105990. /**
  105991. * Dispose the highlight layer and free resources.
  105992. */
  105993. dispose(): void;
  105994. /**
  105995. * Gets the class name of the effect layer
  105996. * @returns the string with the class name of the effect layer
  105997. */
  105998. getClassName(): string;
  105999. /**
  106000. * Creates an effect layer from parsed effect layer data
  106001. * @param parsedEffectLayer defines effect layer data
  106002. * @param scene defines the current scene
  106003. * @param rootUrl defines the root URL containing the effect layer information
  106004. * @returns a parsed effect Layer
  106005. */
  106006. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106007. }
  106008. }
  106009. declare module BABYLON {
  106010. interface AbstractScene {
  106011. /**
  106012. * The list of effect layers (highlights/glow) added to the scene
  106013. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106014. * @see http://doc.babylonjs.com/how_to/glow_layer
  106015. */
  106016. effectLayers: Array<EffectLayer>;
  106017. /**
  106018. * Removes the given effect layer from this scene.
  106019. * @param toRemove defines the effect layer to remove
  106020. * @returns the index of the removed effect layer
  106021. */
  106022. removeEffectLayer(toRemove: EffectLayer): number;
  106023. /**
  106024. * Adds the given effect layer to this scene
  106025. * @param newEffectLayer defines the effect layer to add
  106026. */
  106027. addEffectLayer(newEffectLayer: EffectLayer): void;
  106028. }
  106029. /**
  106030. * Defines the layer scene component responsible to manage any effect layers
  106031. * in a given scene.
  106032. */
  106033. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106034. /**
  106035. * The component name helpfull to identify the component in the list of scene components.
  106036. */
  106037. readonly name: string;
  106038. /**
  106039. * The scene the component belongs to.
  106040. */
  106041. scene: Scene;
  106042. private _engine;
  106043. private _renderEffects;
  106044. private _needStencil;
  106045. private _previousStencilState;
  106046. /**
  106047. * Creates a new instance of the component for the given scene
  106048. * @param scene Defines the scene to register the component in
  106049. */
  106050. constructor(scene: Scene);
  106051. /**
  106052. * Registers the component in a given scene
  106053. */
  106054. register(): void;
  106055. /**
  106056. * Rebuilds the elements related to this component in case of
  106057. * context lost for instance.
  106058. */
  106059. rebuild(): void;
  106060. /**
  106061. * Serializes the component data to the specified json object
  106062. * @param serializationObject The object to serialize to
  106063. */
  106064. serialize(serializationObject: any): void;
  106065. /**
  106066. * Adds all the element from the container to the scene
  106067. * @param container the container holding the elements
  106068. */
  106069. addFromContainer(container: AbstractScene): void;
  106070. /**
  106071. * Removes all the elements in the container from the scene
  106072. * @param container contains the elements to remove
  106073. * @param dispose if the removed element should be disposed (default: false)
  106074. */
  106075. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106076. /**
  106077. * Disposes the component and the associated ressources.
  106078. */
  106079. dispose(): void;
  106080. private _isReadyForMesh;
  106081. private _renderMainTexture;
  106082. private _setStencil;
  106083. private _setStencilBack;
  106084. private _draw;
  106085. private _drawCamera;
  106086. private _drawRenderingGroup;
  106087. }
  106088. }
  106089. declare module BABYLON {
  106090. /** @hidden */
  106091. export var glowMapMergePixelShader: {
  106092. name: string;
  106093. shader: string;
  106094. };
  106095. }
  106096. declare module BABYLON {
  106097. /** @hidden */
  106098. export var glowMapMergeVertexShader: {
  106099. name: string;
  106100. shader: string;
  106101. };
  106102. }
  106103. declare module BABYLON {
  106104. interface AbstractScene {
  106105. /**
  106106. * Return a the first highlight layer of the scene with a given name.
  106107. * @param name The name of the highlight layer to look for.
  106108. * @return The highlight layer if found otherwise null.
  106109. */
  106110. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106111. }
  106112. /**
  106113. * Glow layer options. This helps customizing the behaviour
  106114. * of the glow layer.
  106115. */
  106116. export interface IGlowLayerOptions {
  106117. /**
  106118. * Multiplication factor apply to the canvas size to compute the render target size
  106119. * used to generated the glowing objects (the smaller the faster).
  106120. */
  106121. mainTextureRatio: number;
  106122. /**
  106123. * Enforces a fixed size texture to ensure resize independant blur.
  106124. */
  106125. mainTextureFixedSize?: number;
  106126. /**
  106127. * How big is the kernel of the blur texture.
  106128. */
  106129. blurKernelSize: number;
  106130. /**
  106131. * The camera attached to the layer.
  106132. */
  106133. camera: Nullable<Camera>;
  106134. /**
  106135. * Enable MSAA by chosing the number of samples.
  106136. */
  106137. mainTextureSamples?: number;
  106138. /**
  106139. * The rendering group to draw the layer in.
  106140. */
  106141. renderingGroupId: number;
  106142. }
  106143. /**
  106144. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106145. *
  106146. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106147. * glowy meshes to your scene.
  106148. *
  106149. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106150. */
  106151. export class GlowLayer extends EffectLayer {
  106152. /**
  106153. * Effect Name of the layer.
  106154. */
  106155. static readonly EffectName: string;
  106156. /**
  106157. * The default blur kernel size used for the glow.
  106158. */
  106159. static DefaultBlurKernelSize: number;
  106160. /**
  106161. * The default texture size ratio used for the glow.
  106162. */
  106163. static DefaultTextureRatio: number;
  106164. /**
  106165. * Sets the kernel size of the blur.
  106166. */
  106167. /**
  106168. * Gets the kernel size of the blur.
  106169. */
  106170. blurKernelSize: number;
  106171. /**
  106172. * Sets the glow intensity.
  106173. */
  106174. /**
  106175. * Gets the glow intensity.
  106176. */
  106177. intensity: number;
  106178. private _options;
  106179. private _intensity;
  106180. private _horizontalBlurPostprocess1;
  106181. private _verticalBlurPostprocess1;
  106182. private _horizontalBlurPostprocess2;
  106183. private _verticalBlurPostprocess2;
  106184. private _blurTexture1;
  106185. private _blurTexture2;
  106186. private _postProcesses1;
  106187. private _postProcesses2;
  106188. private _includedOnlyMeshes;
  106189. private _excludedMeshes;
  106190. /**
  106191. * Callback used to let the user override the color selection on a per mesh basis
  106192. */
  106193. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106194. /**
  106195. * Callback used to let the user override the texture selection on a per mesh basis
  106196. */
  106197. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106198. /**
  106199. * Instantiates a new glow Layer and references it to the scene.
  106200. * @param name The name of the layer
  106201. * @param scene The scene to use the layer in
  106202. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106203. */
  106204. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106205. /**
  106206. * Get the effect name of the layer.
  106207. * @return The effect name
  106208. */
  106209. getEffectName(): string;
  106210. /**
  106211. * Create the merge effect. This is the shader use to blit the information back
  106212. * to the main canvas at the end of the scene rendering.
  106213. */
  106214. protected _createMergeEffect(): Effect;
  106215. /**
  106216. * Creates the render target textures and post processes used in the glow layer.
  106217. */
  106218. protected _createTextureAndPostProcesses(): void;
  106219. /**
  106220. * Checks for the readiness of the element composing the layer.
  106221. * @param subMesh the mesh to check for
  106222. * @param useInstances specify wether or not to use instances to render the mesh
  106223. * @param emissiveTexture the associated emissive texture used to generate the glow
  106224. * @return true if ready otherwise, false
  106225. */
  106226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106227. /**
  106228. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106229. */
  106230. needStencil(): boolean;
  106231. /**
  106232. * Returns true if the mesh can be rendered, otherwise false.
  106233. * @param mesh The mesh to render
  106234. * @param material The material used on the mesh
  106235. * @returns true if it can be rendered otherwise false
  106236. */
  106237. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106238. /**
  106239. * Implementation specific of rendering the generating effect on the main canvas.
  106240. * @param effect The effect used to render through
  106241. */
  106242. protected _internalRender(effect: Effect): void;
  106243. /**
  106244. * Sets the required values for both the emissive texture and and the main color.
  106245. */
  106246. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106247. /**
  106248. * Returns true if the mesh should render, otherwise false.
  106249. * @param mesh The mesh to render
  106250. * @returns true if it should render otherwise false
  106251. */
  106252. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106253. /**
  106254. * Adds specific effects defines.
  106255. * @param defines The defines to add specifics to.
  106256. */
  106257. protected _addCustomEffectDefines(defines: string[]): void;
  106258. /**
  106259. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106260. * @param mesh The mesh to exclude from the glow layer
  106261. */
  106262. addExcludedMesh(mesh: Mesh): void;
  106263. /**
  106264. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106265. * @param mesh The mesh to remove
  106266. */
  106267. removeExcludedMesh(mesh: Mesh): void;
  106268. /**
  106269. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106270. * @param mesh The mesh to include in the glow layer
  106271. */
  106272. addIncludedOnlyMesh(mesh: Mesh): void;
  106273. /**
  106274. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106275. * @param mesh The mesh to remove
  106276. */
  106277. removeIncludedOnlyMesh(mesh: Mesh): void;
  106278. /**
  106279. * Determine if a given mesh will be used in the glow layer
  106280. * @param mesh The mesh to test
  106281. * @returns true if the mesh will be highlighted by the current glow layer
  106282. */
  106283. hasMesh(mesh: AbstractMesh): boolean;
  106284. /**
  106285. * Free any resources and references associated to a mesh.
  106286. * Internal use
  106287. * @param mesh The mesh to free.
  106288. * @hidden
  106289. */
  106290. _disposeMesh(mesh: Mesh): void;
  106291. /**
  106292. * Gets the class name of the effect layer
  106293. * @returns the string with the class name of the effect layer
  106294. */
  106295. getClassName(): string;
  106296. /**
  106297. * Serializes this glow layer
  106298. * @returns a serialized glow layer object
  106299. */
  106300. serialize(): any;
  106301. /**
  106302. * Creates a Glow Layer from parsed glow layer data
  106303. * @param parsedGlowLayer defines glow layer data
  106304. * @param scene defines the current scene
  106305. * @param rootUrl defines the root URL containing the glow layer information
  106306. * @returns a parsed Glow Layer
  106307. */
  106308. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106309. }
  106310. }
  106311. declare module BABYLON {
  106312. /** @hidden */
  106313. export var glowBlurPostProcessPixelShader: {
  106314. name: string;
  106315. shader: string;
  106316. };
  106317. }
  106318. declare module BABYLON {
  106319. interface AbstractScene {
  106320. /**
  106321. * Return a the first highlight layer of the scene with a given name.
  106322. * @param name The name of the highlight layer to look for.
  106323. * @return The highlight layer if found otherwise null.
  106324. */
  106325. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106326. }
  106327. /**
  106328. * Highlight layer options. This helps customizing the behaviour
  106329. * of the highlight layer.
  106330. */
  106331. export interface IHighlightLayerOptions {
  106332. /**
  106333. * Multiplication factor apply to the canvas size to compute the render target size
  106334. * used to generated the glowing objects (the smaller the faster).
  106335. */
  106336. mainTextureRatio: number;
  106337. /**
  106338. * Enforces a fixed size texture to ensure resize independant blur.
  106339. */
  106340. mainTextureFixedSize?: number;
  106341. /**
  106342. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106343. * of the picture to blur (the smaller the faster).
  106344. */
  106345. blurTextureSizeRatio: number;
  106346. /**
  106347. * How big in texel of the blur texture is the vertical blur.
  106348. */
  106349. blurVerticalSize: number;
  106350. /**
  106351. * How big in texel of the blur texture is the horizontal blur.
  106352. */
  106353. blurHorizontalSize: number;
  106354. /**
  106355. * Alpha blending mode used to apply the blur. Default is combine.
  106356. */
  106357. alphaBlendingMode: number;
  106358. /**
  106359. * The camera attached to the layer.
  106360. */
  106361. camera: Nullable<Camera>;
  106362. /**
  106363. * Should we display highlight as a solid stroke?
  106364. */
  106365. isStroke?: boolean;
  106366. /**
  106367. * The rendering group to draw the layer in.
  106368. */
  106369. renderingGroupId: number;
  106370. }
  106371. /**
  106372. * The highlight layer Helps adding a glow effect around a mesh.
  106373. *
  106374. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106375. * glowy meshes to your scene.
  106376. *
  106377. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106378. */
  106379. export class HighlightLayer extends EffectLayer {
  106380. name: string;
  106381. /**
  106382. * Effect Name of the highlight layer.
  106383. */
  106384. static readonly EffectName: string;
  106385. /**
  106386. * The neutral color used during the preparation of the glow effect.
  106387. * This is black by default as the blend operation is a blend operation.
  106388. */
  106389. static NeutralColor: Color4;
  106390. /**
  106391. * Stencil value used for glowing meshes.
  106392. */
  106393. static GlowingMeshStencilReference: number;
  106394. /**
  106395. * Stencil value used for the other meshes in the scene.
  106396. */
  106397. static NormalMeshStencilReference: number;
  106398. /**
  106399. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106400. */
  106401. innerGlow: boolean;
  106402. /**
  106403. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106404. */
  106405. outerGlow: boolean;
  106406. /**
  106407. * Specifies the horizontal size of the blur.
  106408. */
  106409. /**
  106410. * Gets the horizontal size of the blur.
  106411. */
  106412. blurHorizontalSize: number;
  106413. /**
  106414. * Specifies the vertical size of the blur.
  106415. */
  106416. /**
  106417. * Gets the vertical size of the blur.
  106418. */
  106419. blurVerticalSize: number;
  106420. /**
  106421. * An event triggered when the highlight layer is being blurred.
  106422. */
  106423. onBeforeBlurObservable: Observable<HighlightLayer>;
  106424. /**
  106425. * An event triggered when the highlight layer has been blurred.
  106426. */
  106427. onAfterBlurObservable: Observable<HighlightLayer>;
  106428. private _instanceGlowingMeshStencilReference;
  106429. private _options;
  106430. private _downSamplePostprocess;
  106431. private _horizontalBlurPostprocess;
  106432. private _verticalBlurPostprocess;
  106433. private _blurTexture;
  106434. private _meshes;
  106435. private _excludedMeshes;
  106436. /**
  106437. * Instantiates a new highlight Layer and references it to the scene..
  106438. * @param name The name of the layer
  106439. * @param scene The scene to use the layer in
  106440. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106441. */
  106442. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106443. /**
  106444. * Get the effect name of the layer.
  106445. * @return The effect name
  106446. */
  106447. getEffectName(): string;
  106448. /**
  106449. * Create the merge effect. This is the shader use to blit the information back
  106450. * to the main canvas at the end of the scene rendering.
  106451. */
  106452. protected _createMergeEffect(): Effect;
  106453. /**
  106454. * Creates the render target textures and post processes used in the highlight layer.
  106455. */
  106456. protected _createTextureAndPostProcesses(): void;
  106457. /**
  106458. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106459. */
  106460. needStencil(): boolean;
  106461. /**
  106462. * Checks for the readiness of the element composing the layer.
  106463. * @param subMesh the mesh to check for
  106464. * @param useInstances specify wether or not to use instances to render the mesh
  106465. * @param emissiveTexture the associated emissive texture used to generate the glow
  106466. * @return true if ready otherwise, false
  106467. */
  106468. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106469. /**
  106470. * Implementation specific of rendering the generating effect on the main canvas.
  106471. * @param effect The effect used to render through
  106472. */
  106473. protected _internalRender(effect: Effect): void;
  106474. /**
  106475. * Returns true if the layer contains information to display, otherwise false.
  106476. */
  106477. shouldRender(): boolean;
  106478. /**
  106479. * Returns true if the mesh should render, otherwise false.
  106480. * @param mesh The mesh to render
  106481. * @returns true if it should render otherwise false
  106482. */
  106483. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106484. /**
  106485. * Sets the required values for both the emissive texture and and the main color.
  106486. */
  106487. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106488. /**
  106489. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106490. * @param mesh The mesh to exclude from the highlight layer
  106491. */
  106492. addExcludedMesh(mesh: Mesh): void;
  106493. /**
  106494. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106495. * @param mesh The mesh to highlight
  106496. */
  106497. removeExcludedMesh(mesh: Mesh): void;
  106498. /**
  106499. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106500. * @param mesh mesh to test
  106501. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106502. */
  106503. hasMesh(mesh: AbstractMesh): boolean;
  106504. /**
  106505. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106506. * @param mesh The mesh to highlight
  106507. * @param color The color of the highlight
  106508. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106509. */
  106510. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106511. /**
  106512. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106513. * @param mesh The mesh to highlight
  106514. */
  106515. removeMesh(mesh: Mesh): void;
  106516. /**
  106517. * Force the stencil to the normal expected value for none glowing parts
  106518. */
  106519. private _defaultStencilReference;
  106520. /**
  106521. * Free any resources and references associated to a mesh.
  106522. * Internal use
  106523. * @param mesh The mesh to free.
  106524. * @hidden
  106525. */
  106526. _disposeMesh(mesh: Mesh): void;
  106527. /**
  106528. * Dispose the highlight layer and free resources.
  106529. */
  106530. dispose(): void;
  106531. /**
  106532. * Gets the class name of the effect layer
  106533. * @returns the string with the class name of the effect layer
  106534. */
  106535. getClassName(): string;
  106536. /**
  106537. * Serializes this Highlight layer
  106538. * @returns a serialized Highlight layer object
  106539. */
  106540. serialize(): any;
  106541. /**
  106542. * Creates a Highlight layer from parsed Highlight layer data
  106543. * @param parsedHightlightLayer defines the Highlight layer data
  106544. * @param scene defines the current scene
  106545. * @param rootUrl defines the root URL containing the Highlight layer information
  106546. * @returns a parsed Highlight layer
  106547. */
  106548. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106549. }
  106550. }
  106551. declare module BABYLON {
  106552. /** @hidden */
  106553. export var lensFlarePixelShader: {
  106554. name: string;
  106555. shader: string;
  106556. };
  106557. }
  106558. declare module BABYLON {
  106559. /** @hidden */
  106560. export var lensFlareVertexShader: {
  106561. name: string;
  106562. shader: string;
  106563. };
  106564. }
  106565. declare module BABYLON {
  106566. /**
  106567. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106568. * It is usually composed of several `lensFlare`.
  106569. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106570. */
  106571. export class LensFlareSystem {
  106572. /**
  106573. * Define the name of the lens flare system
  106574. */
  106575. name: string;
  106576. /**
  106577. * List of lens flares used in this system.
  106578. */
  106579. lensFlares: LensFlare[];
  106580. /**
  106581. * Define a limit from the border the lens flare can be visible.
  106582. */
  106583. borderLimit: number;
  106584. /**
  106585. * Define a viewport border we do not want to see the lens flare in.
  106586. */
  106587. viewportBorder: number;
  106588. /**
  106589. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106590. */
  106591. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106592. /**
  106593. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106594. */
  106595. layerMask: number;
  106596. /**
  106597. * Define the id of the lens flare system in the scene.
  106598. * (equal to name by default)
  106599. */
  106600. id: string;
  106601. private _scene;
  106602. private _emitter;
  106603. private _vertexBuffers;
  106604. private _indexBuffer;
  106605. private _effect;
  106606. private _positionX;
  106607. private _positionY;
  106608. private _isEnabled;
  106609. /** @hidden */
  106610. static _SceneComponentInitialization: (scene: Scene) => void;
  106611. /**
  106612. * Instantiates a lens flare system.
  106613. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106614. * It is usually composed of several `lensFlare`.
  106615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106616. * @param name Define the name of the lens flare system in the scene
  106617. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106618. * @param scene Define the scene the lens flare system belongs to
  106619. */
  106620. constructor(
  106621. /**
  106622. * Define the name of the lens flare system
  106623. */
  106624. name: string, emitter: any, scene: Scene);
  106625. /**
  106626. * Define if the lens flare system is enabled.
  106627. */
  106628. isEnabled: boolean;
  106629. /**
  106630. * Get the scene the effects belongs to.
  106631. * @returns the scene holding the lens flare system
  106632. */
  106633. getScene(): Scene;
  106634. /**
  106635. * Get the emitter of the lens flare system.
  106636. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106637. * @returns the emitter of the lens flare system
  106638. */
  106639. getEmitter(): any;
  106640. /**
  106641. * Set the emitter of the lens flare system.
  106642. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106643. * @param newEmitter Define the new emitter of the system
  106644. */
  106645. setEmitter(newEmitter: any): void;
  106646. /**
  106647. * Get the lens flare system emitter position.
  106648. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106649. * @returns the position
  106650. */
  106651. getEmitterPosition(): Vector3;
  106652. /**
  106653. * @hidden
  106654. */
  106655. computeEffectivePosition(globalViewport: Viewport): boolean;
  106656. /** @hidden */
  106657. _isVisible(): boolean;
  106658. /**
  106659. * @hidden
  106660. */
  106661. render(): boolean;
  106662. /**
  106663. * Dispose and release the lens flare with its associated resources.
  106664. */
  106665. dispose(): void;
  106666. /**
  106667. * Parse a lens flare system from a JSON repressentation
  106668. * @param parsedLensFlareSystem Define the JSON to parse
  106669. * @param scene Define the scene the parsed system should be instantiated in
  106670. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106671. * @returns the parsed system
  106672. */
  106673. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106674. /**
  106675. * Serialize the current Lens Flare System into a JSON representation.
  106676. * @returns the serialized JSON
  106677. */
  106678. serialize(): any;
  106679. }
  106680. }
  106681. declare module BABYLON {
  106682. /**
  106683. * This represents one of the lens effect in a `lensFlareSystem`.
  106684. * It controls one of the indiviual texture used in the effect.
  106685. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106686. */
  106687. export class LensFlare {
  106688. /**
  106689. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106690. */
  106691. size: number;
  106692. /**
  106693. * 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.
  106694. */
  106695. position: number;
  106696. /**
  106697. * Define the lens color.
  106698. */
  106699. color: Color3;
  106700. /**
  106701. * Define the lens texture.
  106702. */
  106703. texture: Nullable<Texture>;
  106704. /**
  106705. * Define the alpha mode to render this particular lens.
  106706. */
  106707. alphaMode: number;
  106708. private _system;
  106709. /**
  106710. * Creates a new Lens Flare.
  106711. * This represents one of the lens effect in a `lensFlareSystem`.
  106712. * It controls one of the indiviual texture used in the effect.
  106713. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106714. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106715. * @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.
  106716. * @param color Define the lens color
  106717. * @param imgUrl Define the lens texture url
  106718. * @param system Define the `lensFlareSystem` this flare is part of
  106719. * @returns The newly created Lens Flare
  106720. */
  106721. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106722. /**
  106723. * Instantiates a new Lens Flare.
  106724. * This represents one of the lens effect in a `lensFlareSystem`.
  106725. * It controls one of the indiviual texture used in the effect.
  106726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106727. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106728. * @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.
  106729. * @param color Define the lens color
  106730. * @param imgUrl Define the lens texture url
  106731. * @param system Define the `lensFlareSystem` this flare is part of
  106732. */
  106733. constructor(
  106734. /**
  106735. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106736. */
  106737. size: number,
  106738. /**
  106739. * 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.
  106740. */
  106741. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106742. /**
  106743. * Dispose and release the lens flare with its associated resources.
  106744. */
  106745. dispose(): void;
  106746. }
  106747. }
  106748. declare module BABYLON {
  106749. interface AbstractScene {
  106750. /**
  106751. * The list of lens flare system added to the scene
  106752. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106753. */
  106754. lensFlareSystems: Array<LensFlareSystem>;
  106755. /**
  106756. * Removes the given lens flare system from this scene.
  106757. * @param toRemove The lens flare system to remove
  106758. * @returns The index of the removed lens flare system
  106759. */
  106760. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106761. /**
  106762. * Adds the given lens flare system to this scene
  106763. * @param newLensFlareSystem The lens flare system to add
  106764. */
  106765. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106766. /**
  106767. * Gets a lens flare system using its name
  106768. * @param name defines the name to look for
  106769. * @returns the lens flare system or null if not found
  106770. */
  106771. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106772. /**
  106773. * Gets a lens flare system using its id
  106774. * @param id defines the id to look for
  106775. * @returns the lens flare system or null if not found
  106776. */
  106777. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106778. }
  106779. /**
  106780. * Defines the lens flare scene component responsible to manage any lens flares
  106781. * in a given scene.
  106782. */
  106783. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106784. /**
  106785. * The component name helpfull to identify the component in the list of scene components.
  106786. */
  106787. readonly name: string;
  106788. /**
  106789. * The scene the component belongs to.
  106790. */
  106791. scene: Scene;
  106792. /**
  106793. * Creates a new instance of the component for the given scene
  106794. * @param scene Defines the scene to register the component in
  106795. */
  106796. constructor(scene: Scene);
  106797. /**
  106798. * Registers the component in a given scene
  106799. */
  106800. register(): void;
  106801. /**
  106802. * Rebuilds the elements related to this component in case of
  106803. * context lost for instance.
  106804. */
  106805. rebuild(): void;
  106806. /**
  106807. * Adds all the element from the container to the scene
  106808. * @param container the container holding the elements
  106809. */
  106810. addFromContainer(container: AbstractScene): void;
  106811. /**
  106812. * Removes all the elements in the container from the scene
  106813. * @param container contains the elements to remove
  106814. * @param dispose if the removed element should be disposed (default: false)
  106815. */
  106816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106817. /**
  106818. * Serializes the component data to the specified json object
  106819. * @param serializationObject The object to serialize to
  106820. */
  106821. serialize(serializationObject: any): void;
  106822. /**
  106823. * Disposes the component and the associated ressources.
  106824. */
  106825. dispose(): void;
  106826. private _draw;
  106827. }
  106828. }
  106829. declare module BABYLON {
  106830. /**
  106831. * Defines the shadow generator component responsible to manage any shadow generators
  106832. * in a given scene.
  106833. */
  106834. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106835. /**
  106836. * The component name helpfull to identify the component in the list of scene components.
  106837. */
  106838. readonly name: string;
  106839. /**
  106840. * The scene the component belongs to.
  106841. */
  106842. scene: Scene;
  106843. /**
  106844. * Creates a new instance of the component for the given scene
  106845. * @param scene Defines the scene to register the component in
  106846. */
  106847. constructor(scene: Scene);
  106848. /**
  106849. * Registers the component in a given scene
  106850. */
  106851. register(): void;
  106852. /**
  106853. * Rebuilds the elements related to this component in case of
  106854. * context lost for instance.
  106855. */
  106856. rebuild(): void;
  106857. /**
  106858. * Serializes the component data to the specified json object
  106859. * @param serializationObject The object to serialize to
  106860. */
  106861. serialize(serializationObject: any): void;
  106862. /**
  106863. * Adds all the element from the container to the scene
  106864. * @param container the container holding the elements
  106865. */
  106866. addFromContainer(container: AbstractScene): void;
  106867. /**
  106868. * Removes all the elements in the container from the scene
  106869. * @param container contains the elements to remove
  106870. * @param dispose if the removed element should be disposed (default: false)
  106871. */
  106872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106873. /**
  106874. * Rebuilds the elements related to this component in case of
  106875. * context lost for instance.
  106876. */
  106877. dispose(): void;
  106878. private _gatherRenderTargets;
  106879. }
  106880. }
  106881. declare module BABYLON {
  106882. /**
  106883. * A point light is a light defined by an unique point in world space.
  106884. * The light is emitted in every direction from this point.
  106885. * A good example of a point light is a standard light bulb.
  106886. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106887. */
  106888. export class PointLight extends ShadowLight {
  106889. private _shadowAngle;
  106890. /**
  106891. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106892. * This specifies what angle the shadow will use to be created.
  106893. *
  106894. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106895. */
  106896. /**
  106897. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106898. * This specifies what angle the shadow will use to be created.
  106899. *
  106900. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106901. */
  106902. shadowAngle: number;
  106903. /**
  106904. * Gets the direction if it has been set.
  106905. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106906. */
  106907. /**
  106908. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106909. */
  106910. direction: Vector3;
  106911. /**
  106912. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106913. * A PointLight emits the light in every direction.
  106914. * It can cast shadows.
  106915. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106916. * ```javascript
  106917. * var pointLight = new PointLight("pl", camera.position, scene);
  106918. * ```
  106919. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106920. * @param name The light friendly name
  106921. * @param position The position of the point light in the scene
  106922. * @param scene The scene the lights belongs to
  106923. */
  106924. constructor(name: string, position: Vector3, scene: Scene);
  106925. /**
  106926. * Returns the string "PointLight"
  106927. * @returns the class name
  106928. */
  106929. getClassName(): string;
  106930. /**
  106931. * Returns the integer 0.
  106932. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106933. */
  106934. getTypeID(): number;
  106935. /**
  106936. * Specifies wether or not the shadowmap should be a cube texture.
  106937. * @returns true if the shadowmap needs to be a cube texture.
  106938. */
  106939. needCube(): boolean;
  106940. /**
  106941. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106942. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106943. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106944. */
  106945. getShadowDirection(faceIndex?: number): Vector3;
  106946. /**
  106947. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106948. * - fov = PI / 2
  106949. * - aspect ratio : 1.0
  106950. * - z-near and far equal to the active camera minZ and maxZ.
  106951. * Returns the PointLight.
  106952. */
  106953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106954. protected _buildUniformLayout(): void;
  106955. /**
  106956. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106957. * @param effect The effect to update
  106958. * @param lightIndex The index of the light in the effect to update
  106959. * @returns The point light
  106960. */
  106961. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106962. /**
  106963. * Prepares the list of defines specific to the light type.
  106964. * @param defines the list of defines
  106965. * @param lightIndex defines the index of the light for the effect
  106966. */
  106967. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106968. }
  106969. }
  106970. declare module BABYLON {
  106971. /**
  106972. * Header information of HDR texture files.
  106973. */
  106974. export interface HDRInfo {
  106975. /**
  106976. * The height of the texture in pixels.
  106977. */
  106978. height: number;
  106979. /**
  106980. * The width of the texture in pixels.
  106981. */
  106982. width: number;
  106983. /**
  106984. * The index of the beginning of the data in the binary file.
  106985. */
  106986. dataPosition: number;
  106987. }
  106988. /**
  106989. * This groups tools to convert HDR texture to native colors array.
  106990. */
  106991. export class HDRTools {
  106992. private static Ldexp;
  106993. private static Rgbe2float;
  106994. private static readStringLine;
  106995. /**
  106996. * Reads header information from an RGBE texture stored in a native array.
  106997. * More information on this format are available here:
  106998. * https://en.wikipedia.org/wiki/RGBE_image_format
  106999. *
  107000. * @param uint8array The binary file stored in native array.
  107001. * @return The header information.
  107002. */
  107003. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107004. /**
  107005. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107006. * This RGBE texture needs to store the information as a panorama.
  107007. *
  107008. * More information on this format are available here:
  107009. * https://en.wikipedia.org/wiki/RGBE_image_format
  107010. *
  107011. * @param buffer The binary file stored in an array buffer.
  107012. * @param size The expected size of the extracted cubemap.
  107013. * @return The Cube Map information.
  107014. */
  107015. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107016. /**
  107017. * Returns the pixels data extracted from an RGBE texture.
  107018. * This pixels will be stored left to right up to down in the R G B order in one array.
  107019. *
  107020. * More information on this format are available here:
  107021. * https://en.wikipedia.org/wiki/RGBE_image_format
  107022. *
  107023. * @param uint8array The binary file stored in an array buffer.
  107024. * @param hdrInfo The header information of the file.
  107025. * @return The pixels data in RGB right to left up to down order.
  107026. */
  107027. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107028. private static RGBE_ReadPixels_RLE;
  107029. }
  107030. }
  107031. declare module BABYLON {
  107032. /**
  107033. * This represents a texture coming from an HDR input.
  107034. *
  107035. * The only supported format is currently panorama picture stored in RGBE format.
  107036. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107037. */
  107038. export class HDRCubeTexture extends BaseTexture {
  107039. private static _facesMapping;
  107040. private _generateHarmonics;
  107041. private _noMipmap;
  107042. private _textureMatrix;
  107043. private _size;
  107044. private _onLoad;
  107045. private _onError;
  107046. /**
  107047. * The texture URL.
  107048. */
  107049. url: string;
  107050. /**
  107051. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107052. */
  107053. coordinatesMode: number;
  107054. protected _isBlocking: boolean;
  107055. /**
  107056. * Sets wether or not the texture is blocking during loading.
  107057. */
  107058. /**
  107059. * Gets wether or not the texture is blocking during loading.
  107060. */
  107061. isBlocking: boolean;
  107062. protected _rotationY: number;
  107063. /**
  107064. * Sets texture matrix rotation angle around Y axis in radians.
  107065. */
  107066. /**
  107067. * Gets texture matrix rotation angle around Y axis radians.
  107068. */
  107069. rotationY: number;
  107070. /**
  107071. * Gets or sets the center of the bounding box associated with the cube texture
  107072. * It must define where the camera used to render the texture was set
  107073. */
  107074. boundingBoxPosition: Vector3;
  107075. private _boundingBoxSize;
  107076. /**
  107077. * Gets or sets the size of the bounding box associated with the cube texture
  107078. * When defined, the cubemap will switch to local mode
  107079. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107080. * @example https://www.babylonjs-playground.com/#RNASML
  107081. */
  107082. boundingBoxSize: Vector3;
  107083. /**
  107084. * Instantiates an HDRTexture from the following parameters.
  107085. *
  107086. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107087. * @param scene The scene the texture will be used in
  107088. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107089. * @param noMipmap Forces to not generate the mipmap if true
  107090. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107091. * @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)
  107092. * @param reserved Reserved flag for internal use.
  107093. */
  107094. 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>);
  107095. /**
  107096. * Get the current class name of the texture useful for serialization or dynamic coding.
  107097. * @returns "HDRCubeTexture"
  107098. */
  107099. getClassName(): string;
  107100. /**
  107101. * Occurs when the file is raw .hdr file.
  107102. */
  107103. private loadTexture;
  107104. clone(): HDRCubeTexture;
  107105. delayLoad(): void;
  107106. /**
  107107. * Get the texture reflection matrix used to rotate/transform the reflection.
  107108. * @returns the reflection matrix
  107109. */
  107110. getReflectionTextureMatrix(): Matrix;
  107111. /**
  107112. * Set the texture reflection matrix used to rotate/transform the reflection.
  107113. * @param value Define the reflection matrix to set
  107114. */
  107115. setReflectionTextureMatrix(value: Matrix): void;
  107116. /**
  107117. * Parses a JSON representation of an HDR Texture in order to create the texture
  107118. * @param parsedTexture Define the JSON representation
  107119. * @param scene Define the scene the texture should be created in
  107120. * @param rootUrl Define the root url in case we need to load relative dependencies
  107121. * @returns the newly created texture after parsing
  107122. */
  107123. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107124. serialize(): any;
  107125. }
  107126. }
  107127. declare module BABYLON {
  107128. /**
  107129. * Class used to control physics engine
  107130. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107131. */
  107132. export class PhysicsEngine implements IPhysicsEngine {
  107133. private _physicsPlugin;
  107134. /**
  107135. * Global value used to control the smallest number supported by the simulation
  107136. */
  107137. static Epsilon: number;
  107138. private _impostors;
  107139. private _joints;
  107140. /**
  107141. * Gets the gravity vector used by the simulation
  107142. */
  107143. gravity: Vector3;
  107144. /**
  107145. * Factory used to create the default physics plugin.
  107146. * @returns The default physics plugin
  107147. */
  107148. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107149. /**
  107150. * Creates a new Physics Engine
  107151. * @param gravity defines the gravity vector used by the simulation
  107152. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107153. */
  107154. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107155. /**
  107156. * Sets the gravity vector used by the simulation
  107157. * @param gravity defines the gravity vector to use
  107158. */
  107159. setGravity(gravity: Vector3): void;
  107160. /**
  107161. * Set the time step of the physics engine.
  107162. * Default is 1/60.
  107163. * To slow it down, enter 1/600 for example.
  107164. * To speed it up, 1/30
  107165. * @param newTimeStep defines the new timestep to apply to this world.
  107166. */
  107167. setTimeStep(newTimeStep?: number): void;
  107168. /**
  107169. * Get the time step of the physics engine.
  107170. * @returns the current time step
  107171. */
  107172. getTimeStep(): number;
  107173. /**
  107174. * Release all resources
  107175. */
  107176. dispose(): void;
  107177. /**
  107178. * Gets the name of the current physics plugin
  107179. * @returns the name of the plugin
  107180. */
  107181. getPhysicsPluginName(): string;
  107182. /**
  107183. * Adding a new impostor for the impostor tracking.
  107184. * This will be done by the impostor itself.
  107185. * @param impostor the impostor to add
  107186. */
  107187. addImpostor(impostor: PhysicsImpostor): void;
  107188. /**
  107189. * Remove an impostor from the engine.
  107190. * This impostor and its mesh will not longer be updated by the physics engine.
  107191. * @param impostor the impostor to remove
  107192. */
  107193. removeImpostor(impostor: PhysicsImpostor): void;
  107194. /**
  107195. * Add a joint to the physics engine
  107196. * @param mainImpostor defines the main impostor to which the joint is added.
  107197. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107198. * @param joint defines the joint that will connect both impostors.
  107199. */
  107200. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107201. /**
  107202. * Removes a joint from the simulation
  107203. * @param mainImpostor defines the impostor used with the joint
  107204. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107205. * @param joint defines the joint to remove
  107206. */
  107207. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107208. /**
  107209. * Called by the scene. No need to call it.
  107210. * @param delta defines the timespam between frames
  107211. */
  107212. _step(delta: number): void;
  107213. /**
  107214. * Gets the current plugin used to run the simulation
  107215. * @returns current plugin
  107216. */
  107217. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107218. /**
  107219. * Gets the list of physic impostors
  107220. * @returns an array of PhysicsImpostor
  107221. */
  107222. getImpostors(): Array<PhysicsImpostor>;
  107223. /**
  107224. * Gets the impostor for a physics enabled object
  107225. * @param object defines the object impersonated by the impostor
  107226. * @returns the PhysicsImpostor or null if not found
  107227. */
  107228. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107229. /**
  107230. * Gets the impostor for a physics body object
  107231. * @param body defines physics body used by the impostor
  107232. * @returns the PhysicsImpostor or null if not found
  107233. */
  107234. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107235. /**
  107236. * Does a raycast in the physics world
  107237. * @param from when should the ray start?
  107238. * @param to when should the ray end?
  107239. * @returns PhysicsRaycastResult
  107240. */
  107241. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107242. }
  107243. }
  107244. declare module BABYLON {
  107245. /** @hidden */
  107246. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107247. private _useDeltaForWorldStep;
  107248. world: any;
  107249. name: string;
  107250. private _physicsMaterials;
  107251. private _fixedTimeStep;
  107252. private _cannonRaycastResult;
  107253. private _raycastResult;
  107254. private _removeAfterStep;
  107255. BJSCANNON: any;
  107256. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107257. setGravity(gravity: Vector3): void;
  107258. setTimeStep(timeStep: number): void;
  107259. getTimeStep(): number;
  107260. executeStep(delta: number): void;
  107261. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107262. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107263. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107264. private _processChildMeshes;
  107265. removePhysicsBody(impostor: PhysicsImpostor): void;
  107266. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107267. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107268. private _addMaterial;
  107269. private _checkWithEpsilon;
  107270. private _createShape;
  107271. private _createHeightmap;
  107272. private _minus90X;
  107273. private _plus90X;
  107274. private _tmpPosition;
  107275. private _tmpDeltaPosition;
  107276. private _tmpUnityRotation;
  107277. private _updatePhysicsBodyTransformation;
  107278. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107279. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107280. isSupported(): boolean;
  107281. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107282. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107283. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107284. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107285. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107286. getBodyMass(impostor: PhysicsImpostor): number;
  107287. getBodyFriction(impostor: PhysicsImpostor): number;
  107288. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107289. getBodyRestitution(impostor: PhysicsImpostor): number;
  107290. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107291. sleepBody(impostor: PhysicsImpostor): void;
  107292. wakeUpBody(impostor: PhysicsImpostor): void;
  107293. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107294. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107295. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107296. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107297. getRadius(impostor: PhysicsImpostor): number;
  107298. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107299. dispose(): void;
  107300. private _extendNamespace;
  107301. /**
  107302. * Does a raycast in the physics world
  107303. * @param from when should the ray start?
  107304. * @param to when should the ray end?
  107305. * @returns PhysicsRaycastResult
  107306. */
  107307. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107308. }
  107309. }
  107310. declare module BABYLON {
  107311. /** @hidden */
  107312. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107313. world: any;
  107314. name: string;
  107315. BJSOIMO: any;
  107316. private _raycastResult;
  107317. constructor(iterations?: number, oimoInjection?: any);
  107318. setGravity(gravity: Vector3): void;
  107319. setTimeStep(timeStep: number): void;
  107320. getTimeStep(): number;
  107321. private _tmpImpostorsArray;
  107322. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107323. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107324. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107325. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107326. private _tmpPositionVector;
  107327. removePhysicsBody(impostor: PhysicsImpostor): void;
  107328. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107329. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107330. isSupported(): boolean;
  107331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107332. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107333. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107334. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107335. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107336. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107337. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107338. getBodyMass(impostor: PhysicsImpostor): number;
  107339. getBodyFriction(impostor: PhysicsImpostor): number;
  107340. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107341. getBodyRestitution(impostor: PhysicsImpostor): number;
  107342. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107343. sleepBody(impostor: PhysicsImpostor): void;
  107344. wakeUpBody(impostor: PhysicsImpostor): void;
  107345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107346. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107348. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107349. getRadius(impostor: PhysicsImpostor): number;
  107350. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107351. dispose(): void;
  107352. /**
  107353. * Does a raycast in the physics world
  107354. * @param from when should the ray start?
  107355. * @param to when should the ray end?
  107356. * @returns PhysicsRaycastResult
  107357. */
  107358. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107359. }
  107360. }
  107361. declare module BABYLON {
  107362. /**
  107363. * Class containing static functions to help procedurally build meshes
  107364. */
  107365. export class RibbonBuilder {
  107366. /**
  107367. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107368. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107369. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107370. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107371. * * 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
  107372. * * 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
  107373. * * 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
  107374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107377. * * 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
  107378. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107379. * * 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
  107380. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107382. * @param name defines the name of the mesh
  107383. * @param options defines the options used to create the mesh
  107384. * @param scene defines the hosting scene
  107385. * @returns the ribbon mesh
  107386. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107388. */
  107389. static CreateRibbon(name: string, options: {
  107390. pathArray: Vector3[][];
  107391. closeArray?: boolean;
  107392. closePath?: boolean;
  107393. offset?: number;
  107394. updatable?: boolean;
  107395. sideOrientation?: number;
  107396. frontUVs?: Vector4;
  107397. backUVs?: Vector4;
  107398. instance?: Mesh;
  107399. invertUV?: boolean;
  107400. uvs?: Vector2[];
  107401. colors?: Color4[];
  107402. }, scene?: Nullable<Scene>): Mesh;
  107403. }
  107404. }
  107405. declare module BABYLON {
  107406. /**
  107407. * Class containing static functions to help procedurally build meshes
  107408. */
  107409. export class ShapeBuilder {
  107410. /**
  107411. * 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.
  107412. * * 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.
  107413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107414. * * 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.
  107415. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107416. * * 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
  107417. * * 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
  107418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107423. * @param name defines the name of the mesh
  107424. * @param options defines the options used to create the mesh
  107425. * @param scene defines the hosting scene
  107426. * @returns the extruded shape mesh
  107427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107429. */
  107430. static ExtrudeShape(name: string, options: {
  107431. shape: Vector3[];
  107432. path: Vector3[];
  107433. scale?: number;
  107434. rotation?: number;
  107435. cap?: number;
  107436. updatable?: boolean;
  107437. sideOrientation?: number;
  107438. frontUVs?: Vector4;
  107439. backUVs?: Vector4;
  107440. instance?: Mesh;
  107441. invertUV?: boolean;
  107442. }, scene?: Nullable<Scene>): Mesh;
  107443. /**
  107444. * Creates an custom extruded shape mesh.
  107445. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107446. * * 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.
  107447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107448. * * 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
  107449. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107450. * * 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
  107451. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107452. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107453. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107454. * * 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
  107455. * * 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
  107456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107461. * @param name defines the name of the mesh
  107462. * @param options defines the options used to create the mesh
  107463. * @param scene defines the hosting scene
  107464. * @returns the custom extruded shape mesh
  107465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107468. */
  107469. static ExtrudeShapeCustom(name: string, options: {
  107470. shape: Vector3[];
  107471. path: Vector3[];
  107472. scaleFunction?: any;
  107473. rotationFunction?: any;
  107474. ribbonCloseArray?: boolean;
  107475. ribbonClosePath?: boolean;
  107476. cap?: number;
  107477. updatable?: boolean;
  107478. sideOrientation?: number;
  107479. frontUVs?: Vector4;
  107480. backUVs?: Vector4;
  107481. instance?: Mesh;
  107482. invertUV?: boolean;
  107483. }, scene?: Nullable<Scene>): Mesh;
  107484. private static _ExtrudeShapeGeneric;
  107485. }
  107486. }
  107487. declare module BABYLON {
  107488. /**
  107489. * AmmoJS Physics plugin
  107490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107491. * @see https://github.com/kripken/ammo.js/
  107492. */
  107493. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107494. private _useDeltaForWorldStep;
  107495. /**
  107496. * Reference to the Ammo library
  107497. */
  107498. bjsAMMO: any;
  107499. /**
  107500. * Created ammoJS world which physics bodies are added to
  107501. */
  107502. world: any;
  107503. /**
  107504. * Name of the plugin
  107505. */
  107506. name: string;
  107507. private _timeStep;
  107508. private _fixedTimeStep;
  107509. private _maxSteps;
  107510. private _tmpQuaternion;
  107511. private _tmpAmmoTransform;
  107512. private _tmpAmmoQuaternion;
  107513. private _tmpAmmoConcreteContactResultCallback;
  107514. private _collisionConfiguration;
  107515. private _dispatcher;
  107516. private _overlappingPairCache;
  107517. private _solver;
  107518. private _softBodySolver;
  107519. private _tmpAmmoVectorA;
  107520. private _tmpAmmoVectorB;
  107521. private _tmpAmmoVectorC;
  107522. private _tmpAmmoVectorD;
  107523. private _tmpContactCallbackResult;
  107524. private _tmpAmmoVectorRCA;
  107525. private _tmpAmmoVectorRCB;
  107526. private _raycastResult;
  107527. private static readonly DISABLE_COLLISION_FLAG;
  107528. private static readonly KINEMATIC_FLAG;
  107529. private static readonly DISABLE_DEACTIVATION_FLAG;
  107530. /**
  107531. * Initializes the ammoJS plugin
  107532. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107533. * @param ammoInjection can be used to inject your own ammo reference
  107534. */
  107535. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107536. /**
  107537. * Sets the gravity of the physics world (m/(s^2))
  107538. * @param gravity Gravity to set
  107539. */
  107540. setGravity(gravity: Vector3): void;
  107541. /**
  107542. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107543. * @param timeStep timestep to use in seconds
  107544. */
  107545. setTimeStep(timeStep: number): void;
  107546. /**
  107547. * 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)
  107548. * @param fixedTimeStep fixedTimeStep to use in seconds
  107549. */
  107550. setFixedTimeStep(fixedTimeStep: number): void;
  107551. /**
  107552. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107553. * @param maxSteps the maximum number of steps by the physics engine per frame
  107554. */
  107555. setMaxSteps(maxSteps: number): void;
  107556. /**
  107557. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107558. * @returns the current timestep in seconds
  107559. */
  107560. getTimeStep(): number;
  107561. private _isImpostorInContact;
  107562. private _isImpostorPairInContact;
  107563. private _stepSimulation;
  107564. /**
  107565. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107566. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107567. * After the step the babylon meshes are set to the position of the physics imposters
  107568. * @param delta amount of time to step forward
  107569. * @param impostors array of imposters to update before/after the step
  107570. */
  107571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107572. /**
  107573. * Update babylon mesh to match physics world object
  107574. * @param impostor imposter to match
  107575. */
  107576. private _afterSoftStep;
  107577. /**
  107578. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107579. * @param impostor imposter to match
  107580. */
  107581. private _ropeStep;
  107582. /**
  107583. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107584. * @param impostor imposter to match
  107585. */
  107586. private _softbodyOrClothStep;
  107587. private _tmpVector;
  107588. private _tmpMatrix;
  107589. /**
  107590. * Applies an impulse on the imposter
  107591. * @param impostor imposter to apply impulse to
  107592. * @param force amount of force to be applied to the imposter
  107593. * @param contactPoint the location to apply the impulse on the imposter
  107594. */
  107595. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107596. /**
  107597. * Applies a force on the imposter
  107598. * @param impostor imposter to apply force
  107599. * @param force amount of force to be applied to the imposter
  107600. * @param contactPoint the location to apply the force on the imposter
  107601. */
  107602. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107603. /**
  107604. * Creates a physics body using the plugin
  107605. * @param impostor the imposter to create the physics body on
  107606. */
  107607. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107608. /**
  107609. * Removes the physics body from the imposter and disposes of the body's memory
  107610. * @param impostor imposter to remove the physics body from
  107611. */
  107612. removePhysicsBody(impostor: PhysicsImpostor): void;
  107613. /**
  107614. * Generates a joint
  107615. * @param impostorJoint the imposter joint to create the joint with
  107616. */
  107617. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107618. /**
  107619. * Removes a joint
  107620. * @param impostorJoint the imposter joint to remove the joint from
  107621. */
  107622. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107623. private _addMeshVerts;
  107624. /**
  107625. * Initialise the soft body vertices to match its object's (mesh) vertices
  107626. * Softbody vertices (nodes) are in world space and to match this
  107627. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107628. * @param impostor to create the softbody for
  107629. */
  107630. private _softVertexData;
  107631. /**
  107632. * Create an impostor's soft body
  107633. * @param impostor to create the softbody for
  107634. */
  107635. private _createSoftbody;
  107636. /**
  107637. * Create cloth for an impostor
  107638. * @param impostor to create the softbody for
  107639. */
  107640. private _createCloth;
  107641. /**
  107642. * Create rope for an impostor
  107643. * @param impostor to create the softbody for
  107644. */
  107645. private _createRope;
  107646. private _addHullVerts;
  107647. private _createShape;
  107648. /**
  107649. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107650. * @param impostor imposter containing the physics body and babylon object
  107651. */
  107652. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107653. /**
  107654. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107655. * @param impostor imposter containing the physics body and babylon object
  107656. * @param newPosition new position
  107657. * @param newRotation new rotation
  107658. */
  107659. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107660. /**
  107661. * If this plugin is supported
  107662. * @returns true if its supported
  107663. */
  107664. isSupported(): boolean;
  107665. /**
  107666. * Sets the linear velocity of the physics body
  107667. * @param impostor imposter to set the velocity on
  107668. * @param velocity velocity to set
  107669. */
  107670. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107671. /**
  107672. * Sets the angular velocity of the physics body
  107673. * @param impostor imposter to set the velocity on
  107674. * @param velocity velocity to set
  107675. */
  107676. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107677. /**
  107678. * gets the linear velocity
  107679. * @param impostor imposter to get linear velocity from
  107680. * @returns linear velocity
  107681. */
  107682. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107683. /**
  107684. * gets the angular velocity
  107685. * @param impostor imposter to get angular velocity from
  107686. * @returns angular velocity
  107687. */
  107688. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107689. /**
  107690. * Sets the mass of physics body
  107691. * @param impostor imposter to set the mass on
  107692. * @param mass mass to set
  107693. */
  107694. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107695. /**
  107696. * Gets the mass of the physics body
  107697. * @param impostor imposter to get the mass from
  107698. * @returns mass
  107699. */
  107700. getBodyMass(impostor: PhysicsImpostor): number;
  107701. /**
  107702. * Gets friction of the impostor
  107703. * @param impostor impostor to get friction from
  107704. * @returns friction value
  107705. */
  107706. getBodyFriction(impostor: PhysicsImpostor): number;
  107707. /**
  107708. * Sets friction of the impostor
  107709. * @param impostor impostor to set friction on
  107710. * @param friction friction value
  107711. */
  107712. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107713. /**
  107714. * Gets restitution of the impostor
  107715. * @param impostor impostor to get restitution from
  107716. * @returns restitution value
  107717. */
  107718. getBodyRestitution(impostor: PhysicsImpostor): number;
  107719. /**
  107720. * Sets resitution of the impostor
  107721. * @param impostor impostor to set resitution on
  107722. * @param restitution resitution value
  107723. */
  107724. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107725. /**
  107726. * Gets pressure inside the impostor
  107727. * @param impostor impostor to get pressure from
  107728. * @returns pressure value
  107729. */
  107730. getBodyPressure(impostor: PhysicsImpostor): number;
  107731. /**
  107732. * Sets pressure inside a soft body impostor
  107733. * Cloth and rope must remain 0 pressure
  107734. * @param impostor impostor to set pressure on
  107735. * @param pressure pressure value
  107736. */
  107737. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107738. /**
  107739. * Gets stiffness of the impostor
  107740. * @param impostor impostor to get stiffness from
  107741. * @returns pressure value
  107742. */
  107743. getBodyStiffness(impostor: PhysicsImpostor): number;
  107744. /**
  107745. * Sets stiffness of the impostor
  107746. * @param impostor impostor to set stiffness on
  107747. * @param stiffness stiffness value from 0 to 1
  107748. */
  107749. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107750. /**
  107751. * Gets velocityIterations of the impostor
  107752. * @param impostor impostor to get velocity iterations from
  107753. * @returns velocityIterations value
  107754. */
  107755. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107756. /**
  107757. * Sets velocityIterations of the impostor
  107758. * @param impostor impostor to set velocity iterations on
  107759. * @param velocityIterations velocityIterations value
  107760. */
  107761. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107762. /**
  107763. * Gets positionIterations of the impostor
  107764. * @param impostor impostor to get position iterations from
  107765. * @returns positionIterations value
  107766. */
  107767. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107768. /**
  107769. * Sets positionIterations of the impostor
  107770. * @param impostor impostor to set position on
  107771. * @param positionIterations positionIterations value
  107772. */
  107773. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107774. /**
  107775. * Append an anchor to a cloth object
  107776. * @param impostor is the cloth impostor to add anchor to
  107777. * @param otherImpostor is the rigid impostor to anchor to
  107778. * @param width ratio across width from 0 to 1
  107779. * @param height ratio up height from 0 to 1
  107780. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107781. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107782. */
  107783. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107784. /**
  107785. * Append an hook to a rope object
  107786. * @param impostor is the rope impostor to add hook to
  107787. * @param otherImpostor is the rigid impostor to hook to
  107788. * @param length ratio along the rope from 0 to 1
  107789. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107790. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107791. */
  107792. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107793. /**
  107794. * Sleeps the physics body and stops it from being active
  107795. * @param impostor impostor to sleep
  107796. */
  107797. sleepBody(impostor: PhysicsImpostor): void;
  107798. /**
  107799. * Activates the physics body
  107800. * @param impostor impostor to activate
  107801. */
  107802. wakeUpBody(impostor: PhysicsImpostor): void;
  107803. /**
  107804. * Updates the distance parameters of the joint
  107805. * @param joint joint to update
  107806. * @param maxDistance maximum distance of the joint
  107807. * @param minDistance minimum distance of the joint
  107808. */
  107809. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107810. /**
  107811. * Sets a motor on the joint
  107812. * @param joint joint to set motor on
  107813. * @param speed speed of the motor
  107814. * @param maxForce maximum force of the motor
  107815. * @param motorIndex index of the motor
  107816. */
  107817. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107818. /**
  107819. * Sets the motors limit
  107820. * @param joint joint to set limit on
  107821. * @param upperLimit upper limit
  107822. * @param lowerLimit lower limit
  107823. */
  107824. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107825. /**
  107826. * Syncs the position and rotation of a mesh with the impostor
  107827. * @param mesh mesh to sync
  107828. * @param impostor impostor to update the mesh with
  107829. */
  107830. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107831. /**
  107832. * Gets the radius of the impostor
  107833. * @param impostor impostor to get radius from
  107834. * @returns the radius
  107835. */
  107836. getRadius(impostor: PhysicsImpostor): number;
  107837. /**
  107838. * Gets the box size of the impostor
  107839. * @param impostor impostor to get box size from
  107840. * @param result the resulting box size
  107841. */
  107842. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107843. /**
  107844. * Disposes of the impostor
  107845. */
  107846. dispose(): void;
  107847. /**
  107848. * Does a raycast in the physics world
  107849. * @param from when should the ray start?
  107850. * @param to when should the ray end?
  107851. * @returns PhysicsRaycastResult
  107852. */
  107853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107854. }
  107855. }
  107856. declare module BABYLON {
  107857. interface AbstractScene {
  107858. /**
  107859. * The list of reflection probes added to the scene
  107860. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107861. */
  107862. reflectionProbes: Array<ReflectionProbe>;
  107863. /**
  107864. * Removes the given reflection probe from this scene.
  107865. * @param toRemove The reflection probe to remove
  107866. * @returns The index of the removed reflection probe
  107867. */
  107868. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107869. /**
  107870. * Adds the given reflection probe to this scene.
  107871. * @param newReflectionProbe The reflection probe to add
  107872. */
  107873. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107874. }
  107875. /**
  107876. * Class used to generate realtime reflection / refraction cube textures
  107877. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107878. */
  107879. export class ReflectionProbe {
  107880. /** defines the name of the probe */
  107881. name: string;
  107882. private _scene;
  107883. private _renderTargetTexture;
  107884. private _projectionMatrix;
  107885. private _viewMatrix;
  107886. private _target;
  107887. private _add;
  107888. private _attachedMesh;
  107889. private _invertYAxis;
  107890. /** Gets or sets probe position (center of the cube map) */
  107891. position: Vector3;
  107892. /**
  107893. * Creates a new reflection probe
  107894. * @param name defines the name of the probe
  107895. * @param size defines the texture resolution (for each face)
  107896. * @param scene defines the hosting scene
  107897. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107898. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107899. */
  107900. constructor(
  107901. /** defines the name of the probe */
  107902. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107903. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107904. samples: number;
  107905. /** Gets or sets the refresh rate to use (on every frame by default) */
  107906. refreshRate: number;
  107907. /**
  107908. * Gets the hosting scene
  107909. * @returns a Scene
  107910. */
  107911. getScene(): Scene;
  107912. /** Gets the internal CubeTexture used to render to */
  107913. readonly cubeTexture: RenderTargetTexture;
  107914. /** Gets the list of meshes to render */
  107915. readonly renderList: Nullable<AbstractMesh[]>;
  107916. /**
  107917. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107918. * @param mesh defines the mesh to attach to
  107919. */
  107920. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107921. /**
  107922. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107923. * @param renderingGroupId The rendering group id corresponding to its index
  107924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107925. */
  107926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107927. /**
  107928. * Clean all associated resources
  107929. */
  107930. dispose(): void;
  107931. /**
  107932. * Converts the reflection probe information to a readable string for debug purpose.
  107933. * @param fullDetails Supports for multiple levels of logging within scene loading
  107934. * @returns the human readable reflection probe info
  107935. */
  107936. toString(fullDetails?: boolean): string;
  107937. /**
  107938. * Get the class name of the relfection probe.
  107939. * @returns "ReflectionProbe"
  107940. */
  107941. getClassName(): string;
  107942. /**
  107943. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107944. * @returns The JSON representation of the texture
  107945. */
  107946. serialize(): any;
  107947. /**
  107948. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107949. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107950. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107951. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107952. * @returns The parsed reflection probe if successful
  107953. */
  107954. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107955. }
  107956. }
  107957. declare module BABYLON {
  107958. /** @hidden */
  107959. export var _BabylonLoaderRegistered: boolean;
  107960. }
  107961. declare module BABYLON {
  107962. /**
  107963. * The Physically based simple base material of BJS.
  107964. *
  107965. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107966. * It is used as the base class for both the specGloss and metalRough conventions.
  107967. */
  107968. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107969. /**
  107970. * Number of Simultaneous lights allowed on the material.
  107971. */
  107972. maxSimultaneousLights: number;
  107973. /**
  107974. * If sets to true, disables all the lights affecting the material.
  107975. */
  107976. disableLighting: boolean;
  107977. /**
  107978. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107979. */
  107980. environmentTexture: BaseTexture;
  107981. /**
  107982. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107983. */
  107984. invertNormalMapX: boolean;
  107985. /**
  107986. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107987. */
  107988. invertNormalMapY: boolean;
  107989. /**
  107990. * Normal map used in the model.
  107991. */
  107992. normalTexture: BaseTexture;
  107993. /**
  107994. * Emissivie color used to self-illuminate the model.
  107995. */
  107996. emissiveColor: Color3;
  107997. /**
  107998. * Emissivie texture used to self-illuminate the model.
  107999. */
  108000. emissiveTexture: BaseTexture;
  108001. /**
  108002. * Occlusion Channel Strenght.
  108003. */
  108004. occlusionStrength: number;
  108005. /**
  108006. * Occlusion Texture of the material (adding extra occlusion effects).
  108007. */
  108008. occlusionTexture: BaseTexture;
  108009. /**
  108010. * Defines the alpha limits in alpha test mode.
  108011. */
  108012. alphaCutOff: number;
  108013. /**
  108014. * Gets the current double sided mode.
  108015. */
  108016. /**
  108017. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108018. */
  108019. doubleSided: boolean;
  108020. /**
  108021. * Stores the pre-calculated light information of a mesh in a texture.
  108022. */
  108023. lightmapTexture: BaseTexture;
  108024. /**
  108025. * If true, the light map contains occlusion information instead of lighting info.
  108026. */
  108027. useLightmapAsShadowmap: boolean;
  108028. /**
  108029. * Instantiates a new PBRMaterial instance.
  108030. *
  108031. * @param name The material name
  108032. * @param scene The scene the material will be use in.
  108033. */
  108034. constructor(name: string, scene: Scene);
  108035. getClassName(): string;
  108036. }
  108037. }
  108038. declare module BABYLON {
  108039. /**
  108040. * The PBR material of BJS following the metal roughness convention.
  108041. *
  108042. * This fits to the PBR convention in the GLTF definition:
  108043. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108044. */
  108045. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108046. /**
  108047. * The base color has two different interpretations depending on the value of metalness.
  108048. * When the material is a metal, the base color is the specific measured reflectance value
  108049. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108050. * of the material.
  108051. */
  108052. baseColor: Color3;
  108053. /**
  108054. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108055. * well as opacity information in the alpha channel.
  108056. */
  108057. baseTexture: BaseTexture;
  108058. /**
  108059. * Specifies the metallic scalar value of the material.
  108060. * Can also be used to scale the metalness values of the metallic texture.
  108061. */
  108062. metallic: number;
  108063. /**
  108064. * Specifies the roughness scalar value of the material.
  108065. * Can also be used to scale the roughness values of the metallic texture.
  108066. */
  108067. roughness: number;
  108068. /**
  108069. * Texture containing both the metallic value in the B channel and the
  108070. * roughness value in the G channel to keep better precision.
  108071. */
  108072. metallicRoughnessTexture: BaseTexture;
  108073. /**
  108074. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108075. *
  108076. * @param name The material name
  108077. * @param scene The scene the material will be use in.
  108078. */
  108079. constructor(name: string, scene: Scene);
  108080. /**
  108081. * Return the currrent class name of the material.
  108082. */
  108083. getClassName(): string;
  108084. /**
  108085. * Makes a duplicate of the current material.
  108086. * @param name - name to use for the new material.
  108087. */
  108088. clone(name: string): PBRMetallicRoughnessMaterial;
  108089. /**
  108090. * Serialize the material to a parsable JSON object.
  108091. */
  108092. serialize(): any;
  108093. /**
  108094. * Parses a JSON object correponding to the serialize function.
  108095. */
  108096. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108097. }
  108098. }
  108099. declare module BABYLON {
  108100. /**
  108101. * The PBR material of BJS following the specular glossiness convention.
  108102. *
  108103. * This fits to the PBR convention in the GLTF definition:
  108104. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108105. */
  108106. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108107. /**
  108108. * Specifies the diffuse color of the material.
  108109. */
  108110. diffuseColor: Color3;
  108111. /**
  108112. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108113. * channel.
  108114. */
  108115. diffuseTexture: BaseTexture;
  108116. /**
  108117. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108118. */
  108119. specularColor: Color3;
  108120. /**
  108121. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108122. */
  108123. glossiness: number;
  108124. /**
  108125. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108126. */
  108127. specularGlossinessTexture: BaseTexture;
  108128. /**
  108129. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108130. *
  108131. * @param name The material name
  108132. * @param scene The scene the material will be use in.
  108133. */
  108134. constructor(name: string, scene: Scene);
  108135. /**
  108136. * Return the currrent class name of the material.
  108137. */
  108138. getClassName(): string;
  108139. /**
  108140. * Makes a duplicate of the current material.
  108141. * @param name - name to use for the new material.
  108142. */
  108143. clone(name: string): PBRSpecularGlossinessMaterial;
  108144. /**
  108145. * Serialize the material to a parsable JSON object.
  108146. */
  108147. serialize(): any;
  108148. /**
  108149. * Parses a JSON object correponding to the serialize function.
  108150. */
  108151. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108152. }
  108153. }
  108154. declare module BABYLON {
  108155. /**
  108156. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108157. * It can help converting any input color in a desired output one. This can then be used to create effects
  108158. * from sepia, black and white to sixties or futuristic rendering...
  108159. *
  108160. * The only supported format is currently 3dl.
  108161. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108162. */
  108163. export class ColorGradingTexture extends BaseTexture {
  108164. /**
  108165. * The current texture matrix. (will always be identity in color grading texture)
  108166. */
  108167. private _textureMatrix;
  108168. /**
  108169. * The texture URL.
  108170. */
  108171. url: string;
  108172. /**
  108173. * Empty line regex stored for GC.
  108174. */
  108175. private static _noneEmptyLineRegex;
  108176. private _engine;
  108177. /**
  108178. * Instantiates a ColorGradingTexture from the following parameters.
  108179. *
  108180. * @param url The location of the color gradind data (currently only supporting 3dl)
  108181. * @param scene The scene the texture will be used in
  108182. */
  108183. constructor(url: string, scene: Scene);
  108184. /**
  108185. * Returns the texture matrix used in most of the material.
  108186. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108187. */
  108188. getTextureMatrix(): Matrix;
  108189. /**
  108190. * Occurs when the file being loaded is a .3dl LUT file.
  108191. */
  108192. private load3dlTexture;
  108193. /**
  108194. * Starts the loading process of the texture.
  108195. */
  108196. private loadTexture;
  108197. /**
  108198. * Clones the color gradind texture.
  108199. */
  108200. clone(): ColorGradingTexture;
  108201. /**
  108202. * Called during delayed load for textures.
  108203. */
  108204. delayLoad(): void;
  108205. /**
  108206. * Parses a color grading texture serialized by Babylon.
  108207. * @param parsedTexture The texture information being parsedTexture
  108208. * @param scene The scene to load the texture in
  108209. * @param rootUrl The root url of the data assets to load
  108210. * @return A color gradind texture
  108211. */
  108212. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108213. /**
  108214. * Serializes the LUT texture to json format.
  108215. */
  108216. serialize(): any;
  108217. }
  108218. }
  108219. declare module BABYLON {
  108220. /**
  108221. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108222. */
  108223. export class EquiRectangularCubeTexture extends BaseTexture {
  108224. /** The six faces of the cube. */
  108225. private static _FacesMapping;
  108226. private _noMipmap;
  108227. private _onLoad;
  108228. private _onError;
  108229. /** The size of the cubemap. */
  108230. private _size;
  108231. /** The buffer of the image. */
  108232. private _buffer;
  108233. /** The width of the input image. */
  108234. private _width;
  108235. /** The height of the input image. */
  108236. private _height;
  108237. /** The URL to the image. */
  108238. url: string;
  108239. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108240. coordinatesMode: number;
  108241. /**
  108242. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108243. * @param url The location of the image
  108244. * @param scene The scene the texture will be used in
  108245. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108246. * @param noMipmap Forces to not generate the mipmap if true
  108247. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108248. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108249. * @param onLoad — defines a callback called when texture is loaded
  108250. * @param onError — defines a callback called if there is an error
  108251. */
  108252. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108253. /**
  108254. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108255. */
  108256. private loadImage;
  108257. /**
  108258. * Convert the image buffer into a cubemap and create a CubeTexture.
  108259. */
  108260. private loadTexture;
  108261. /**
  108262. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108263. * @param buffer The ArrayBuffer that should be converted.
  108264. * @returns The buffer as Float32Array.
  108265. */
  108266. private getFloat32ArrayFromArrayBuffer;
  108267. /**
  108268. * Get the current class name of the texture useful for serialization or dynamic coding.
  108269. * @returns "EquiRectangularCubeTexture"
  108270. */
  108271. getClassName(): string;
  108272. /**
  108273. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108274. * @returns A clone of the current EquiRectangularCubeTexture.
  108275. */
  108276. clone(): EquiRectangularCubeTexture;
  108277. }
  108278. }
  108279. declare module BABYLON {
  108280. /**
  108281. * Based on jsTGALoader - Javascript loader for TGA file
  108282. * By Vincent Thibault
  108283. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108284. */
  108285. export class TGATools {
  108286. private static _TYPE_INDEXED;
  108287. private static _TYPE_RGB;
  108288. private static _TYPE_GREY;
  108289. private static _TYPE_RLE_INDEXED;
  108290. private static _TYPE_RLE_RGB;
  108291. private static _TYPE_RLE_GREY;
  108292. private static _ORIGIN_MASK;
  108293. private static _ORIGIN_SHIFT;
  108294. private static _ORIGIN_BL;
  108295. private static _ORIGIN_BR;
  108296. private static _ORIGIN_UL;
  108297. private static _ORIGIN_UR;
  108298. /**
  108299. * Gets the header of a TGA file
  108300. * @param data defines the TGA data
  108301. * @returns the header
  108302. */
  108303. static GetTGAHeader(data: Uint8Array): any;
  108304. /**
  108305. * Uploads TGA content to a Babylon Texture
  108306. * @hidden
  108307. */
  108308. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108309. /** @hidden */
  108310. 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;
  108311. /** @hidden */
  108312. 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;
  108313. /** @hidden */
  108314. 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;
  108315. /** @hidden */
  108316. 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;
  108317. /** @hidden */
  108318. 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;
  108319. /** @hidden */
  108320. 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;
  108321. }
  108322. }
  108323. declare module BABYLON {
  108324. /**
  108325. * Implementation of the TGA Texture Loader.
  108326. * @hidden
  108327. */
  108328. export class _TGATextureLoader implements IInternalTextureLoader {
  108329. /**
  108330. * Defines wether the loader supports cascade loading the different faces.
  108331. */
  108332. readonly supportCascades: boolean;
  108333. /**
  108334. * This returns if the loader support the current file information.
  108335. * @param extension defines the file extension of the file being loaded
  108336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108337. * @param fallback defines the fallback internal texture if any
  108338. * @param isBase64 defines whether the texture is encoded as a base64
  108339. * @param isBuffer defines whether the texture data are stored as a buffer
  108340. * @returns true if the loader can load the specified file
  108341. */
  108342. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108343. /**
  108344. * Transform the url before loading if required.
  108345. * @param rootUrl the url of the texture
  108346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108347. * @returns the transformed texture
  108348. */
  108349. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108350. /**
  108351. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108352. * @param rootUrl the url of the texture
  108353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108354. * @returns the fallback texture
  108355. */
  108356. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108357. /**
  108358. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108359. * @param data contains the texture data
  108360. * @param texture defines the BabylonJS internal texture
  108361. * @param createPolynomials will be true if polynomials have been requested
  108362. * @param onLoad defines the callback to trigger once the texture is ready
  108363. * @param onError defines the callback to trigger in case of error
  108364. */
  108365. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108366. /**
  108367. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108368. * @param data contains the texture data
  108369. * @param texture defines the BabylonJS internal texture
  108370. * @param callback defines the method to call once ready to upload
  108371. */
  108372. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108373. }
  108374. }
  108375. declare module BABYLON {
  108376. /**
  108377. * 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.
  108378. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108379. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108380. */
  108381. export class CustomProceduralTexture extends ProceduralTexture {
  108382. private _animate;
  108383. private _time;
  108384. private _config;
  108385. private _texturePath;
  108386. /**
  108387. * Instantiates a new Custom Procedural Texture.
  108388. * 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.
  108389. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108390. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108391. * @param name Define the name of the texture
  108392. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108393. * @param size Define the size of the texture to create
  108394. * @param scene Define the scene the texture belongs to
  108395. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108396. * @param generateMipMaps Define if the texture should creates mip maps or not
  108397. */
  108398. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108399. private _loadJson;
  108400. /**
  108401. * Is the texture ready to be used ? (rendered at least once)
  108402. * @returns true if ready, otherwise, false.
  108403. */
  108404. isReady(): boolean;
  108405. /**
  108406. * Render the texture to its associated render target.
  108407. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108408. */
  108409. render(useCameraPostProcess?: boolean): void;
  108410. /**
  108411. * Update the list of dependant textures samplers in the shader.
  108412. */
  108413. updateTextures(): void;
  108414. /**
  108415. * Update the uniform values of the procedural texture in the shader.
  108416. */
  108417. updateShaderUniforms(): void;
  108418. /**
  108419. * Define if the texture animates or not.
  108420. */
  108421. animate: boolean;
  108422. }
  108423. }
  108424. declare module BABYLON {
  108425. /** @hidden */
  108426. export var noisePixelShader: {
  108427. name: string;
  108428. shader: string;
  108429. };
  108430. }
  108431. declare module BABYLON {
  108432. /**
  108433. * Class used to generate noise procedural textures
  108434. */
  108435. export class NoiseProceduralTexture extends ProceduralTexture {
  108436. private _time;
  108437. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108438. brightness: number;
  108439. /** Defines the number of octaves to process */
  108440. octaves: number;
  108441. /** Defines the level of persistence (0.8 by default) */
  108442. persistence: number;
  108443. /** Gets or sets animation speed factor (default is 1) */
  108444. animationSpeedFactor: number;
  108445. /**
  108446. * Creates a new NoiseProceduralTexture
  108447. * @param name defines the name fo the texture
  108448. * @param size defines the size of the texture (default is 256)
  108449. * @param scene defines the hosting scene
  108450. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108451. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108452. */
  108453. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108454. private _updateShaderUniforms;
  108455. protected _getDefines(): string;
  108456. /** Generate the current state of the procedural texture */
  108457. render(useCameraPostProcess?: boolean): void;
  108458. /**
  108459. * Serializes this noise procedural texture
  108460. * @returns a serialized noise procedural texture object
  108461. */
  108462. serialize(): any;
  108463. /**
  108464. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108465. * @param parsedTexture defines parsed texture data
  108466. * @param scene defines the current scene
  108467. * @param rootUrl defines the root URL containing noise procedural texture information
  108468. * @returns a parsed NoiseProceduralTexture
  108469. */
  108470. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108471. }
  108472. }
  108473. declare module BABYLON {
  108474. /**
  108475. * Raw cube texture where the raw buffers are passed in
  108476. */
  108477. export class RawCubeTexture extends CubeTexture {
  108478. /**
  108479. * Creates a cube texture where the raw buffers are passed in.
  108480. * @param scene defines the scene the texture is attached to
  108481. * @param data defines the array of data to use to create each face
  108482. * @param size defines the size of the textures
  108483. * @param format defines the format of the data
  108484. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108485. * @param generateMipMaps defines if the engine should generate the mip levels
  108486. * @param invertY defines if data must be stored with Y axis inverted
  108487. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108488. * @param compression defines the compression used (null by default)
  108489. */
  108490. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108491. /**
  108492. * Updates the raw cube texture.
  108493. * @param data defines the data to store
  108494. * @param format defines the data format
  108495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108496. * @param invertY defines if data must be stored with Y axis inverted
  108497. * @param compression defines the compression used (null by default)
  108498. * @param level defines which level of the texture to update
  108499. */
  108500. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108501. /**
  108502. * Updates a raw cube texture with RGBD encoded data.
  108503. * @param data defines the array of data [mipmap][face] to use to create each face
  108504. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108505. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108506. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108507. * @returns a promsie that resolves when the operation is complete
  108508. */
  108509. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108510. /**
  108511. * Clones the raw cube texture.
  108512. * @return a new cube texture
  108513. */
  108514. clone(): CubeTexture;
  108515. /** @hidden */
  108516. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108517. }
  108518. }
  108519. declare module BABYLON {
  108520. /**
  108521. * Class used to store 3D textures containing user data
  108522. */
  108523. export class RawTexture3D extends Texture {
  108524. /** Gets or sets the texture format to use */
  108525. format: number;
  108526. private _engine;
  108527. /**
  108528. * Create a new RawTexture3D
  108529. * @param data defines the data of the texture
  108530. * @param width defines the width of the texture
  108531. * @param height defines the height of the texture
  108532. * @param depth defines the depth of the texture
  108533. * @param format defines the texture format to use
  108534. * @param scene defines the hosting scene
  108535. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108536. * @param invertY defines if texture must be stored with Y axis inverted
  108537. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108538. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108539. */
  108540. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108541. /** Gets or sets the texture format to use */
  108542. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108543. /**
  108544. * Update the texture with new data
  108545. * @param data defines the data to store in the texture
  108546. */
  108547. update(data: ArrayBufferView): void;
  108548. }
  108549. }
  108550. declare module BABYLON {
  108551. /**
  108552. * Creates a refraction texture used by refraction channel of the standard material.
  108553. * It is like a mirror but to see through a material.
  108554. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108555. */
  108556. export class RefractionTexture extends RenderTargetTexture {
  108557. /**
  108558. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108559. * 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.
  108560. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108561. */
  108562. refractionPlane: Plane;
  108563. /**
  108564. * Define how deep under the surface we should see.
  108565. */
  108566. depth: number;
  108567. /**
  108568. * Creates a refraction texture used by refraction channel of the standard material.
  108569. * It is like a mirror but to see through a material.
  108570. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108571. * @param name Define the texture name
  108572. * @param size Define the size of the underlying texture
  108573. * @param scene Define the scene the refraction belongs to
  108574. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108575. */
  108576. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108577. /**
  108578. * Clone the refraction texture.
  108579. * @returns the cloned texture
  108580. */
  108581. clone(): RefractionTexture;
  108582. /**
  108583. * Serialize the texture to a JSON representation you could use in Parse later on
  108584. * @returns the serialized JSON representation
  108585. */
  108586. serialize(): any;
  108587. }
  108588. }
  108589. declare module BABYLON {
  108590. /**
  108591. * Configuration for Draco compression
  108592. */
  108593. export interface IDracoCompressionConfiguration {
  108594. /**
  108595. * Configuration for the decoder.
  108596. */
  108597. decoder?: {
  108598. /**
  108599. * The url to the WebAssembly module.
  108600. */
  108601. wasmUrl?: string;
  108602. /**
  108603. * The url to the WebAssembly binary.
  108604. */
  108605. wasmBinaryUrl?: string;
  108606. /**
  108607. * The url to the fallback JavaScript module.
  108608. */
  108609. fallbackUrl?: string;
  108610. };
  108611. }
  108612. /**
  108613. * Draco compression (https://google.github.io/draco/)
  108614. *
  108615. * This class wraps the Draco module.
  108616. *
  108617. * **Encoder**
  108618. *
  108619. * The encoder is not currently implemented.
  108620. *
  108621. * **Decoder**
  108622. *
  108623. * 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.
  108624. *
  108625. * To update the configuration, use the following code:
  108626. * ```javascript
  108627. * DracoCompression.Configuration = {
  108628. * decoder: {
  108629. * wasmUrl: "<url to the WebAssembly library>",
  108630. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108631. * fallbackUrl: "<url to the fallback JavaScript library>",
  108632. * }
  108633. * };
  108634. * ```
  108635. *
  108636. * 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.
  108637. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108638. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108639. *
  108640. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108641. * ```javascript
  108642. * var dracoCompression = new DracoCompression();
  108643. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108644. * [VertexBuffer.PositionKind]: 0
  108645. * });
  108646. * ```
  108647. *
  108648. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108649. */
  108650. export class DracoCompression implements IDisposable {
  108651. private static _DecoderModulePromise;
  108652. /**
  108653. * The configuration. Defaults to the following urls:
  108654. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108655. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108656. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108657. */
  108658. static Configuration: IDracoCompressionConfiguration;
  108659. /**
  108660. * Returns true if the decoder is available.
  108661. */
  108662. static readonly DecoderAvailable: boolean;
  108663. /**
  108664. * Constructor
  108665. */
  108666. constructor();
  108667. /**
  108668. * Stop all async operations and release resources.
  108669. */
  108670. dispose(): void;
  108671. /**
  108672. * Decode Draco compressed mesh data to vertex data.
  108673. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108674. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108675. * @returns A promise that resolves with the decoded vertex data
  108676. */
  108677. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108678. [kind: string]: number;
  108679. }): Promise<VertexData>;
  108680. private static _GetDecoderModule;
  108681. private static _LoadScriptAsync;
  108682. private static _LoadFileAsync;
  108683. }
  108684. }
  108685. declare module BABYLON {
  108686. /**
  108687. * Class for building Constructive Solid Geometry
  108688. */
  108689. export class CSG {
  108690. private polygons;
  108691. /**
  108692. * The world matrix
  108693. */
  108694. matrix: Matrix;
  108695. /**
  108696. * Stores the position
  108697. */
  108698. position: Vector3;
  108699. /**
  108700. * Stores the rotation
  108701. */
  108702. rotation: Vector3;
  108703. /**
  108704. * Stores the rotation quaternion
  108705. */
  108706. rotationQuaternion: Nullable<Quaternion>;
  108707. /**
  108708. * Stores the scaling vector
  108709. */
  108710. scaling: Vector3;
  108711. /**
  108712. * Convert the Mesh to CSG
  108713. * @param mesh The Mesh to convert to CSG
  108714. * @returns A new CSG from the Mesh
  108715. */
  108716. static FromMesh(mesh: Mesh): CSG;
  108717. /**
  108718. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108719. * @param polygons Polygons used to construct a CSG solid
  108720. */
  108721. private static FromPolygons;
  108722. /**
  108723. * Clones, or makes a deep copy, of the CSG
  108724. * @returns A new CSG
  108725. */
  108726. clone(): CSG;
  108727. /**
  108728. * Unions this CSG with another CSG
  108729. * @param csg The CSG to union against this CSG
  108730. * @returns The unioned CSG
  108731. */
  108732. union(csg: CSG): CSG;
  108733. /**
  108734. * Unions this CSG with another CSG in place
  108735. * @param csg The CSG to union against this CSG
  108736. */
  108737. unionInPlace(csg: CSG): void;
  108738. /**
  108739. * Subtracts this CSG with another CSG
  108740. * @param csg The CSG to subtract against this CSG
  108741. * @returns A new CSG
  108742. */
  108743. subtract(csg: CSG): CSG;
  108744. /**
  108745. * Subtracts this CSG with another CSG in place
  108746. * @param csg The CSG to subtact against this CSG
  108747. */
  108748. subtractInPlace(csg: CSG): void;
  108749. /**
  108750. * Intersect this CSG with another CSG
  108751. * @param csg The CSG to intersect against this CSG
  108752. * @returns A new CSG
  108753. */
  108754. intersect(csg: CSG): CSG;
  108755. /**
  108756. * Intersects this CSG with another CSG in place
  108757. * @param csg The CSG to intersect against this CSG
  108758. */
  108759. intersectInPlace(csg: CSG): void;
  108760. /**
  108761. * Return a new CSG solid with solid and empty space switched. This solid is
  108762. * not modified.
  108763. * @returns A new CSG solid with solid and empty space switched
  108764. */
  108765. inverse(): CSG;
  108766. /**
  108767. * Inverses the CSG in place
  108768. */
  108769. inverseInPlace(): void;
  108770. /**
  108771. * This is used to keep meshes transformations so they can be restored
  108772. * when we build back a Babylon Mesh
  108773. * NB : All CSG operations are performed in world coordinates
  108774. * @param csg The CSG to copy the transform attributes from
  108775. * @returns This CSG
  108776. */
  108777. copyTransformAttributes(csg: CSG): CSG;
  108778. /**
  108779. * Build Raw mesh from CSG
  108780. * Coordinates here are in world space
  108781. * @param name The name of the mesh geometry
  108782. * @param scene The Scene
  108783. * @param keepSubMeshes Specifies if the submeshes should be kept
  108784. * @returns A new Mesh
  108785. */
  108786. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108787. /**
  108788. * Build Mesh from CSG taking material and transforms into account
  108789. * @param name The name of the Mesh
  108790. * @param material The material of the Mesh
  108791. * @param scene The Scene
  108792. * @param keepSubMeshes Specifies if submeshes should be kept
  108793. * @returns The new Mesh
  108794. */
  108795. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108796. }
  108797. }
  108798. declare module BABYLON {
  108799. /**
  108800. * Class used to create a trail following a mesh
  108801. */
  108802. export class TrailMesh extends Mesh {
  108803. private _generator;
  108804. private _autoStart;
  108805. private _running;
  108806. private _diameter;
  108807. private _length;
  108808. private _sectionPolygonPointsCount;
  108809. private _sectionVectors;
  108810. private _sectionNormalVectors;
  108811. private _beforeRenderObserver;
  108812. /**
  108813. * @constructor
  108814. * @param name The value used by scene.getMeshByName() to do a lookup.
  108815. * @param generator The mesh to generate a trail.
  108816. * @param scene The scene to add this mesh to.
  108817. * @param diameter Diameter of trailing mesh. Default is 1.
  108818. * @param length Length of trailing mesh. Default is 60.
  108819. * @param autoStart Automatically start trailing mesh. Default true.
  108820. */
  108821. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108822. /**
  108823. * "TrailMesh"
  108824. * @returns "TrailMesh"
  108825. */
  108826. getClassName(): string;
  108827. private _createMesh;
  108828. /**
  108829. * Start trailing mesh.
  108830. */
  108831. start(): void;
  108832. /**
  108833. * Stop trailing mesh.
  108834. */
  108835. stop(): void;
  108836. /**
  108837. * Update trailing mesh geometry.
  108838. */
  108839. update(): void;
  108840. /**
  108841. * Returns a new TrailMesh object.
  108842. * @param name is a string, the name given to the new mesh
  108843. * @param newGenerator use new generator object for cloned trail mesh
  108844. * @returns a new mesh
  108845. */
  108846. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108847. /**
  108848. * Serializes this trail mesh
  108849. * @param serializationObject object to write serialization to
  108850. */
  108851. serialize(serializationObject: any): void;
  108852. /**
  108853. * Parses a serialized trail mesh
  108854. * @param parsedMesh the serialized mesh
  108855. * @param scene the scene to create the trail mesh in
  108856. * @returns the created trail mesh
  108857. */
  108858. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108859. }
  108860. }
  108861. declare module BABYLON {
  108862. /**
  108863. * Class containing static functions to help procedurally build meshes
  108864. */
  108865. export class TorusKnotBuilder {
  108866. /**
  108867. * Creates a torus knot mesh
  108868. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108869. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108870. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108871. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108875. * @param name defines the name of the mesh
  108876. * @param options defines the options used to create the mesh
  108877. * @param scene defines the hosting scene
  108878. * @returns the torus knot mesh
  108879. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108880. */
  108881. static CreateTorusKnot(name: string, options: {
  108882. radius?: number;
  108883. tube?: number;
  108884. radialSegments?: number;
  108885. tubularSegments?: number;
  108886. p?: number;
  108887. q?: number;
  108888. updatable?: boolean;
  108889. sideOrientation?: number;
  108890. frontUVs?: Vector4;
  108891. backUVs?: Vector4;
  108892. }, scene: any): Mesh;
  108893. }
  108894. }
  108895. declare module BABYLON {
  108896. /**
  108897. * Polygon
  108898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108899. */
  108900. export class Polygon {
  108901. /**
  108902. * Creates a rectangle
  108903. * @param xmin bottom X coord
  108904. * @param ymin bottom Y coord
  108905. * @param xmax top X coord
  108906. * @param ymax top Y coord
  108907. * @returns points that make the resulting rectation
  108908. */
  108909. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108910. /**
  108911. * Creates a circle
  108912. * @param radius radius of circle
  108913. * @param cx scale in x
  108914. * @param cy scale in y
  108915. * @param numberOfSides number of sides that make up the circle
  108916. * @returns points that make the resulting circle
  108917. */
  108918. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108919. /**
  108920. * Creates a polygon from input string
  108921. * @param input Input polygon data
  108922. * @returns the parsed points
  108923. */
  108924. static Parse(input: string): Vector2[];
  108925. /**
  108926. * Starts building a polygon from x and y coordinates
  108927. * @param x x coordinate
  108928. * @param y y coordinate
  108929. * @returns the started path2
  108930. */
  108931. static StartingAt(x: number, y: number): Path2;
  108932. }
  108933. /**
  108934. * Builds a polygon
  108935. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108936. */
  108937. export class PolygonMeshBuilder {
  108938. private _points;
  108939. private _outlinepoints;
  108940. private _holes;
  108941. private _name;
  108942. private _scene;
  108943. private _epoints;
  108944. private _eholes;
  108945. private _addToepoint;
  108946. /**
  108947. * Babylon reference to the earcut plugin.
  108948. */
  108949. bjsEarcut: any;
  108950. /**
  108951. * Creates a PolygonMeshBuilder
  108952. * @param name name of the builder
  108953. * @param contours Path of the polygon
  108954. * @param scene scene to add to when creating the mesh
  108955. * @param earcutInjection can be used to inject your own earcut reference
  108956. */
  108957. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108958. /**
  108959. * Adds a whole within the polygon
  108960. * @param hole Array of points defining the hole
  108961. * @returns this
  108962. */
  108963. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108964. /**
  108965. * Creates the polygon
  108966. * @param updatable If the mesh should be updatable
  108967. * @param depth The depth of the mesh created
  108968. * @returns the created mesh
  108969. */
  108970. build(updatable?: boolean, depth?: number): Mesh;
  108971. /**
  108972. * Creates the polygon
  108973. * @param depth The depth of the mesh created
  108974. * @returns the created VertexData
  108975. */
  108976. buildVertexData(depth?: number): VertexData;
  108977. /**
  108978. * Adds a side to the polygon
  108979. * @param positions points that make the polygon
  108980. * @param normals normals of the polygon
  108981. * @param uvs uvs of the polygon
  108982. * @param indices indices of the polygon
  108983. * @param bounds bounds of the polygon
  108984. * @param points points of the polygon
  108985. * @param depth depth of the polygon
  108986. * @param flip flip of the polygon
  108987. */
  108988. private addSide;
  108989. }
  108990. }
  108991. declare module BABYLON {
  108992. /**
  108993. * Class containing static functions to help procedurally build meshes
  108994. */
  108995. export class PolygonBuilder {
  108996. /**
  108997. * Creates a polygon mesh
  108998. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108999. * * 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
  109000. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109003. * * Remember you can only change the shape positions, not their number when updating a polygon
  109004. * @param name defines the name of the mesh
  109005. * @param options defines the options used to create the mesh
  109006. * @param scene defines the hosting scene
  109007. * @param earcutInjection can be used to inject your own earcut reference
  109008. * @returns the polygon mesh
  109009. */
  109010. static CreatePolygon(name: string, options: {
  109011. shape: Vector3[];
  109012. holes?: Vector3[][];
  109013. depth?: number;
  109014. faceUV?: Vector4[];
  109015. faceColors?: Color4[];
  109016. updatable?: boolean;
  109017. sideOrientation?: number;
  109018. frontUVs?: Vector4;
  109019. backUVs?: Vector4;
  109020. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109021. /**
  109022. * Creates an extruded polygon mesh, with depth in the Y direction.
  109023. * * 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)
  109024. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109025. * @param name defines the name of the mesh
  109026. * @param options defines the options used to create the mesh
  109027. * @param scene defines the hosting scene
  109028. * @param earcutInjection can be used to inject your own earcut reference
  109029. * @returns the polygon mesh
  109030. */
  109031. static ExtrudePolygon(name: string, options: {
  109032. shape: Vector3[];
  109033. holes?: Vector3[][];
  109034. depth?: number;
  109035. faceUV?: Vector4[];
  109036. faceColors?: Color4[];
  109037. updatable?: boolean;
  109038. sideOrientation?: number;
  109039. frontUVs?: Vector4;
  109040. backUVs?: Vector4;
  109041. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109042. }
  109043. }
  109044. declare module BABYLON {
  109045. /**
  109046. * Class containing static functions to help procedurally build meshes
  109047. */
  109048. export class LatheBuilder {
  109049. /**
  109050. * Creates lathe mesh.
  109051. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109052. * * 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
  109053. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109054. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109055. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109056. * * 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
  109057. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109058. * * 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
  109059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109063. * @param name defines the name of the mesh
  109064. * @param options defines the options used to create the mesh
  109065. * @param scene defines the hosting scene
  109066. * @returns the lathe mesh
  109067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109068. */
  109069. static CreateLathe(name: string, options: {
  109070. shape: Vector3[];
  109071. radius?: number;
  109072. tessellation?: number;
  109073. clip?: number;
  109074. arc?: number;
  109075. closed?: boolean;
  109076. updatable?: boolean;
  109077. sideOrientation?: number;
  109078. frontUVs?: Vector4;
  109079. backUVs?: Vector4;
  109080. cap?: number;
  109081. invertUV?: boolean;
  109082. }, scene?: Nullable<Scene>): Mesh;
  109083. }
  109084. }
  109085. declare module BABYLON {
  109086. /**
  109087. * Class containing static functions to help procedurally build meshes
  109088. */
  109089. export class TubeBuilder {
  109090. /**
  109091. * Creates a tube mesh.
  109092. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109093. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109094. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109095. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109096. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109097. * * 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)
  109098. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109099. * * 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
  109100. * * 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
  109101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109103. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109105. * @param name defines the name of the mesh
  109106. * @param options defines the options used to create the mesh
  109107. * @param scene defines the hosting scene
  109108. * @returns the tube mesh
  109109. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109110. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109111. */
  109112. static CreateTube(name: string, options: {
  109113. path: Vector3[];
  109114. radius?: number;
  109115. tessellation?: number;
  109116. radiusFunction?: {
  109117. (i: number, distance: number): number;
  109118. };
  109119. cap?: number;
  109120. arc?: number;
  109121. updatable?: boolean;
  109122. sideOrientation?: number;
  109123. frontUVs?: Vector4;
  109124. backUVs?: Vector4;
  109125. instance?: Mesh;
  109126. invertUV?: boolean;
  109127. }, scene?: Nullable<Scene>): Mesh;
  109128. }
  109129. }
  109130. declare module BABYLON {
  109131. /**
  109132. * Class containing static functions to help procedurally build meshes
  109133. */
  109134. export class IcoSphereBuilder {
  109135. /**
  109136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109138. * * 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`)
  109139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109140. * * 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
  109141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109144. * @param name defines the name of the mesh
  109145. * @param options defines the options used to create the mesh
  109146. * @param scene defines the hosting scene
  109147. * @returns the icosahedron mesh
  109148. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109149. */
  109150. static CreateIcoSphere(name: string, options: {
  109151. radius?: number;
  109152. radiusX?: number;
  109153. radiusY?: number;
  109154. radiusZ?: number;
  109155. flat?: boolean;
  109156. subdivisions?: number;
  109157. sideOrientation?: number;
  109158. frontUVs?: Vector4;
  109159. backUVs?: Vector4;
  109160. updatable?: boolean;
  109161. }, scene?: Nullable<Scene>): Mesh;
  109162. }
  109163. }
  109164. declare module BABYLON {
  109165. /**
  109166. * Class containing static functions to help procedurally build meshes
  109167. */
  109168. export class DecalBuilder {
  109169. /**
  109170. * Creates a decal mesh.
  109171. * 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
  109172. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109173. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109174. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109175. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109176. * @param name defines the name of the mesh
  109177. * @param sourceMesh defines the mesh where the decal must be applied
  109178. * @param options defines the options used to create the mesh
  109179. * @param scene defines the hosting scene
  109180. * @returns the decal mesh
  109181. * @see https://doc.babylonjs.com/how_to/decals
  109182. */
  109183. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109184. position?: Vector3;
  109185. normal?: Vector3;
  109186. size?: Vector3;
  109187. angle?: number;
  109188. }): Mesh;
  109189. }
  109190. }
  109191. declare module BABYLON {
  109192. /**
  109193. * Class containing static functions to help procedurally build meshes
  109194. */
  109195. export class MeshBuilder {
  109196. /**
  109197. * Creates a box mesh
  109198. * * The parameter `size` sets the size (float) of each box side (default 1)
  109199. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109200. * * 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)
  109201. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109205. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109206. * @param name defines the name of the mesh
  109207. * @param options defines the options used to create the mesh
  109208. * @param scene defines the hosting scene
  109209. * @returns the box mesh
  109210. */
  109211. static CreateBox(name: string, options: {
  109212. size?: number;
  109213. width?: number;
  109214. height?: number;
  109215. depth?: number;
  109216. faceUV?: Vector4[];
  109217. faceColors?: Color4[];
  109218. sideOrientation?: number;
  109219. frontUVs?: Vector4;
  109220. backUVs?: Vector4;
  109221. updatable?: boolean;
  109222. }, scene?: Nullable<Scene>): Mesh;
  109223. /**
  109224. * Creates a sphere mesh
  109225. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109226. * * 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`)
  109227. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109228. * * 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
  109229. * * 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)
  109230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109233. * @param name defines the name of the mesh
  109234. * @param options defines the options used to create the mesh
  109235. * @param scene defines the hosting scene
  109236. * @returns the sphere mesh
  109237. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109238. */
  109239. static CreateSphere(name: string, options: {
  109240. segments?: number;
  109241. diameter?: number;
  109242. diameterX?: number;
  109243. diameterY?: number;
  109244. diameterZ?: number;
  109245. arc?: number;
  109246. slice?: number;
  109247. sideOrientation?: number;
  109248. frontUVs?: Vector4;
  109249. backUVs?: Vector4;
  109250. updatable?: boolean;
  109251. }, scene?: Nullable<Scene>): Mesh;
  109252. /**
  109253. * Creates a plane polygonal mesh. By default, this is a disc
  109254. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109255. * * 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
  109256. * * 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
  109257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109260. * @param name defines the name of the mesh
  109261. * @param options defines the options used to create the mesh
  109262. * @param scene defines the hosting scene
  109263. * @returns the plane polygonal mesh
  109264. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109265. */
  109266. static CreateDisc(name: string, options: {
  109267. radius?: number;
  109268. tessellation?: number;
  109269. arc?: number;
  109270. updatable?: boolean;
  109271. sideOrientation?: number;
  109272. frontUVs?: Vector4;
  109273. backUVs?: Vector4;
  109274. }, scene?: Nullable<Scene>): Mesh;
  109275. /**
  109276. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109277. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109278. * * 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`)
  109279. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109280. * * 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
  109281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109284. * @param name defines the name of the mesh
  109285. * @param options defines the options used to create the mesh
  109286. * @param scene defines the hosting scene
  109287. * @returns the icosahedron mesh
  109288. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109289. */
  109290. static CreateIcoSphere(name: string, options: {
  109291. radius?: number;
  109292. radiusX?: number;
  109293. radiusY?: number;
  109294. radiusZ?: number;
  109295. flat?: boolean;
  109296. subdivisions?: number;
  109297. sideOrientation?: number;
  109298. frontUVs?: Vector4;
  109299. backUVs?: Vector4;
  109300. updatable?: boolean;
  109301. }, scene?: Nullable<Scene>): Mesh;
  109302. /**
  109303. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109304. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109305. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109306. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109307. * * 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
  109308. * * 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
  109309. * * 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
  109310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109313. * * 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
  109314. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109315. * * 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
  109316. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109318. * @param name defines the name of the mesh
  109319. * @param options defines the options used to create the mesh
  109320. * @param scene defines the hosting scene
  109321. * @returns the ribbon mesh
  109322. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109324. */
  109325. static CreateRibbon(name: string, options: {
  109326. pathArray: Vector3[][];
  109327. closeArray?: boolean;
  109328. closePath?: boolean;
  109329. offset?: number;
  109330. updatable?: boolean;
  109331. sideOrientation?: number;
  109332. frontUVs?: Vector4;
  109333. backUVs?: Vector4;
  109334. instance?: Mesh;
  109335. invertUV?: boolean;
  109336. uvs?: Vector2[];
  109337. colors?: Color4[];
  109338. }, scene?: Nullable<Scene>): Mesh;
  109339. /**
  109340. * Creates a cylinder or a cone mesh
  109341. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109342. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109343. * * 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.
  109344. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109345. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109346. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109347. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109348. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109349. * * 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).
  109350. * * 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
  109351. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109352. * * 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
  109353. * * 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.
  109354. * * If `enclose` is false, a ring surface is one element.
  109355. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109356. * * 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
  109357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109360. * @param name defines the name of the mesh
  109361. * @param options defines the options used to create the mesh
  109362. * @param scene defines the hosting scene
  109363. * @returns the cylinder mesh
  109364. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109365. */
  109366. static CreateCylinder(name: string, options: {
  109367. height?: number;
  109368. diameterTop?: number;
  109369. diameterBottom?: number;
  109370. diameter?: number;
  109371. tessellation?: number;
  109372. subdivisions?: number;
  109373. arc?: number;
  109374. faceColors?: Color4[];
  109375. faceUV?: Vector4[];
  109376. updatable?: boolean;
  109377. hasRings?: boolean;
  109378. enclose?: boolean;
  109379. sideOrientation?: number;
  109380. frontUVs?: Vector4;
  109381. backUVs?: Vector4;
  109382. }, scene?: Nullable<Scene>): Mesh;
  109383. /**
  109384. * Creates a torus mesh
  109385. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109386. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109387. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109391. * @param name defines the name of the mesh
  109392. * @param options defines the options used to create the mesh
  109393. * @param scene defines the hosting scene
  109394. * @returns the torus mesh
  109395. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109396. */
  109397. static CreateTorus(name: string, options: {
  109398. diameter?: number;
  109399. thickness?: number;
  109400. tessellation?: number;
  109401. updatable?: boolean;
  109402. sideOrientation?: number;
  109403. frontUVs?: Vector4;
  109404. backUVs?: Vector4;
  109405. }, scene?: Nullable<Scene>): Mesh;
  109406. /**
  109407. * Creates a torus knot mesh
  109408. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109409. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109410. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109411. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109415. * @param name defines the name of the mesh
  109416. * @param options defines the options used to create the mesh
  109417. * @param scene defines the hosting scene
  109418. * @returns the torus knot mesh
  109419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109420. */
  109421. static CreateTorusKnot(name: string, options: {
  109422. radius?: number;
  109423. tube?: number;
  109424. radialSegments?: number;
  109425. tubularSegments?: number;
  109426. p?: number;
  109427. q?: number;
  109428. updatable?: boolean;
  109429. sideOrientation?: number;
  109430. frontUVs?: Vector4;
  109431. backUVs?: Vector4;
  109432. }, scene?: Nullable<Scene>): Mesh;
  109433. /**
  109434. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109435. * * 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
  109436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109437. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109438. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109439. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109441. * * 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
  109442. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109445. * @param name defines the name of the new line system
  109446. * @param options defines the options used to create the line system
  109447. * @param scene defines the hosting scene
  109448. * @returns a new line system mesh
  109449. */
  109450. static CreateLineSystem(name: string, options: {
  109451. lines: Vector3[][];
  109452. updatable?: boolean;
  109453. instance?: Nullable<LinesMesh>;
  109454. colors?: Nullable<Color4[][]>;
  109455. useVertexAlpha?: boolean;
  109456. }, scene: Nullable<Scene>): LinesMesh;
  109457. /**
  109458. * Creates a line mesh
  109459. * 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
  109460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109461. * * The parameter `points` is an array successive Vector3
  109462. * * 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
  109463. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109464. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109465. * * When updating an instance, remember that only point positions can change, not the number of points
  109466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109468. * @param name defines the name of the new line system
  109469. * @param options defines the options used to create the line system
  109470. * @param scene defines the hosting scene
  109471. * @returns a new line mesh
  109472. */
  109473. static CreateLines(name: string, options: {
  109474. points: Vector3[];
  109475. updatable?: boolean;
  109476. instance?: Nullable<LinesMesh>;
  109477. colors?: Color4[];
  109478. useVertexAlpha?: boolean;
  109479. }, scene?: Nullable<Scene>): LinesMesh;
  109480. /**
  109481. * Creates a dashed line mesh
  109482. * * 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
  109483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109484. * * The parameter `points` is an array successive Vector3
  109485. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109486. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109487. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109488. * * 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
  109489. * * When updating an instance, remember that only point positions can change, not the number of points
  109490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109491. * @param name defines the name of the mesh
  109492. * @param options defines the options used to create the mesh
  109493. * @param scene defines the hosting scene
  109494. * @returns the dashed line mesh
  109495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109496. */
  109497. static CreateDashedLines(name: string, options: {
  109498. points: Vector3[];
  109499. dashSize?: number;
  109500. gapSize?: number;
  109501. dashNb?: number;
  109502. updatable?: boolean;
  109503. instance?: LinesMesh;
  109504. }, scene?: Nullable<Scene>): LinesMesh;
  109505. /**
  109506. * 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.
  109507. * * 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.
  109508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109509. * * 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.
  109510. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109511. * * 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
  109512. * * 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
  109513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109518. * @param name defines the name of the mesh
  109519. * @param options defines the options used to create the mesh
  109520. * @param scene defines the hosting scene
  109521. * @returns the extruded shape mesh
  109522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109524. */
  109525. static ExtrudeShape(name: string, options: {
  109526. shape: Vector3[];
  109527. path: Vector3[];
  109528. scale?: number;
  109529. rotation?: number;
  109530. cap?: number;
  109531. updatable?: boolean;
  109532. sideOrientation?: number;
  109533. frontUVs?: Vector4;
  109534. backUVs?: Vector4;
  109535. instance?: Mesh;
  109536. invertUV?: boolean;
  109537. }, scene?: Nullable<Scene>): Mesh;
  109538. /**
  109539. * Creates an custom extruded shape mesh.
  109540. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109541. * * 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.
  109542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109543. * * 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
  109544. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109545. * * 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
  109546. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109547. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109548. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109549. * * 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
  109550. * * 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
  109551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109556. * @param name defines the name of the mesh
  109557. * @param options defines the options used to create the mesh
  109558. * @param scene defines the hosting scene
  109559. * @returns the custom extruded shape mesh
  109560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109563. */
  109564. static ExtrudeShapeCustom(name: string, options: {
  109565. shape: Vector3[];
  109566. path: Vector3[];
  109567. scaleFunction?: any;
  109568. rotationFunction?: any;
  109569. ribbonCloseArray?: boolean;
  109570. ribbonClosePath?: boolean;
  109571. cap?: number;
  109572. updatable?: boolean;
  109573. sideOrientation?: number;
  109574. frontUVs?: Vector4;
  109575. backUVs?: Vector4;
  109576. instance?: Mesh;
  109577. invertUV?: boolean;
  109578. }, scene?: Nullable<Scene>): Mesh;
  109579. /**
  109580. * Creates lathe mesh.
  109581. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109582. * * 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
  109583. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109584. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109585. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109586. * * 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
  109587. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109588. * * 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
  109589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109593. * @param name defines the name of the mesh
  109594. * @param options defines the options used to create the mesh
  109595. * @param scene defines the hosting scene
  109596. * @returns the lathe mesh
  109597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109598. */
  109599. static CreateLathe(name: string, options: {
  109600. shape: Vector3[];
  109601. radius?: number;
  109602. tessellation?: number;
  109603. clip?: number;
  109604. arc?: number;
  109605. closed?: boolean;
  109606. updatable?: boolean;
  109607. sideOrientation?: number;
  109608. frontUVs?: Vector4;
  109609. backUVs?: Vector4;
  109610. cap?: number;
  109611. invertUV?: boolean;
  109612. }, scene?: Nullable<Scene>): Mesh;
  109613. /**
  109614. * Creates a plane mesh
  109615. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109616. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109617. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109621. * @param name defines the name of the mesh
  109622. * @param options defines the options used to create the mesh
  109623. * @param scene defines the hosting scene
  109624. * @returns the plane mesh
  109625. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109626. */
  109627. static CreatePlane(name: string, options: {
  109628. size?: number;
  109629. width?: number;
  109630. height?: number;
  109631. sideOrientation?: number;
  109632. frontUVs?: Vector4;
  109633. backUVs?: Vector4;
  109634. updatable?: boolean;
  109635. sourcePlane?: Plane;
  109636. }, scene?: Nullable<Scene>): Mesh;
  109637. /**
  109638. * Creates a ground mesh
  109639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109642. * @param name defines the name of the mesh
  109643. * @param options defines the options used to create the mesh
  109644. * @param scene defines the hosting scene
  109645. * @returns the ground mesh
  109646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109647. */
  109648. static CreateGround(name: string, options: {
  109649. width?: number;
  109650. height?: number;
  109651. subdivisions?: number;
  109652. subdivisionsX?: number;
  109653. subdivisionsY?: number;
  109654. updatable?: boolean;
  109655. }, scene?: Nullable<Scene>): Mesh;
  109656. /**
  109657. * Creates a tiled ground mesh
  109658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109660. * * 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
  109661. * * 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
  109662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109663. * @param name defines the name of the mesh
  109664. * @param options defines the options used to create the mesh
  109665. * @param scene defines the hosting scene
  109666. * @returns the tiled ground mesh
  109667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109668. */
  109669. static CreateTiledGround(name: string, options: {
  109670. xmin: number;
  109671. zmin: number;
  109672. xmax: number;
  109673. zmax: number;
  109674. subdivisions?: {
  109675. w: number;
  109676. h: number;
  109677. };
  109678. precision?: {
  109679. w: number;
  109680. h: number;
  109681. };
  109682. updatable?: boolean;
  109683. }, scene?: Nullable<Scene>): Mesh;
  109684. /**
  109685. * Creates a ground mesh from a height map
  109686. * * The parameter `url` sets the URL of the height map image resource.
  109687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109691. * * 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.
  109692. * * 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).
  109693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109695. * @param name defines the name of the mesh
  109696. * @param url defines the url to the height map
  109697. * @param options defines the options used to create the mesh
  109698. * @param scene defines the hosting scene
  109699. * @returns the ground mesh
  109700. * @see https://doc.babylonjs.com/babylon101/height_map
  109701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109702. */
  109703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109704. width?: number;
  109705. height?: number;
  109706. subdivisions?: number;
  109707. minHeight?: number;
  109708. maxHeight?: number;
  109709. colorFilter?: Color3;
  109710. alphaFilter?: number;
  109711. updatable?: boolean;
  109712. onReady?: (mesh: GroundMesh) => void;
  109713. }, scene?: Nullable<Scene>): GroundMesh;
  109714. /**
  109715. * Creates a polygon mesh
  109716. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109717. * * 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
  109718. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109721. * * Remember you can only change the shape positions, not their number when updating a polygon
  109722. * @param name defines the name of the mesh
  109723. * @param options defines the options used to create the mesh
  109724. * @param scene defines the hosting scene
  109725. * @param earcutInjection can be used to inject your own earcut reference
  109726. * @returns the polygon mesh
  109727. */
  109728. static CreatePolygon(name: string, options: {
  109729. shape: Vector3[];
  109730. holes?: Vector3[][];
  109731. depth?: number;
  109732. faceUV?: Vector4[];
  109733. faceColors?: Color4[];
  109734. updatable?: boolean;
  109735. sideOrientation?: number;
  109736. frontUVs?: Vector4;
  109737. backUVs?: Vector4;
  109738. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109739. /**
  109740. * Creates an extruded polygon mesh, with depth in the Y direction.
  109741. * * 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)
  109742. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109743. * @param name defines the name of the mesh
  109744. * @param options defines the options used to create the mesh
  109745. * @param scene defines the hosting scene
  109746. * @param earcutInjection can be used to inject your own earcut reference
  109747. * @returns the polygon mesh
  109748. */
  109749. static ExtrudePolygon(name: string, options: {
  109750. shape: Vector3[];
  109751. holes?: Vector3[][];
  109752. depth?: number;
  109753. faceUV?: Vector4[];
  109754. faceColors?: Color4[];
  109755. updatable?: boolean;
  109756. sideOrientation?: number;
  109757. frontUVs?: Vector4;
  109758. backUVs?: Vector4;
  109759. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109760. /**
  109761. * Creates a tube mesh.
  109762. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109763. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109764. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109765. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109766. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109767. * * 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)
  109768. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109769. * * 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
  109770. * * 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
  109771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109775. * @param name defines the name of the mesh
  109776. * @param options defines the options used to create the mesh
  109777. * @param scene defines the hosting scene
  109778. * @returns the tube mesh
  109779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109780. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109781. */
  109782. static CreateTube(name: string, options: {
  109783. path: Vector3[];
  109784. radius?: number;
  109785. tessellation?: number;
  109786. radiusFunction?: {
  109787. (i: number, distance: number): number;
  109788. };
  109789. cap?: number;
  109790. arc?: number;
  109791. updatable?: boolean;
  109792. sideOrientation?: number;
  109793. frontUVs?: Vector4;
  109794. backUVs?: Vector4;
  109795. instance?: Mesh;
  109796. invertUV?: boolean;
  109797. }, scene?: Nullable<Scene>): Mesh;
  109798. /**
  109799. * Creates a polyhedron mesh
  109800. * * 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
  109801. * * The parameter `size` (positive float, default 1) sets the polygon size
  109802. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109803. * * 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`
  109804. * * 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
  109805. * * 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)`)
  109806. * * 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
  109807. * * 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
  109808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109811. * @param name defines the name of the mesh
  109812. * @param options defines the options used to create the mesh
  109813. * @param scene defines the hosting scene
  109814. * @returns the polyhedron mesh
  109815. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109816. */
  109817. static CreatePolyhedron(name: string, options: {
  109818. type?: number;
  109819. size?: number;
  109820. sizeX?: number;
  109821. sizeY?: number;
  109822. sizeZ?: number;
  109823. custom?: any;
  109824. faceUV?: Vector4[];
  109825. faceColors?: Color4[];
  109826. flat?: boolean;
  109827. updatable?: boolean;
  109828. sideOrientation?: number;
  109829. frontUVs?: Vector4;
  109830. backUVs?: Vector4;
  109831. }, scene?: Nullable<Scene>): Mesh;
  109832. /**
  109833. * Creates a decal mesh.
  109834. * 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
  109835. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109836. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109837. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109838. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109839. * @param name defines the name of the mesh
  109840. * @param sourceMesh defines the mesh where the decal must be applied
  109841. * @param options defines the options used to create the mesh
  109842. * @param scene defines the hosting scene
  109843. * @returns the decal mesh
  109844. * @see https://doc.babylonjs.com/how_to/decals
  109845. */
  109846. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109847. position?: Vector3;
  109848. normal?: Vector3;
  109849. size?: Vector3;
  109850. angle?: number;
  109851. }): Mesh;
  109852. }
  109853. }
  109854. declare module BABYLON {
  109855. /**
  109856. * A simplifier interface for future simplification implementations
  109857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109858. */
  109859. export interface ISimplifier {
  109860. /**
  109861. * Simplification of a given mesh according to the given settings.
  109862. * Since this requires computation, it is assumed that the function runs async.
  109863. * @param settings The settings of the simplification, including quality and distance
  109864. * @param successCallback A callback that will be called after the mesh was simplified.
  109865. * @param errorCallback in case of an error, this callback will be called. optional.
  109866. */
  109867. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109868. }
  109869. /**
  109870. * Expected simplification settings.
  109871. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109872. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109873. */
  109874. export interface ISimplificationSettings {
  109875. /**
  109876. * Gets or sets the expected quality
  109877. */
  109878. quality: number;
  109879. /**
  109880. * Gets or sets the distance when this optimized version should be used
  109881. */
  109882. distance: number;
  109883. /**
  109884. * Gets an already optimized mesh
  109885. */
  109886. optimizeMesh?: boolean;
  109887. }
  109888. /**
  109889. * Class used to specify simplification options
  109890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109891. */
  109892. export class SimplificationSettings implements ISimplificationSettings {
  109893. /** expected quality */
  109894. quality: number;
  109895. /** distance when this optimized version should be used */
  109896. distance: number;
  109897. /** already optimized mesh */
  109898. optimizeMesh?: boolean | undefined;
  109899. /**
  109900. * Creates a SimplificationSettings
  109901. * @param quality expected quality
  109902. * @param distance distance when this optimized version should be used
  109903. * @param optimizeMesh already optimized mesh
  109904. */
  109905. constructor(
  109906. /** expected quality */
  109907. quality: number,
  109908. /** distance when this optimized version should be used */
  109909. distance: number,
  109910. /** already optimized mesh */
  109911. optimizeMesh?: boolean | undefined);
  109912. }
  109913. /**
  109914. * Interface used to define a simplification task
  109915. */
  109916. export interface ISimplificationTask {
  109917. /**
  109918. * Array of settings
  109919. */
  109920. settings: Array<ISimplificationSettings>;
  109921. /**
  109922. * Simplification type
  109923. */
  109924. simplificationType: SimplificationType;
  109925. /**
  109926. * Mesh to simplify
  109927. */
  109928. mesh: Mesh;
  109929. /**
  109930. * Callback called on success
  109931. */
  109932. successCallback?: () => void;
  109933. /**
  109934. * Defines if parallel processing can be used
  109935. */
  109936. parallelProcessing: boolean;
  109937. }
  109938. /**
  109939. * Queue used to order the simplification tasks
  109940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109941. */
  109942. export class SimplificationQueue {
  109943. private _simplificationArray;
  109944. /**
  109945. * Gets a boolean indicating that the process is still running
  109946. */
  109947. running: boolean;
  109948. /**
  109949. * Creates a new queue
  109950. */
  109951. constructor();
  109952. /**
  109953. * Adds a new simplification task
  109954. * @param task defines a task to add
  109955. */
  109956. addTask(task: ISimplificationTask): void;
  109957. /**
  109958. * Execute next task
  109959. */
  109960. executeNext(): void;
  109961. /**
  109962. * Execute a simplification task
  109963. * @param task defines the task to run
  109964. */
  109965. runSimplification(task: ISimplificationTask): void;
  109966. private getSimplifier;
  109967. }
  109968. /**
  109969. * The implemented types of simplification
  109970. * At the moment only Quadratic Error Decimation is implemented
  109971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109972. */
  109973. export enum SimplificationType {
  109974. /** Quadratic error decimation */
  109975. QUADRATIC = 0
  109976. }
  109977. }
  109978. declare module BABYLON {
  109979. interface Scene {
  109980. /** @hidden (Backing field) */
  109981. _simplificationQueue: SimplificationQueue;
  109982. /**
  109983. * Gets or sets the simplification queue attached to the scene
  109984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109985. */
  109986. simplificationQueue: SimplificationQueue;
  109987. }
  109988. interface Mesh {
  109989. /**
  109990. * Simplify the mesh according to the given array of settings.
  109991. * Function will return immediately and will simplify async
  109992. * @param settings a collection of simplification settings
  109993. * @param parallelProcessing should all levels calculate parallel or one after the other
  109994. * @param simplificationType the type of simplification to run
  109995. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  109996. * @returns the current mesh
  109997. */
  109998. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  109999. }
  110000. /**
  110001. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110002. * created in a scene
  110003. */
  110004. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110005. /**
  110006. * The component name helpfull to identify the component in the list of scene components.
  110007. */
  110008. readonly name: string;
  110009. /**
  110010. * The scene the component belongs to.
  110011. */
  110012. scene: Scene;
  110013. /**
  110014. * Creates a new instance of the component for the given scene
  110015. * @param scene Defines the scene to register the component in
  110016. */
  110017. constructor(scene: Scene);
  110018. /**
  110019. * Registers the component in a given scene
  110020. */
  110021. register(): void;
  110022. /**
  110023. * Rebuilds the elements related to this component in case of
  110024. * context lost for instance.
  110025. */
  110026. rebuild(): void;
  110027. /**
  110028. * Disposes the component and the associated ressources
  110029. */
  110030. dispose(): void;
  110031. private _beforeCameraUpdate;
  110032. }
  110033. }
  110034. declare module BABYLON {
  110035. /**
  110036. * Class used to enable access to IndexedDB
  110037. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110038. */
  110039. export class Database implements IOfflineProvider {
  110040. private _callbackManifestChecked;
  110041. private _currentSceneUrl;
  110042. private _db;
  110043. private _enableSceneOffline;
  110044. private _enableTexturesOffline;
  110045. private _manifestVersionFound;
  110046. private _mustUpdateRessources;
  110047. private _hasReachedQuota;
  110048. private _isSupported;
  110049. private _idbFactory;
  110050. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110051. private static IsUASupportingBlobStorage;
  110052. /**
  110053. * Gets a boolean indicating if Database storate is enabled (off by default)
  110054. */
  110055. static IDBStorageEnabled: boolean;
  110056. /**
  110057. * Gets a boolean indicating if scene must be saved in the database
  110058. */
  110059. readonly enableSceneOffline: boolean;
  110060. /**
  110061. * Gets a boolean indicating if textures must be saved in the database
  110062. */
  110063. readonly enableTexturesOffline: boolean;
  110064. /**
  110065. * Creates a new Database
  110066. * @param urlToScene defines the url to load the scene
  110067. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110068. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110069. */
  110070. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110071. private static _ParseURL;
  110072. private static _ReturnFullUrlLocation;
  110073. private _checkManifestFile;
  110074. /**
  110075. * Open the database and make it available
  110076. * @param successCallback defines the callback to call on success
  110077. * @param errorCallback defines the callback to call on error
  110078. */
  110079. open(successCallback: () => void, errorCallback: () => void): void;
  110080. /**
  110081. * Loads an image from the database
  110082. * @param url defines the url to load from
  110083. * @param image defines the target DOM image
  110084. */
  110085. loadImage(url: string, image: HTMLImageElement): void;
  110086. private _loadImageFromDBAsync;
  110087. private _saveImageIntoDBAsync;
  110088. private _checkVersionFromDB;
  110089. private _loadVersionFromDBAsync;
  110090. private _saveVersionIntoDBAsync;
  110091. /**
  110092. * Loads a file from database
  110093. * @param url defines the URL to load from
  110094. * @param sceneLoaded defines a callback to call on success
  110095. * @param progressCallBack defines a callback to call when progress changed
  110096. * @param errorCallback defines a callback to call on error
  110097. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110098. */
  110099. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110100. private _loadFileAsync;
  110101. private _saveFileAsync;
  110102. /**
  110103. * Validates if xhr data is correct
  110104. * @param xhr defines the request to validate
  110105. * @param dataType defines the expected data type
  110106. * @returns true if data is correct
  110107. */
  110108. private static _ValidateXHRData;
  110109. }
  110110. }
  110111. declare module BABYLON {
  110112. /** @hidden */
  110113. export var gpuUpdateParticlesPixelShader: {
  110114. name: string;
  110115. shader: string;
  110116. };
  110117. }
  110118. declare module BABYLON {
  110119. /** @hidden */
  110120. export var gpuUpdateParticlesVertexShader: {
  110121. name: string;
  110122. shader: string;
  110123. };
  110124. }
  110125. declare module BABYLON {
  110126. /** @hidden */
  110127. export var clipPlaneFragmentDeclaration2: {
  110128. name: string;
  110129. shader: string;
  110130. };
  110131. }
  110132. declare module BABYLON {
  110133. /** @hidden */
  110134. export var gpuRenderParticlesPixelShader: {
  110135. name: string;
  110136. shader: string;
  110137. };
  110138. }
  110139. declare module BABYLON {
  110140. /** @hidden */
  110141. export var clipPlaneVertexDeclaration2: {
  110142. name: string;
  110143. shader: string;
  110144. };
  110145. }
  110146. declare module BABYLON {
  110147. /** @hidden */
  110148. export var gpuRenderParticlesVertexShader: {
  110149. name: string;
  110150. shader: string;
  110151. };
  110152. }
  110153. declare module BABYLON {
  110154. /**
  110155. * This represents a GPU particle system in Babylon
  110156. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110157. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110158. */
  110159. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110160. /**
  110161. * The layer mask we are rendering the particles through.
  110162. */
  110163. layerMask: number;
  110164. private _capacity;
  110165. private _activeCount;
  110166. private _currentActiveCount;
  110167. private _accumulatedCount;
  110168. private _renderEffect;
  110169. private _updateEffect;
  110170. private _buffer0;
  110171. private _buffer1;
  110172. private _spriteBuffer;
  110173. private _updateVAO;
  110174. private _renderVAO;
  110175. private _targetIndex;
  110176. private _sourceBuffer;
  110177. private _targetBuffer;
  110178. private _engine;
  110179. private _currentRenderId;
  110180. private _started;
  110181. private _stopped;
  110182. private _timeDelta;
  110183. private _randomTexture;
  110184. private _randomTexture2;
  110185. private _attributesStrideSize;
  110186. private _updateEffectOptions;
  110187. private _randomTextureSize;
  110188. private _actualFrame;
  110189. private readonly _rawTextureWidth;
  110190. /**
  110191. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110192. */
  110193. static readonly IsSupported: boolean;
  110194. /**
  110195. * An event triggered when the system is disposed.
  110196. */
  110197. onDisposeObservable: Observable<GPUParticleSystem>;
  110198. /**
  110199. * Gets the maximum number of particles active at the same time.
  110200. * @returns The max number of active particles.
  110201. */
  110202. getCapacity(): number;
  110203. /**
  110204. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110205. * to override the particles.
  110206. */
  110207. forceDepthWrite: boolean;
  110208. /**
  110209. * Gets or set the number of active particles
  110210. */
  110211. activeParticleCount: number;
  110212. private _preWarmDone;
  110213. /**
  110214. * Is this system ready to be used/rendered
  110215. * @return true if the system is ready
  110216. */
  110217. isReady(): boolean;
  110218. /**
  110219. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110220. * @returns True if it has been started, otherwise false.
  110221. */
  110222. isStarted(): boolean;
  110223. /**
  110224. * Starts the particle system and begins to emit
  110225. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110226. */
  110227. start(delay?: number): void;
  110228. /**
  110229. * Stops the particle system.
  110230. */
  110231. stop(): void;
  110232. /**
  110233. * Remove all active particles
  110234. */
  110235. reset(): void;
  110236. /**
  110237. * Returns the string "GPUParticleSystem"
  110238. * @returns a string containing the class name
  110239. */
  110240. getClassName(): string;
  110241. private _colorGradientsTexture;
  110242. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110243. /**
  110244. * Adds a new color gradient
  110245. * @param gradient defines the gradient to use (between 0 and 1)
  110246. * @param color1 defines the color to affect to the specified gradient
  110247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110248. * @returns the current particle system
  110249. */
  110250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110251. /**
  110252. * Remove a specific color gradient
  110253. * @param gradient defines the gradient to remove
  110254. * @returns the current particle system
  110255. */
  110256. removeColorGradient(gradient: number): GPUParticleSystem;
  110257. private _angularSpeedGradientsTexture;
  110258. private _sizeGradientsTexture;
  110259. private _velocityGradientsTexture;
  110260. private _limitVelocityGradientsTexture;
  110261. private _dragGradientsTexture;
  110262. private _addFactorGradient;
  110263. /**
  110264. * Adds a new size gradient
  110265. * @param gradient defines the gradient to use (between 0 and 1)
  110266. * @param factor defines the size factor to affect to the specified gradient
  110267. * @returns the current particle system
  110268. */
  110269. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110270. /**
  110271. * Remove a specific size gradient
  110272. * @param gradient defines the gradient to remove
  110273. * @returns the current particle system
  110274. */
  110275. removeSizeGradient(gradient: number): GPUParticleSystem;
  110276. /**
  110277. * Adds a new angular speed gradient
  110278. * @param gradient defines the gradient to use (between 0 and 1)
  110279. * @param factor defines the angular speed to affect to the specified gradient
  110280. * @returns the current particle system
  110281. */
  110282. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110283. /**
  110284. * Remove a specific angular speed gradient
  110285. * @param gradient defines the gradient to remove
  110286. * @returns the current particle system
  110287. */
  110288. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110289. /**
  110290. * Adds a new velocity gradient
  110291. * @param gradient defines the gradient to use (between 0 and 1)
  110292. * @param factor defines the velocity to affect to the specified gradient
  110293. * @returns the current particle system
  110294. */
  110295. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110296. /**
  110297. * Remove a specific velocity gradient
  110298. * @param gradient defines the gradient to remove
  110299. * @returns the current particle system
  110300. */
  110301. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110302. /**
  110303. * Adds a new limit velocity gradient
  110304. * @param gradient defines the gradient to use (between 0 and 1)
  110305. * @param factor defines the limit velocity value to affect to the specified gradient
  110306. * @returns the current particle system
  110307. */
  110308. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110309. /**
  110310. * Remove a specific limit velocity gradient
  110311. * @param gradient defines the gradient to remove
  110312. * @returns the current particle system
  110313. */
  110314. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110315. /**
  110316. * Adds a new drag gradient
  110317. * @param gradient defines the gradient to use (between 0 and 1)
  110318. * @param factor defines the drag value to affect to the specified gradient
  110319. * @returns the current particle system
  110320. */
  110321. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110322. /**
  110323. * Remove a specific drag gradient
  110324. * @param gradient defines the gradient to remove
  110325. * @returns the current particle system
  110326. */
  110327. removeDragGradient(gradient: number): GPUParticleSystem;
  110328. /**
  110329. * Not supported by GPUParticleSystem
  110330. * @param gradient defines the gradient to use (between 0 and 1)
  110331. * @param factor defines the emit rate value to affect to the specified gradient
  110332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110333. * @returns the current particle system
  110334. */
  110335. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110336. /**
  110337. * Not supported by GPUParticleSystem
  110338. * @param gradient defines the gradient to remove
  110339. * @returns the current particle system
  110340. */
  110341. removeEmitRateGradient(gradient: number): IParticleSystem;
  110342. /**
  110343. * Not supported by GPUParticleSystem
  110344. * @param gradient defines the gradient to use (between 0 and 1)
  110345. * @param factor defines the start size value to affect to the specified gradient
  110346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110347. * @returns the current particle system
  110348. */
  110349. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110350. /**
  110351. * Not supported by GPUParticleSystem
  110352. * @param gradient defines the gradient to remove
  110353. * @returns the current particle system
  110354. */
  110355. removeStartSizeGradient(gradient: number): IParticleSystem;
  110356. /**
  110357. * Not supported by GPUParticleSystem
  110358. * @param gradient defines the gradient to use (between 0 and 1)
  110359. * @param min defines the color remap minimal range
  110360. * @param max defines the color remap maximal range
  110361. * @returns the current particle system
  110362. */
  110363. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110364. /**
  110365. * Not supported by GPUParticleSystem
  110366. * @param gradient defines the gradient to remove
  110367. * @returns the current particle system
  110368. */
  110369. removeColorRemapGradient(): IParticleSystem;
  110370. /**
  110371. * Not supported by GPUParticleSystem
  110372. * @param gradient defines the gradient to use (between 0 and 1)
  110373. * @param min defines the alpha remap minimal range
  110374. * @param max defines the alpha remap maximal range
  110375. * @returns the current particle system
  110376. */
  110377. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110378. /**
  110379. * Not supported by GPUParticleSystem
  110380. * @param gradient defines the gradient to remove
  110381. * @returns the current particle system
  110382. */
  110383. removeAlphaRemapGradient(): IParticleSystem;
  110384. /**
  110385. * Not supported by GPUParticleSystem
  110386. * @param gradient defines the gradient to use (between 0 and 1)
  110387. * @param color defines the color to affect to the specified gradient
  110388. * @returns the current particle system
  110389. */
  110390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110391. /**
  110392. * Not supported by GPUParticleSystem
  110393. * @param gradient defines the gradient to remove
  110394. * @returns the current particle system
  110395. */
  110396. removeRampGradient(): IParticleSystem;
  110397. /**
  110398. * Not supported by GPUParticleSystem
  110399. * @returns the list of ramp gradients
  110400. */
  110401. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110402. /**
  110403. * Not supported by GPUParticleSystem
  110404. * Gets or sets a boolean indicating that ramp gradients must be used
  110405. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110406. */
  110407. useRampGradients: boolean;
  110408. /**
  110409. * Not supported by GPUParticleSystem
  110410. * @param gradient defines the gradient to use (between 0 and 1)
  110411. * @param factor defines the life time factor to affect to the specified gradient
  110412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110413. * @returns the current particle system
  110414. */
  110415. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110416. /**
  110417. * Not supported by GPUParticleSystem
  110418. * @param gradient defines the gradient to remove
  110419. * @returns the current particle system
  110420. */
  110421. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110422. /**
  110423. * Instantiates a GPU particle system.
  110424. * 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.
  110425. * @param name The name of the particle system
  110426. * @param options The options used to create the system
  110427. * @param scene The scene the particle system belongs to
  110428. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110429. */
  110430. constructor(name: string, options: Partial<{
  110431. capacity: number;
  110432. randomTextureSize: number;
  110433. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110434. protected _reset(): void;
  110435. private _createUpdateVAO;
  110436. private _createRenderVAO;
  110437. private _initialize;
  110438. /** @hidden */
  110439. _recreateUpdateEffect(): void;
  110440. /** @hidden */
  110441. _recreateRenderEffect(): void;
  110442. /**
  110443. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110444. * @param preWarm defines if we are in the pre-warmimg phase
  110445. */
  110446. animate(preWarm?: boolean): void;
  110447. private _createFactorGradientTexture;
  110448. private _createSizeGradientTexture;
  110449. private _createAngularSpeedGradientTexture;
  110450. private _createVelocityGradientTexture;
  110451. private _createLimitVelocityGradientTexture;
  110452. private _createDragGradientTexture;
  110453. private _createColorGradientTexture;
  110454. /**
  110455. * Renders the particle system in its current state
  110456. * @param preWarm defines if the system should only update the particles but not render them
  110457. * @returns the current number of particles
  110458. */
  110459. render(preWarm?: boolean): number;
  110460. /**
  110461. * Rebuilds the particle system
  110462. */
  110463. rebuild(): void;
  110464. private _releaseBuffers;
  110465. private _releaseVAOs;
  110466. /**
  110467. * Disposes the particle system and free the associated resources
  110468. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110469. */
  110470. dispose(disposeTexture?: boolean): void;
  110471. /**
  110472. * Clones the particle system.
  110473. * @param name The name of the cloned object
  110474. * @param newEmitter The new emitter to use
  110475. * @returns the cloned particle system
  110476. */
  110477. clone(name: string, newEmitter: any): GPUParticleSystem;
  110478. /**
  110479. * Serializes the particle system to a JSON object.
  110480. * @returns the JSON object
  110481. */
  110482. serialize(): any;
  110483. /**
  110484. * Parses a JSON object to create a GPU particle system.
  110485. * @param parsedParticleSystem The JSON object to parse
  110486. * @param scene The scene to create the particle system in
  110487. * @param rootUrl The root url to use to load external dependencies like texture
  110488. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110489. * @returns the parsed GPU particle system
  110490. */
  110491. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110492. }
  110493. }
  110494. declare module BABYLON {
  110495. /**
  110496. * Represents a set of particle systems working together to create a specific effect
  110497. */
  110498. export class ParticleSystemSet implements IDisposable {
  110499. private _emitterCreationOptions;
  110500. private _emitterNode;
  110501. /**
  110502. * Gets the particle system list
  110503. */
  110504. systems: IParticleSystem[];
  110505. /**
  110506. * Gets the emitter node used with this set
  110507. */
  110508. readonly emitterNode: Nullable<TransformNode>;
  110509. /**
  110510. * Creates a new emitter mesh as a sphere
  110511. * @param options defines the options used to create the sphere
  110512. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110513. * @param scene defines the hosting scene
  110514. */
  110515. setEmitterAsSphere(options: {
  110516. diameter: number;
  110517. segments: number;
  110518. color: Color3;
  110519. }, renderingGroupId: number, scene: Scene): void;
  110520. /**
  110521. * Starts all particle systems of the set
  110522. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110523. */
  110524. start(emitter?: AbstractMesh): void;
  110525. /**
  110526. * Release all associated resources
  110527. */
  110528. dispose(): void;
  110529. /**
  110530. * Serialize the set into a JSON compatible object
  110531. * @returns a JSON compatible representation of the set
  110532. */
  110533. serialize(): any;
  110534. /**
  110535. * Parse a new ParticleSystemSet from a serialized source
  110536. * @param data defines a JSON compatible representation of the set
  110537. * @param scene defines the hosting scene
  110538. * @param gpu defines if we want GPU particles or CPU particles
  110539. * @returns a new ParticleSystemSet
  110540. */
  110541. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110542. }
  110543. }
  110544. declare module BABYLON {
  110545. /**
  110546. * This class is made for on one-liner static method to help creating particle system set.
  110547. */
  110548. export class ParticleHelper {
  110549. /**
  110550. * Gets or sets base Assets URL
  110551. */
  110552. static BaseAssetsUrl: string;
  110553. /**
  110554. * Create a default particle system that you can tweak
  110555. * @param emitter defines the emitter to use
  110556. * @param capacity defines the system capacity (default is 500 particles)
  110557. * @param scene defines the hosting scene
  110558. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110559. * @returns the new Particle system
  110560. */
  110561. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110562. /**
  110563. * This is the main static method (one-liner) of this helper to create different particle systems
  110564. * @param type This string represents the type to the particle system to create
  110565. * @param scene The scene where the particle system should live
  110566. * @param gpu If the system will use gpu
  110567. * @returns the ParticleSystemSet created
  110568. */
  110569. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110570. /**
  110571. * Static function used to export a particle system to a ParticleSystemSet variable.
  110572. * Please note that the emitter shape is not exported
  110573. * @param systems defines the particle systems to export
  110574. * @returns the created particle system set
  110575. */
  110576. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110577. }
  110578. }
  110579. declare module BABYLON {
  110580. interface Engine {
  110581. /**
  110582. * Create an effect to use with particle systems.
  110583. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110584. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110585. * @param uniformsNames defines a list of attribute names
  110586. * @param samplers defines an array of string used to represent textures
  110587. * @param defines defines the string containing the defines to use to compile the shaders
  110588. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110589. * @param onCompiled defines a function to call when the effect creation is successful
  110590. * @param onError defines a function to call when the effect creation has failed
  110591. * @returns the new Effect
  110592. */
  110593. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110594. }
  110595. interface Mesh {
  110596. /**
  110597. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110598. * @returns an array of IParticleSystem
  110599. */
  110600. getEmittedParticleSystems(): IParticleSystem[];
  110601. /**
  110602. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110603. * @returns an array of IParticleSystem
  110604. */
  110605. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110606. }
  110607. /**
  110608. * @hidden
  110609. */
  110610. export var _IDoNeedToBeInTheBuild: number;
  110611. }
  110612. declare module BABYLON {
  110613. interface Scene {
  110614. /** @hidden (Backing field) */
  110615. _physicsEngine: Nullable<IPhysicsEngine>;
  110616. /**
  110617. * Gets the current physics engine
  110618. * @returns a IPhysicsEngine or null if none attached
  110619. */
  110620. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110621. /**
  110622. * Enables physics to the current scene
  110623. * @param gravity defines the scene's gravity for the physics engine
  110624. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110625. * @return a boolean indicating if the physics engine was initialized
  110626. */
  110627. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110628. /**
  110629. * Disables and disposes the physics engine associated with the scene
  110630. */
  110631. disablePhysicsEngine(): void;
  110632. /**
  110633. * Gets a boolean indicating if there is an active physics engine
  110634. * @returns a boolean indicating if there is an active physics engine
  110635. */
  110636. isPhysicsEnabled(): boolean;
  110637. /**
  110638. * Deletes a physics compound impostor
  110639. * @param compound defines the compound to delete
  110640. */
  110641. deleteCompoundImpostor(compound: any): void;
  110642. /**
  110643. * An event triggered when physic simulation is about to be run
  110644. */
  110645. onBeforePhysicsObservable: Observable<Scene>;
  110646. /**
  110647. * An event triggered when physic simulation has been done
  110648. */
  110649. onAfterPhysicsObservable: Observable<Scene>;
  110650. }
  110651. interface AbstractMesh {
  110652. /** @hidden */
  110653. _physicsImpostor: Nullable<PhysicsImpostor>;
  110654. /**
  110655. * Gets or sets impostor used for physic simulation
  110656. * @see http://doc.babylonjs.com/features/physics_engine
  110657. */
  110658. physicsImpostor: Nullable<PhysicsImpostor>;
  110659. /**
  110660. * Gets the current physics impostor
  110661. * @see http://doc.babylonjs.com/features/physics_engine
  110662. * @returns a physics impostor or null
  110663. */
  110664. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110665. /** Apply a physic impulse to the mesh
  110666. * @param force defines the force to apply
  110667. * @param contactPoint defines where to apply the force
  110668. * @returns the current mesh
  110669. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110670. */
  110671. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110672. /**
  110673. * Creates a physic joint between two meshes
  110674. * @param otherMesh defines the other mesh to use
  110675. * @param pivot1 defines the pivot to use on this mesh
  110676. * @param pivot2 defines the pivot to use on the other mesh
  110677. * @param options defines additional options (can be plugin dependent)
  110678. * @returns the current mesh
  110679. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110680. */
  110681. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110682. /** @hidden */
  110683. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110684. }
  110685. /**
  110686. * Defines the physics engine scene component responsible to manage a physics engine
  110687. */
  110688. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110689. /**
  110690. * The component name helpful to identify the component in the list of scene components.
  110691. */
  110692. readonly name: string;
  110693. /**
  110694. * The scene the component belongs to.
  110695. */
  110696. scene: Scene;
  110697. /**
  110698. * Creates a new instance of the component for the given scene
  110699. * @param scene Defines the scene to register the component in
  110700. */
  110701. constructor(scene: Scene);
  110702. /**
  110703. * Registers the component in a given scene
  110704. */
  110705. register(): void;
  110706. /**
  110707. * Rebuilds the elements related to this component in case of
  110708. * context lost for instance.
  110709. */
  110710. rebuild(): void;
  110711. /**
  110712. * Disposes the component and the associated ressources
  110713. */
  110714. dispose(): void;
  110715. }
  110716. }
  110717. declare module BABYLON {
  110718. /**
  110719. * A helper for physics simulations
  110720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110721. */
  110722. export class PhysicsHelper {
  110723. private _scene;
  110724. private _physicsEngine;
  110725. /**
  110726. * Initializes the Physics helper
  110727. * @param scene Babylon.js scene
  110728. */
  110729. constructor(scene: Scene);
  110730. /**
  110731. * Applies a radial explosion impulse
  110732. * @param origin the origin of the explosion
  110733. * @param radiusOrEventOptions the radius or the options of radial explosion
  110734. * @param strength the explosion strength
  110735. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110736. * @returns A physics radial explosion event, or null
  110737. */
  110738. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110739. /**
  110740. * Applies a radial explosion force
  110741. * @param origin the origin of the explosion
  110742. * @param radiusOrEventOptions the radius or the options of radial explosion
  110743. * @param strength the explosion strength
  110744. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110745. * @returns A physics radial explosion event, or null
  110746. */
  110747. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110748. /**
  110749. * Creates a gravitational field
  110750. * @param origin the origin of the explosion
  110751. * @param radiusOrEventOptions the radius or the options of radial explosion
  110752. * @param strength the explosion strength
  110753. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110754. * @returns A physics gravitational field event, or null
  110755. */
  110756. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110757. /**
  110758. * Creates a physics updraft event
  110759. * @param origin the origin of the updraft
  110760. * @param radiusOrEventOptions the radius or the options of the updraft
  110761. * @param strength the strength of the updraft
  110762. * @param height the height of the updraft
  110763. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110764. * @returns A physics updraft event, or null
  110765. */
  110766. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110767. /**
  110768. * Creates a physics vortex event
  110769. * @param origin the of the vortex
  110770. * @param radiusOrEventOptions the radius or the options of the vortex
  110771. * @param strength the strength of the vortex
  110772. * @param height the height of the vortex
  110773. * @returns a Physics vortex event, or null
  110774. * A physics vortex event or null
  110775. */
  110776. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110777. }
  110778. /**
  110779. * Represents a physics radial explosion event
  110780. */
  110781. class PhysicsRadialExplosionEvent {
  110782. private _scene;
  110783. private _options;
  110784. private _sphere;
  110785. private _dataFetched;
  110786. /**
  110787. * Initializes a radial explosioin event
  110788. * @param _scene BabylonJS scene
  110789. * @param _options The options for the vortex event
  110790. */
  110791. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110792. /**
  110793. * Returns the data related to the radial explosion event (sphere).
  110794. * @returns The radial explosion event data
  110795. */
  110796. getData(): PhysicsRadialExplosionEventData;
  110797. /**
  110798. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110799. * @param impostor A physics imposter
  110800. * @param origin the origin of the explosion
  110801. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110802. */
  110803. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110804. /**
  110805. * Triggers affecterd impostors callbacks
  110806. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110807. */
  110808. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110809. /**
  110810. * Disposes the sphere.
  110811. * @param force Specifies if the sphere should be disposed by force
  110812. */
  110813. dispose(force?: boolean): void;
  110814. /*** Helpers ***/
  110815. private _prepareSphere;
  110816. private _intersectsWithSphere;
  110817. }
  110818. /**
  110819. * Represents a gravitational field event
  110820. */
  110821. class PhysicsGravitationalFieldEvent {
  110822. private _physicsHelper;
  110823. private _scene;
  110824. private _origin;
  110825. private _options;
  110826. private _tickCallback;
  110827. private _sphere;
  110828. private _dataFetched;
  110829. /**
  110830. * Initializes the physics gravitational field event
  110831. * @param _physicsHelper A physics helper
  110832. * @param _scene BabylonJS scene
  110833. * @param _origin The origin position of the gravitational field event
  110834. * @param _options The options for the vortex event
  110835. */
  110836. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110837. /**
  110838. * Returns the data related to the gravitational field event (sphere).
  110839. * @returns A gravitational field event
  110840. */
  110841. getData(): PhysicsGravitationalFieldEventData;
  110842. /**
  110843. * Enables the gravitational field.
  110844. */
  110845. enable(): void;
  110846. /**
  110847. * Disables the gravitational field.
  110848. */
  110849. disable(): void;
  110850. /**
  110851. * Disposes the sphere.
  110852. * @param force The force to dispose from the gravitational field event
  110853. */
  110854. dispose(force?: boolean): void;
  110855. private _tick;
  110856. }
  110857. /**
  110858. * Represents a physics updraft event
  110859. */
  110860. class PhysicsUpdraftEvent {
  110861. private _scene;
  110862. private _origin;
  110863. private _options;
  110864. private _physicsEngine;
  110865. private _originTop;
  110866. private _originDirection;
  110867. private _tickCallback;
  110868. private _cylinder;
  110869. private _cylinderPosition;
  110870. private _dataFetched;
  110871. /**
  110872. * Initializes the physics updraft event
  110873. * @param _scene BabylonJS scene
  110874. * @param _origin The origin position of the updraft
  110875. * @param _options The options for the updraft event
  110876. */
  110877. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110878. /**
  110879. * Returns the data related to the updraft event (cylinder).
  110880. * @returns A physics updraft event
  110881. */
  110882. getData(): PhysicsUpdraftEventData;
  110883. /**
  110884. * Enables the updraft.
  110885. */
  110886. enable(): void;
  110887. /**
  110888. * Disables the updraft.
  110889. */
  110890. disable(): void;
  110891. /**
  110892. * Disposes the cylinder.
  110893. * @param force Specifies if the updraft should be disposed by force
  110894. */
  110895. dispose(force?: boolean): void;
  110896. private getImpostorHitData;
  110897. private _tick;
  110898. /*** Helpers ***/
  110899. private _prepareCylinder;
  110900. private _intersectsWithCylinder;
  110901. }
  110902. /**
  110903. * Represents a physics vortex event
  110904. */
  110905. class PhysicsVortexEvent {
  110906. private _scene;
  110907. private _origin;
  110908. private _options;
  110909. private _physicsEngine;
  110910. private _originTop;
  110911. private _tickCallback;
  110912. private _cylinder;
  110913. private _cylinderPosition;
  110914. private _dataFetched;
  110915. /**
  110916. * Initializes the physics vortex event
  110917. * @param _scene The BabylonJS scene
  110918. * @param _origin The origin position of the vortex
  110919. * @param _options The options for the vortex event
  110920. */
  110921. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110922. /**
  110923. * Returns the data related to the vortex event (cylinder).
  110924. * @returns The physics vortex event data
  110925. */
  110926. getData(): PhysicsVortexEventData;
  110927. /**
  110928. * Enables the vortex.
  110929. */
  110930. enable(): void;
  110931. /**
  110932. * Disables the cortex.
  110933. */
  110934. disable(): void;
  110935. /**
  110936. * Disposes the sphere.
  110937. * @param force
  110938. */
  110939. dispose(force?: boolean): void;
  110940. private getImpostorHitData;
  110941. private _tick;
  110942. /*** Helpers ***/
  110943. private _prepareCylinder;
  110944. private _intersectsWithCylinder;
  110945. }
  110946. /**
  110947. * Options fot the radial explosion event
  110948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110949. */
  110950. export class PhysicsRadialExplosionEventOptions {
  110951. /**
  110952. * The radius of the sphere for the radial explosion.
  110953. */
  110954. radius: number;
  110955. /**
  110956. * The strenth of the explosion.
  110957. */
  110958. strength: number;
  110959. /**
  110960. * The strenght of the force in correspondence to the distance of the affected object
  110961. */
  110962. falloff: PhysicsRadialImpulseFalloff;
  110963. /**
  110964. * Sphere options for the radial explosion.
  110965. */
  110966. sphere: {
  110967. segments: number;
  110968. diameter: number;
  110969. };
  110970. /**
  110971. * Sphere options for the radial explosion.
  110972. */
  110973. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110974. }
  110975. /**
  110976. * Options fot the updraft event
  110977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110978. */
  110979. export class PhysicsUpdraftEventOptions {
  110980. /**
  110981. * The radius of the cylinder for the vortex
  110982. */
  110983. radius: number;
  110984. /**
  110985. * The strenth of the updraft.
  110986. */
  110987. strength: number;
  110988. /**
  110989. * The height of the cylinder for the updraft.
  110990. */
  110991. height: number;
  110992. /**
  110993. * The mode for the the updraft.
  110994. */
  110995. updraftMode: PhysicsUpdraftMode;
  110996. }
  110997. /**
  110998. * Options fot the vortex event
  110999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111000. */
  111001. export class PhysicsVortexEventOptions {
  111002. /**
  111003. * The radius of the cylinder for the vortex
  111004. */
  111005. radius: number;
  111006. /**
  111007. * The strenth of the vortex.
  111008. */
  111009. strength: number;
  111010. /**
  111011. * The height of the cylinder for the vortex.
  111012. */
  111013. height: number;
  111014. /**
  111015. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111016. */
  111017. centripetalForceThreshold: number;
  111018. /**
  111019. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111020. */
  111021. centripetalForceMultiplier: number;
  111022. /**
  111023. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111024. */
  111025. centrifugalForceMultiplier: number;
  111026. /**
  111027. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111028. */
  111029. updraftForceMultiplier: number;
  111030. }
  111031. /**
  111032. * The strenght of the force in correspondence to the distance of the affected object
  111033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111034. */
  111035. export enum PhysicsRadialImpulseFalloff {
  111036. /** Defines that impulse is constant in strength across it's whole radius */
  111037. Constant = 0,
  111038. /** Defines that impulse gets weaker if it's further from the origin */
  111039. Linear = 1
  111040. }
  111041. /**
  111042. * The strength of the force in correspondence to the distance of the affected object
  111043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111044. */
  111045. export enum PhysicsUpdraftMode {
  111046. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111047. Center = 0,
  111048. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111049. Perpendicular = 1
  111050. }
  111051. /**
  111052. * Interface for a physics hit data
  111053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111054. */
  111055. export interface PhysicsHitData {
  111056. /**
  111057. * The force applied at the contact point
  111058. */
  111059. force: Vector3;
  111060. /**
  111061. * The contact point
  111062. */
  111063. contactPoint: Vector3;
  111064. /**
  111065. * The distance from the origin to the contact point
  111066. */
  111067. distanceFromOrigin: number;
  111068. }
  111069. /**
  111070. * Interface for radial explosion event data
  111071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111072. */
  111073. export interface PhysicsRadialExplosionEventData {
  111074. /**
  111075. * A sphere used for the radial explosion event
  111076. */
  111077. sphere: Mesh;
  111078. }
  111079. /**
  111080. * Interface for gravitational field event data
  111081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111082. */
  111083. export interface PhysicsGravitationalFieldEventData {
  111084. /**
  111085. * A sphere mesh used for the gravitational field event
  111086. */
  111087. sphere: Mesh;
  111088. }
  111089. /**
  111090. * Interface for updraft event data
  111091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111092. */
  111093. export interface PhysicsUpdraftEventData {
  111094. /**
  111095. * A cylinder used for the updraft event
  111096. */
  111097. cylinder: Mesh;
  111098. }
  111099. /**
  111100. * Interface for vortex event data
  111101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111102. */
  111103. export interface PhysicsVortexEventData {
  111104. /**
  111105. * A cylinder used for the vortex event
  111106. */
  111107. cylinder: Mesh;
  111108. }
  111109. /**
  111110. * Interface for an affected physics impostor
  111111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111112. */
  111113. export interface PhysicsAffectedImpostorWithData {
  111114. /**
  111115. * The impostor affected by the effect
  111116. */
  111117. impostor: PhysicsImpostor;
  111118. /**
  111119. * The data about the hit/horce from the explosion
  111120. */
  111121. hitData: PhysicsHitData;
  111122. }
  111123. }
  111124. declare module BABYLON {
  111125. /** @hidden */
  111126. export var blackAndWhitePixelShader: {
  111127. name: string;
  111128. shader: string;
  111129. };
  111130. }
  111131. declare module BABYLON {
  111132. /**
  111133. * Post process used to render in black and white
  111134. */
  111135. export class BlackAndWhitePostProcess extends PostProcess {
  111136. /**
  111137. * Linear about to convert he result to black and white (default: 1)
  111138. */
  111139. degree: number;
  111140. /**
  111141. * Creates a black and white post process
  111142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111143. * @param name The name of the effect.
  111144. * @param options The required width/height ratio to downsize to before computing the render pass.
  111145. * @param camera The camera to apply the render pass to.
  111146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111147. * @param engine The engine which the post process will be applied. (default: current engine)
  111148. * @param reusable If the post process can be reused on the same frame. (default: false)
  111149. */
  111150. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111151. }
  111152. }
  111153. declare module BABYLON {
  111154. /**
  111155. * This represents a set of one or more post processes in Babylon.
  111156. * A post process can be used to apply a shader to a texture after it is rendered.
  111157. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111158. */
  111159. export class PostProcessRenderEffect {
  111160. private _postProcesses;
  111161. private _getPostProcesses;
  111162. private _singleInstance;
  111163. private _cameras;
  111164. private _indicesForCamera;
  111165. /**
  111166. * Name of the effect
  111167. * @hidden
  111168. */
  111169. _name: string;
  111170. /**
  111171. * Instantiates a post process render effect.
  111172. * A post process can be used to apply a shader to a texture after it is rendered.
  111173. * @param engine The engine the effect is tied to
  111174. * @param name The name of the effect
  111175. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111176. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111177. */
  111178. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111179. /**
  111180. * Checks if all the post processes in the effect are supported.
  111181. */
  111182. readonly isSupported: boolean;
  111183. /**
  111184. * Updates the current state of the effect
  111185. * @hidden
  111186. */
  111187. _update(): void;
  111188. /**
  111189. * Attaches the effect on cameras
  111190. * @param cameras The camera to attach to.
  111191. * @hidden
  111192. */
  111193. _attachCameras(cameras: Camera): void;
  111194. /**
  111195. * Attaches the effect on cameras
  111196. * @param cameras The camera to attach to.
  111197. * @hidden
  111198. */
  111199. _attachCameras(cameras: Camera[]): void;
  111200. /**
  111201. * Detatches the effect on cameras
  111202. * @param cameras The camera to detatch from.
  111203. * @hidden
  111204. */
  111205. _detachCameras(cameras: Camera): void;
  111206. /**
  111207. * Detatches the effect on cameras
  111208. * @param cameras The camera to detatch from.
  111209. * @hidden
  111210. */
  111211. _detachCameras(cameras: Camera[]): void;
  111212. /**
  111213. * Enables the effect on given cameras
  111214. * @param cameras The camera to enable.
  111215. * @hidden
  111216. */
  111217. _enable(cameras: Camera): void;
  111218. /**
  111219. * Enables the effect on given cameras
  111220. * @param cameras The camera to enable.
  111221. * @hidden
  111222. */
  111223. _enable(cameras: Nullable<Camera[]>): void;
  111224. /**
  111225. * Disables the effect on the given cameras
  111226. * @param cameras The camera to disable.
  111227. * @hidden
  111228. */
  111229. _disable(cameras: Camera): void;
  111230. /**
  111231. * Disables the effect on the given cameras
  111232. * @param cameras The camera to disable.
  111233. * @hidden
  111234. */
  111235. _disable(cameras: Nullable<Camera[]>): void;
  111236. /**
  111237. * Gets a list of the post processes contained in the effect.
  111238. * @param camera The camera to get the post processes on.
  111239. * @returns The list of the post processes in the effect.
  111240. */
  111241. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111242. }
  111243. }
  111244. declare module BABYLON {
  111245. /** @hidden */
  111246. export var extractHighlightsPixelShader: {
  111247. name: string;
  111248. shader: string;
  111249. };
  111250. }
  111251. declare module BABYLON {
  111252. /**
  111253. * 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.
  111254. */
  111255. export class ExtractHighlightsPostProcess extends PostProcess {
  111256. /**
  111257. * The luminance threshold, pixels below this value will be set to black.
  111258. */
  111259. threshold: number;
  111260. /** @hidden */
  111261. _exposure: number;
  111262. /**
  111263. * Post process which has the input texture to be used when performing highlight extraction
  111264. * @hidden
  111265. */
  111266. _inputPostProcess: Nullable<PostProcess>;
  111267. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111268. }
  111269. }
  111270. declare module BABYLON {
  111271. /** @hidden */
  111272. export var bloomMergePixelShader: {
  111273. name: string;
  111274. shader: string;
  111275. };
  111276. }
  111277. declare module BABYLON {
  111278. /**
  111279. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111280. */
  111281. export class BloomMergePostProcess extends PostProcess {
  111282. /** Weight of the bloom to be added to the original input. */
  111283. weight: number;
  111284. /**
  111285. * Creates a new instance of @see BloomMergePostProcess
  111286. * @param name The name of the effect.
  111287. * @param originalFromInput Post process which's input will be used for the merge.
  111288. * @param blurred Blurred highlights post process which's output will be used.
  111289. * @param weight Weight of the bloom to be added to the original input.
  111290. * @param options The required width/height ratio to downsize to before computing the render pass.
  111291. * @param camera The camera to apply the render pass to.
  111292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111293. * @param engine The engine which the post process will be applied. (default: current engine)
  111294. * @param reusable If the post process can be reused on the same frame. (default: false)
  111295. * @param textureType Type of textures used when performing the post process. (default: 0)
  111296. * @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)
  111297. */
  111298. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111299. /** Weight of the bloom to be added to the original input. */
  111300. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111301. }
  111302. }
  111303. declare module BABYLON {
  111304. /**
  111305. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111306. */
  111307. export class BloomEffect extends PostProcessRenderEffect {
  111308. private bloomScale;
  111309. /**
  111310. * @hidden Internal
  111311. */
  111312. _effects: Array<PostProcess>;
  111313. /**
  111314. * @hidden Internal
  111315. */
  111316. _downscale: ExtractHighlightsPostProcess;
  111317. private _blurX;
  111318. private _blurY;
  111319. private _merge;
  111320. /**
  111321. * The luminance threshold to find bright areas of the image to bloom.
  111322. */
  111323. threshold: number;
  111324. /**
  111325. * The strength of the bloom.
  111326. */
  111327. weight: number;
  111328. /**
  111329. * Specifies the size of the bloom blur kernel, relative to the final output size
  111330. */
  111331. kernel: number;
  111332. /**
  111333. * Creates a new instance of @see BloomEffect
  111334. * @param scene The scene the effect belongs to.
  111335. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111336. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111337. * @param bloomWeight The the strength of bloom.
  111338. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111339. * @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)
  111340. */
  111341. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111342. /**
  111343. * Disposes each of the internal effects for a given camera.
  111344. * @param camera The camera to dispose the effect on.
  111345. */
  111346. disposeEffects(camera: Camera): void;
  111347. /**
  111348. * @hidden Internal
  111349. */
  111350. _updateEffects(): void;
  111351. /**
  111352. * Internal
  111353. * @returns if all the contained post processes are ready.
  111354. * @hidden
  111355. */
  111356. _isReady(): boolean;
  111357. }
  111358. }
  111359. declare module BABYLON {
  111360. /** @hidden */
  111361. export var chromaticAberrationPixelShader: {
  111362. name: string;
  111363. shader: string;
  111364. };
  111365. }
  111366. declare module BABYLON {
  111367. /**
  111368. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111369. */
  111370. export class ChromaticAberrationPostProcess extends PostProcess {
  111371. /**
  111372. * The amount of seperation of rgb channels (default: 30)
  111373. */
  111374. aberrationAmount: number;
  111375. /**
  111376. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111377. */
  111378. radialIntensity: number;
  111379. /**
  111380. * 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))
  111381. */
  111382. direction: Vector2;
  111383. /**
  111384. * 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))
  111385. */
  111386. centerPosition: Vector2;
  111387. /**
  111388. * Creates a new instance ChromaticAberrationPostProcess
  111389. * @param name The name of the effect.
  111390. * @param screenWidth The width of the screen to apply the effect on.
  111391. * @param screenHeight The height of the screen to apply the effect on.
  111392. * @param options The required width/height ratio to downsize to before computing the render pass.
  111393. * @param camera The camera to apply the render pass to.
  111394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111395. * @param engine The engine which the post process will be applied. (default: current engine)
  111396. * @param reusable If the post process can be reused on the same frame. (default: false)
  111397. * @param textureType Type of textures used when performing the post process. (default: 0)
  111398. * @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)
  111399. */
  111400. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111401. }
  111402. }
  111403. declare module BABYLON {
  111404. /** @hidden */
  111405. export var circleOfConfusionPixelShader: {
  111406. name: string;
  111407. shader: string;
  111408. };
  111409. }
  111410. declare module BABYLON {
  111411. /**
  111412. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111413. */
  111414. export class CircleOfConfusionPostProcess extends PostProcess {
  111415. /**
  111416. * 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.
  111417. */
  111418. lensSize: number;
  111419. /**
  111420. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111421. */
  111422. fStop: number;
  111423. /**
  111424. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111425. */
  111426. focusDistance: number;
  111427. /**
  111428. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111429. */
  111430. focalLength: number;
  111431. private _depthTexture;
  111432. /**
  111433. * Creates a new instance CircleOfConfusionPostProcess
  111434. * @param name The name of the effect.
  111435. * @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.
  111436. * @param options The required width/height ratio to downsize to before computing the render pass.
  111437. * @param camera The camera to apply the render pass to.
  111438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111439. * @param engine The engine which the post process will be applied. (default: current engine)
  111440. * @param reusable If the post process can be reused on the same frame. (default: false)
  111441. * @param textureType Type of textures used when performing the post process. (default: 0)
  111442. * @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)
  111443. */
  111444. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111445. /**
  111446. * 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.
  111447. */
  111448. depthTexture: RenderTargetTexture;
  111449. }
  111450. }
  111451. declare module BABYLON {
  111452. /** @hidden */
  111453. export var colorCorrectionPixelShader: {
  111454. name: string;
  111455. shader: string;
  111456. };
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. *
  111461. * This post-process allows the modification of rendered colors by using
  111462. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111463. *
  111464. * The object needs to be provided an url to a texture containing the color
  111465. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111466. * Use an image editing software to tweak the LUT to match your needs.
  111467. *
  111468. * For an example of a color LUT, see here:
  111469. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111470. * For explanations on color grading, see here:
  111471. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111472. *
  111473. */
  111474. export class ColorCorrectionPostProcess extends PostProcess {
  111475. private _colorTableTexture;
  111476. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111477. }
  111478. }
  111479. declare module BABYLON {
  111480. /** @hidden */
  111481. export var convolutionPixelShader: {
  111482. name: string;
  111483. shader: string;
  111484. };
  111485. }
  111486. declare module BABYLON {
  111487. /**
  111488. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111489. * input texture to perform effects such as edge detection or sharpening
  111490. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111491. */
  111492. export class ConvolutionPostProcess extends PostProcess {
  111493. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111494. kernel: number[];
  111495. /**
  111496. * Creates a new instance ConvolutionPostProcess
  111497. * @param name The name of the effect.
  111498. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111499. * @param options The required width/height ratio to downsize to before computing the render pass.
  111500. * @param camera The camera to apply the render pass to.
  111501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111502. * @param engine The engine which the post process will be applied. (default: current engine)
  111503. * @param reusable If the post process can be reused on the same frame. (default: false)
  111504. * @param textureType Type of textures used when performing the post process. (default: 0)
  111505. */
  111506. constructor(name: string,
  111507. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111508. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111509. /**
  111510. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111511. */
  111512. static EdgeDetect0Kernel: number[];
  111513. /**
  111514. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111515. */
  111516. static EdgeDetect1Kernel: number[];
  111517. /**
  111518. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111519. */
  111520. static EdgeDetect2Kernel: number[];
  111521. /**
  111522. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111523. */
  111524. static SharpenKernel: number[];
  111525. /**
  111526. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111527. */
  111528. static EmbossKernel: number[];
  111529. /**
  111530. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111531. */
  111532. static GaussianKernel: number[];
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111538. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111539. * based on samples that have a large difference in distance than the center pixel.
  111540. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111541. */
  111542. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111543. direction: Vector2;
  111544. /**
  111545. * Creates a new instance CircleOfConfusionPostProcess
  111546. * @param name The name of the effect.
  111547. * @param scene The scene the effect belongs to.
  111548. * @param direction The direction the blur should be applied.
  111549. * @param kernel The size of the kernel used to blur.
  111550. * @param options The required width/height ratio to downsize to before computing the render pass.
  111551. * @param camera The camera to apply the render pass to.
  111552. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111553. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111555. * @param engine The engine which the post process will be applied. (default: current engine)
  111556. * @param reusable If the post process can be reused on the same frame. (default: false)
  111557. * @param textureType Type of textures used when performing the post process. (default: 0)
  111558. * @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)
  111559. */
  111560. 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);
  111561. }
  111562. }
  111563. declare module BABYLON {
  111564. /** @hidden */
  111565. export var depthOfFieldMergePixelShader: {
  111566. name: string;
  111567. shader: string;
  111568. };
  111569. }
  111570. declare module BABYLON {
  111571. /**
  111572. * Options to be set when merging outputs from the default pipeline.
  111573. */
  111574. export class DepthOfFieldMergePostProcessOptions {
  111575. /**
  111576. * The original image to merge on top of
  111577. */
  111578. originalFromInput: PostProcess;
  111579. /**
  111580. * Parameters to perform the merge of the depth of field effect
  111581. */
  111582. depthOfField?: {
  111583. circleOfConfusion: PostProcess;
  111584. blurSteps: Array<PostProcess>;
  111585. };
  111586. /**
  111587. * Parameters to perform the merge of bloom effect
  111588. */
  111589. bloom?: {
  111590. blurred: PostProcess;
  111591. weight: number;
  111592. };
  111593. }
  111594. /**
  111595. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111596. */
  111597. export class DepthOfFieldMergePostProcess extends PostProcess {
  111598. private blurSteps;
  111599. /**
  111600. * Creates a new instance of DepthOfFieldMergePostProcess
  111601. * @param name The name of the effect.
  111602. * @param originalFromInput Post process which's input will be used for the merge.
  111603. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111604. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111605. * @param options The required width/height ratio to downsize to before computing the render pass.
  111606. * @param camera The camera to apply the render pass to.
  111607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111608. * @param engine The engine which the post process will be applied. (default: current engine)
  111609. * @param reusable If the post process can be reused on the same frame. (default: false)
  111610. * @param textureType Type of textures used when performing the post process. (default: 0)
  111611. * @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)
  111612. */
  111613. 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);
  111614. /**
  111615. * Updates the effect with the current post process compile time values and recompiles the shader.
  111616. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111617. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111618. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111619. * @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
  111620. * @param onCompiled Called when the shader has been compiled.
  111621. * @param onError Called if there is an error when compiling a shader.
  111622. */
  111623. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111624. }
  111625. }
  111626. declare module BABYLON {
  111627. /**
  111628. * Specifies the level of max blur that should be applied when using the depth of field effect
  111629. */
  111630. export enum DepthOfFieldEffectBlurLevel {
  111631. /**
  111632. * Subtle blur
  111633. */
  111634. Low = 0,
  111635. /**
  111636. * Medium blur
  111637. */
  111638. Medium = 1,
  111639. /**
  111640. * Large blur
  111641. */
  111642. High = 2
  111643. }
  111644. /**
  111645. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111646. */
  111647. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111648. private _circleOfConfusion;
  111649. /**
  111650. * @hidden Internal, blurs from high to low
  111651. */
  111652. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111653. private _depthOfFieldBlurY;
  111654. private _dofMerge;
  111655. /**
  111656. * @hidden Internal post processes in depth of field effect
  111657. */
  111658. _effects: Array<PostProcess>;
  111659. /**
  111660. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111661. */
  111662. focalLength: number;
  111663. /**
  111664. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111665. */
  111666. fStop: number;
  111667. /**
  111668. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111669. */
  111670. focusDistance: number;
  111671. /**
  111672. * 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.
  111673. */
  111674. lensSize: number;
  111675. /**
  111676. * Creates a new instance DepthOfFieldEffect
  111677. * @param scene The scene the effect belongs to.
  111678. * @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.
  111679. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111680. * @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)
  111681. */
  111682. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111683. /**
  111684. * 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.
  111685. */
  111686. depthTexture: RenderTargetTexture;
  111687. /**
  111688. * Disposes each of the internal effects for a given camera.
  111689. * @param camera The camera to dispose the effect on.
  111690. */
  111691. disposeEffects(camera: Camera): void;
  111692. /**
  111693. * @hidden Internal
  111694. */
  111695. _updateEffects(): void;
  111696. /**
  111697. * Internal
  111698. * @returns if all the contained post processes are ready.
  111699. * @hidden
  111700. */
  111701. _isReady(): boolean;
  111702. }
  111703. }
  111704. declare module BABYLON {
  111705. /** @hidden */
  111706. export var displayPassPixelShader: {
  111707. name: string;
  111708. shader: string;
  111709. };
  111710. }
  111711. declare module BABYLON {
  111712. /**
  111713. * DisplayPassPostProcess which produces an output the same as it's input
  111714. */
  111715. export class DisplayPassPostProcess extends PostProcess {
  111716. /**
  111717. * Creates the DisplayPassPostProcess
  111718. * @param name The name of the effect.
  111719. * @param options The required width/height ratio to downsize to before computing the render pass.
  111720. * @param camera The camera to apply the render pass to.
  111721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111722. * @param engine The engine which the post process will be applied. (default: current engine)
  111723. * @param reusable If the post process can be reused on the same frame. (default: false)
  111724. */
  111725. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111726. }
  111727. }
  111728. declare module BABYLON {
  111729. /** @hidden */
  111730. export var filterPixelShader: {
  111731. name: string;
  111732. shader: string;
  111733. };
  111734. }
  111735. declare module BABYLON {
  111736. /**
  111737. * Applies a kernel filter to the image
  111738. */
  111739. export class FilterPostProcess extends PostProcess {
  111740. /** The matrix to be applied to the image */
  111741. kernelMatrix: Matrix;
  111742. /**
  111743. *
  111744. * @param name The name of the effect.
  111745. * @param kernelMatrix The matrix to be applied to the image
  111746. * @param options The required width/height ratio to downsize to before computing the render pass.
  111747. * @param camera The camera to apply the render pass to.
  111748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111749. * @param engine The engine which the post process will be applied. (default: current engine)
  111750. * @param reusable If the post process can be reused on the same frame. (default: false)
  111751. */
  111752. constructor(name: string,
  111753. /** The matrix to be applied to the image */
  111754. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111755. }
  111756. }
  111757. declare module BABYLON {
  111758. /** @hidden */
  111759. export var fxaaPixelShader: {
  111760. name: string;
  111761. shader: string;
  111762. };
  111763. }
  111764. declare module BABYLON {
  111765. /** @hidden */
  111766. export var fxaaVertexShader: {
  111767. name: string;
  111768. shader: string;
  111769. };
  111770. }
  111771. declare module BABYLON {
  111772. /**
  111773. * Fxaa post process
  111774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111775. */
  111776. export class FxaaPostProcess extends PostProcess {
  111777. /** @hidden */
  111778. texelWidth: number;
  111779. /** @hidden */
  111780. texelHeight: number;
  111781. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111782. private _getDefines;
  111783. }
  111784. }
  111785. declare module BABYLON {
  111786. /** @hidden */
  111787. export var grainPixelShader: {
  111788. name: string;
  111789. shader: string;
  111790. };
  111791. }
  111792. declare module BABYLON {
  111793. /**
  111794. * The GrainPostProcess adds noise to the image at mid luminance levels
  111795. */
  111796. export class GrainPostProcess extends PostProcess {
  111797. /**
  111798. * The intensity of the grain added (default: 30)
  111799. */
  111800. intensity: number;
  111801. /**
  111802. * If the grain should be randomized on every frame
  111803. */
  111804. animated: boolean;
  111805. /**
  111806. * Creates a new instance of @see GrainPostProcess
  111807. * @param name The name of the effect.
  111808. * @param options The required width/height ratio to downsize to before computing the render pass.
  111809. * @param camera The camera to apply the render pass to.
  111810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111811. * @param engine The engine which the post process will be applied. (default: current engine)
  111812. * @param reusable If the post process can be reused on the same frame. (default: false)
  111813. * @param textureType Type of textures used when performing the post process. (default: 0)
  111814. * @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)
  111815. */
  111816. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111817. }
  111818. }
  111819. declare module BABYLON {
  111820. /** @hidden */
  111821. export var highlightsPixelShader: {
  111822. name: string;
  111823. shader: string;
  111824. };
  111825. }
  111826. declare module BABYLON {
  111827. /**
  111828. * Extracts highlights from the image
  111829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111830. */
  111831. export class HighlightsPostProcess extends PostProcess {
  111832. /**
  111833. * Extracts highlights from the image
  111834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111835. * @param name The name of the effect.
  111836. * @param options The required width/height ratio to downsize to before computing the render pass.
  111837. * @param camera The camera to apply the render pass to.
  111838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111839. * @param engine The engine which the post process will be applied. (default: current engine)
  111840. * @param reusable If the post process can be reused on the same frame. (default: false)
  111841. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111842. */
  111843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111844. }
  111845. }
  111846. declare module BABYLON {
  111847. /** @hidden */
  111848. export var mrtFragmentDeclaration: {
  111849. name: string;
  111850. shader: string;
  111851. };
  111852. }
  111853. declare module BABYLON {
  111854. /** @hidden */
  111855. export var geometryPixelShader: {
  111856. name: string;
  111857. shader: string;
  111858. };
  111859. }
  111860. declare module BABYLON {
  111861. /** @hidden */
  111862. export var geometryVertexShader: {
  111863. name: string;
  111864. shader: string;
  111865. };
  111866. }
  111867. declare module BABYLON {
  111868. /**
  111869. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111870. */
  111871. export class GeometryBufferRenderer {
  111872. /**
  111873. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111874. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111875. */
  111876. static readonly POSITION_TEXTURE_TYPE: number;
  111877. /**
  111878. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111879. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111880. */
  111881. static readonly VELOCITY_TEXTURE_TYPE: number;
  111882. /**
  111883. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111884. * in order to compute objects velocities when enableVelocity is set to "true"
  111885. * @hidden
  111886. */
  111887. _previousTransformationMatrices: {
  111888. [index: number]: Matrix;
  111889. };
  111890. private _scene;
  111891. private _multiRenderTarget;
  111892. private _ratio;
  111893. private _enablePosition;
  111894. private _enableVelocity;
  111895. private _positionIndex;
  111896. private _velocityIndex;
  111897. protected _effect: Effect;
  111898. protected _cachedDefines: string;
  111899. /**
  111900. * Set the render list (meshes to be rendered) used in the G buffer.
  111901. */
  111902. renderList: Mesh[];
  111903. /**
  111904. * Gets wether or not G buffer are supported by the running hardware.
  111905. * This requires draw buffer supports
  111906. */
  111907. readonly isSupported: boolean;
  111908. /**
  111909. * Returns the index of the given texture type in the G-Buffer textures array
  111910. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111911. * @returns the index of the given texture type in the G-Buffer textures array
  111912. */
  111913. getTextureIndex(textureType: number): number;
  111914. /**
  111915. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111916. */
  111917. /**
  111918. * Sets whether or not objects positions are enabled for the G buffer.
  111919. */
  111920. enablePosition: boolean;
  111921. /**
  111922. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111923. */
  111924. /**
  111925. * Sets wether or not objects velocities are enabled for the G buffer.
  111926. */
  111927. enableVelocity: boolean;
  111928. /**
  111929. * Gets the scene associated with the buffer.
  111930. */
  111931. readonly scene: Scene;
  111932. /**
  111933. * Gets the ratio used by the buffer during its creation.
  111934. * How big is the buffer related to the main canvas.
  111935. */
  111936. readonly ratio: number;
  111937. /** @hidden */
  111938. static _SceneComponentInitialization: (scene: Scene) => void;
  111939. /**
  111940. * Creates a new G Buffer for the scene
  111941. * @param scene The scene the buffer belongs to
  111942. * @param ratio How big is the buffer related to the main canvas.
  111943. */
  111944. constructor(scene: Scene, ratio?: number);
  111945. /**
  111946. * Checks wether everything is ready to render a submesh to the G buffer.
  111947. * @param subMesh the submesh to check readiness for
  111948. * @param useInstances is the mesh drawn using instance or not
  111949. * @returns true if ready otherwise false
  111950. */
  111951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111952. /**
  111953. * Gets the current underlying G Buffer.
  111954. * @returns the buffer
  111955. */
  111956. getGBuffer(): MultiRenderTarget;
  111957. /**
  111958. * Gets the number of samples used to render the buffer (anti aliasing).
  111959. */
  111960. /**
  111961. * Sets the number of samples used to render the buffer (anti aliasing).
  111962. */
  111963. samples: number;
  111964. /**
  111965. * Disposes the renderer and frees up associated resources.
  111966. */
  111967. dispose(): void;
  111968. protected _createRenderTargets(): void;
  111969. }
  111970. }
  111971. declare module BABYLON {
  111972. interface Scene {
  111973. /** @hidden (Backing field) */
  111974. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111975. /**
  111976. * Gets or Sets the current geometry buffer associated to the scene.
  111977. */
  111978. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111979. /**
  111980. * Enables a GeometryBufferRender and associates it with the scene
  111981. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111982. * @returns the GeometryBufferRenderer
  111983. */
  111984. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  111985. /**
  111986. * Disables the GeometryBufferRender associated with the scene
  111987. */
  111988. disableGeometryBufferRenderer(): void;
  111989. }
  111990. /**
  111991. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  111992. * in several rendering techniques.
  111993. */
  111994. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  111995. /**
  111996. * The component name helpful to identify the component in the list of scene components.
  111997. */
  111998. readonly name: string;
  111999. /**
  112000. * The scene the component belongs to.
  112001. */
  112002. scene: Scene;
  112003. /**
  112004. * Creates a new instance of the component for the given scene
  112005. * @param scene Defines the scene to register the component in
  112006. */
  112007. constructor(scene: Scene);
  112008. /**
  112009. * Registers the component in a given scene
  112010. */
  112011. register(): void;
  112012. /**
  112013. * Rebuilds the elements related to this component in case of
  112014. * context lost for instance.
  112015. */
  112016. rebuild(): void;
  112017. /**
  112018. * Disposes the component and the associated ressources
  112019. */
  112020. dispose(): void;
  112021. private _gatherRenderTargets;
  112022. }
  112023. }
  112024. declare module BABYLON {
  112025. /** @hidden */
  112026. export var motionBlurPixelShader: {
  112027. name: string;
  112028. shader: string;
  112029. };
  112030. }
  112031. declare module BABYLON {
  112032. /**
  112033. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112034. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112035. * As an example, all you have to do is to create the post-process:
  112036. * var mb = new BABYLON.MotionBlurPostProcess(
  112037. * 'mb', // The name of the effect.
  112038. * scene, // The scene containing the objects to blur according to their velocity.
  112039. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112040. * camera // The camera to apply the render pass to.
  112041. * );
  112042. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112043. */
  112044. export class MotionBlurPostProcess extends PostProcess {
  112045. /**
  112046. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112047. */
  112048. motionStrength: number;
  112049. /**
  112050. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112051. */
  112052. /**
  112053. * Sets the number of iterations to be used for motion blur quality
  112054. */
  112055. motionBlurSamples: number;
  112056. private _motionBlurSamples;
  112057. private _geometryBufferRenderer;
  112058. /**
  112059. * Creates a new instance MotionBlurPostProcess
  112060. * @param name The name of the effect.
  112061. * @param scene The scene containing the objects to blur according to their velocity.
  112062. * @param options The required width/height ratio to downsize to before computing the render pass.
  112063. * @param camera The camera to apply the render pass to.
  112064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112065. * @param engine The engine which the post process will be applied. (default: current engine)
  112066. * @param reusable If the post process can be reused on the same frame. (default: false)
  112067. * @param textureType Type of textures used when performing the post process. (default: 0)
  112068. * @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)
  112069. */
  112070. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112071. /**
  112072. * Disposes the post process.
  112073. * @param camera The camera to dispose the post process on.
  112074. */
  112075. dispose(camera?: Camera): void;
  112076. }
  112077. }
  112078. declare module BABYLON {
  112079. /** @hidden */
  112080. export var refractionPixelShader: {
  112081. name: string;
  112082. shader: string;
  112083. };
  112084. }
  112085. declare module BABYLON {
  112086. /**
  112087. * Post process which applies a refractin texture
  112088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112089. */
  112090. export class RefractionPostProcess extends PostProcess {
  112091. /** the base color of the refraction (used to taint the rendering) */
  112092. color: Color3;
  112093. /** simulated refraction depth */
  112094. depth: number;
  112095. /** the coefficient of the base color (0 to remove base color tainting) */
  112096. colorLevel: number;
  112097. private _refTexture;
  112098. private _ownRefractionTexture;
  112099. /**
  112100. * Gets or sets the refraction texture
  112101. * Please note that you are responsible for disposing the texture if you set it manually
  112102. */
  112103. refractionTexture: Texture;
  112104. /**
  112105. * Initializes the RefractionPostProcess
  112106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112107. * @param name The name of the effect.
  112108. * @param refractionTextureUrl Url of the refraction texture to use
  112109. * @param color the base color of the refraction (used to taint the rendering)
  112110. * @param depth simulated refraction depth
  112111. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112112. * @param camera The camera to apply the render pass to.
  112113. * @param options The required width/height ratio to downsize to before computing the render pass.
  112114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112115. * @param engine The engine which the post process will be applied. (default: current engine)
  112116. * @param reusable If the post process can be reused on the same frame. (default: false)
  112117. */
  112118. constructor(name: string, refractionTextureUrl: string,
  112119. /** the base color of the refraction (used to taint the rendering) */
  112120. color: Color3,
  112121. /** simulated refraction depth */
  112122. depth: number,
  112123. /** the coefficient of the base color (0 to remove base color tainting) */
  112124. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112125. /**
  112126. * Disposes of the post process
  112127. * @param camera Camera to dispose post process on
  112128. */
  112129. dispose(camera: Camera): void;
  112130. }
  112131. }
  112132. declare module BABYLON {
  112133. /** @hidden */
  112134. export var sharpenPixelShader: {
  112135. name: string;
  112136. shader: string;
  112137. };
  112138. }
  112139. declare module BABYLON {
  112140. /**
  112141. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112142. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112143. */
  112144. export class SharpenPostProcess extends PostProcess {
  112145. /**
  112146. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112147. */
  112148. colorAmount: number;
  112149. /**
  112150. * How much sharpness should be applied (default: 0.3)
  112151. */
  112152. edgeAmount: number;
  112153. /**
  112154. * Creates a new instance ConvolutionPostProcess
  112155. * @param name The name of the effect.
  112156. * @param options The required width/height ratio to downsize to before computing the render pass.
  112157. * @param camera The camera to apply the render pass to.
  112158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112159. * @param engine The engine which the post process will be applied. (default: current engine)
  112160. * @param reusable If the post process can be reused on the same frame. (default: false)
  112161. * @param textureType Type of textures used when performing the post process. (default: 0)
  112162. * @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)
  112163. */
  112164. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112165. }
  112166. }
  112167. declare module BABYLON {
  112168. /**
  112169. * PostProcessRenderPipeline
  112170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112171. */
  112172. export class PostProcessRenderPipeline {
  112173. private engine;
  112174. private _renderEffects;
  112175. private _renderEffectsForIsolatedPass;
  112176. /**
  112177. * List of inspectable custom properties (used by the Inspector)
  112178. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112179. */
  112180. inspectableCustomProperties: IInspectable[];
  112181. /**
  112182. * @hidden
  112183. */
  112184. protected _cameras: Camera[];
  112185. /** @hidden */
  112186. _name: string;
  112187. /**
  112188. * Gets pipeline name
  112189. */
  112190. readonly name: string;
  112191. /**
  112192. * Initializes a PostProcessRenderPipeline
  112193. * @param engine engine to add the pipeline to
  112194. * @param name name of the pipeline
  112195. */
  112196. constructor(engine: Engine, name: string);
  112197. /**
  112198. * Gets the class name
  112199. * @returns "PostProcessRenderPipeline"
  112200. */
  112201. getClassName(): string;
  112202. /**
  112203. * If all the render effects in the pipeline are supported
  112204. */
  112205. readonly isSupported: boolean;
  112206. /**
  112207. * Adds an effect to the pipeline
  112208. * @param renderEffect the effect to add
  112209. */
  112210. addEffect(renderEffect: PostProcessRenderEffect): void;
  112211. /** @hidden */
  112212. _rebuild(): void;
  112213. /** @hidden */
  112214. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112215. /** @hidden */
  112216. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112217. /** @hidden */
  112218. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112219. /** @hidden */
  112220. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112221. /** @hidden */
  112222. _attachCameras(cameras: Camera, unique: boolean): void;
  112223. /** @hidden */
  112224. _attachCameras(cameras: Camera[], unique: boolean): void;
  112225. /** @hidden */
  112226. _detachCameras(cameras: Camera): void;
  112227. /** @hidden */
  112228. _detachCameras(cameras: Nullable<Camera[]>): void;
  112229. /** @hidden */
  112230. _update(): void;
  112231. /** @hidden */
  112232. _reset(): void;
  112233. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112234. /**
  112235. * Disposes of the pipeline
  112236. */
  112237. dispose(): void;
  112238. }
  112239. }
  112240. declare module BABYLON {
  112241. /**
  112242. * PostProcessRenderPipelineManager class
  112243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112244. */
  112245. export class PostProcessRenderPipelineManager {
  112246. private _renderPipelines;
  112247. /**
  112248. * Initializes a PostProcessRenderPipelineManager
  112249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112250. */
  112251. constructor();
  112252. /**
  112253. * Gets the list of supported render pipelines
  112254. */
  112255. readonly supportedPipelines: PostProcessRenderPipeline[];
  112256. /**
  112257. * Adds a pipeline to the manager
  112258. * @param renderPipeline The pipeline to add
  112259. */
  112260. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112261. /**
  112262. * Attaches a camera to the pipeline
  112263. * @param renderPipelineName The name of the pipeline to attach to
  112264. * @param cameras the camera to attach
  112265. * @param unique if the camera can be attached multiple times to the pipeline
  112266. */
  112267. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112268. /**
  112269. * Detaches a camera from the pipeline
  112270. * @param renderPipelineName The name of the pipeline to detach from
  112271. * @param cameras the camera to detach
  112272. */
  112273. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112274. /**
  112275. * Enables an effect by name on a pipeline
  112276. * @param renderPipelineName the name of the pipeline to enable the effect in
  112277. * @param renderEffectName the name of the effect to enable
  112278. * @param cameras the cameras that the effect should be enabled on
  112279. */
  112280. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112281. /**
  112282. * Disables an effect by name on a pipeline
  112283. * @param renderPipelineName the name of the pipeline to disable the effect in
  112284. * @param renderEffectName the name of the effect to disable
  112285. * @param cameras the cameras that the effect should be disabled on
  112286. */
  112287. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112288. /**
  112289. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112290. */
  112291. update(): void;
  112292. /** @hidden */
  112293. _rebuild(): void;
  112294. /**
  112295. * Disposes of the manager and pipelines
  112296. */
  112297. dispose(): void;
  112298. }
  112299. }
  112300. declare module BABYLON {
  112301. interface Scene {
  112302. /** @hidden (Backing field) */
  112303. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112304. /**
  112305. * Gets the postprocess render pipeline manager
  112306. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112307. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112308. */
  112309. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112310. }
  112311. /**
  112312. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112313. */
  112314. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112315. /**
  112316. * The component name helpfull to identify the component in the list of scene components.
  112317. */
  112318. readonly name: string;
  112319. /**
  112320. * The scene the component belongs to.
  112321. */
  112322. scene: Scene;
  112323. /**
  112324. * Creates a new instance of the component for the given scene
  112325. * @param scene Defines the scene to register the component in
  112326. */
  112327. constructor(scene: Scene);
  112328. /**
  112329. * Registers the component in a given scene
  112330. */
  112331. register(): void;
  112332. /**
  112333. * Rebuilds the elements related to this component in case of
  112334. * context lost for instance.
  112335. */
  112336. rebuild(): void;
  112337. /**
  112338. * Disposes the component and the associated ressources
  112339. */
  112340. dispose(): void;
  112341. private _gatherRenderTargets;
  112342. }
  112343. }
  112344. declare module BABYLON {
  112345. /**
  112346. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112347. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112348. */
  112349. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112350. private _scene;
  112351. private _camerasToBeAttached;
  112352. /**
  112353. * ID of the sharpen post process,
  112354. */
  112355. private readonly SharpenPostProcessId;
  112356. /**
  112357. * @ignore
  112358. * ID of the image processing post process;
  112359. */
  112360. readonly ImageProcessingPostProcessId: string;
  112361. /**
  112362. * @ignore
  112363. * ID of the Fast Approximate Anti-Aliasing post process;
  112364. */
  112365. readonly FxaaPostProcessId: string;
  112366. /**
  112367. * ID of the chromatic aberration post process,
  112368. */
  112369. private readonly ChromaticAberrationPostProcessId;
  112370. /**
  112371. * ID of the grain post process
  112372. */
  112373. private readonly GrainPostProcessId;
  112374. /**
  112375. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112376. */
  112377. sharpen: SharpenPostProcess;
  112378. private _sharpenEffect;
  112379. private bloom;
  112380. /**
  112381. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112382. */
  112383. depthOfField: DepthOfFieldEffect;
  112384. /**
  112385. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112386. */
  112387. fxaa: FxaaPostProcess;
  112388. /**
  112389. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112390. */
  112391. imageProcessing: ImageProcessingPostProcess;
  112392. /**
  112393. * Chromatic aberration post process which will shift rgb colors in the image
  112394. */
  112395. chromaticAberration: ChromaticAberrationPostProcess;
  112396. private _chromaticAberrationEffect;
  112397. /**
  112398. * Grain post process which add noise to the image
  112399. */
  112400. grain: GrainPostProcess;
  112401. private _grainEffect;
  112402. /**
  112403. * Glow post process which adds a glow to emissive areas of the image
  112404. */
  112405. private _glowLayer;
  112406. /**
  112407. * Animations which can be used to tweak settings over a period of time
  112408. */
  112409. animations: Animation[];
  112410. private _imageProcessingConfigurationObserver;
  112411. private _sharpenEnabled;
  112412. private _bloomEnabled;
  112413. private _depthOfFieldEnabled;
  112414. private _depthOfFieldBlurLevel;
  112415. private _fxaaEnabled;
  112416. private _imageProcessingEnabled;
  112417. private _defaultPipelineTextureType;
  112418. private _bloomScale;
  112419. private _chromaticAberrationEnabled;
  112420. private _grainEnabled;
  112421. private _buildAllowed;
  112422. /**
  112423. * Gets active scene
  112424. */
  112425. readonly scene: Scene;
  112426. /**
  112427. * Enable or disable the sharpen process from the pipeline
  112428. */
  112429. sharpenEnabled: boolean;
  112430. private _resizeObserver;
  112431. private _hardwareScaleLevel;
  112432. private _bloomKernel;
  112433. /**
  112434. * Specifies the size of the bloom blur kernel, relative to the final output size
  112435. */
  112436. bloomKernel: number;
  112437. /**
  112438. * Specifies the weight of the bloom in the final rendering
  112439. */
  112440. private _bloomWeight;
  112441. /**
  112442. * Specifies the luma threshold for the area that will be blurred by the bloom
  112443. */
  112444. private _bloomThreshold;
  112445. private _hdr;
  112446. /**
  112447. * The strength of the bloom.
  112448. */
  112449. bloomWeight: number;
  112450. /**
  112451. * The strength of the bloom.
  112452. */
  112453. bloomThreshold: number;
  112454. /**
  112455. * The scale of the bloom, lower value will provide better performance.
  112456. */
  112457. bloomScale: number;
  112458. /**
  112459. * Enable or disable the bloom from the pipeline
  112460. */
  112461. bloomEnabled: boolean;
  112462. private _rebuildBloom;
  112463. /**
  112464. * If the depth of field is enabled.
  112465. */
  112466. depthOfFieldEnabled: boolean;
  112467. /**
  112468. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112469. */
  112470. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112471. /**
  112472. * If the anti aliasing is enabled.
  112473. */
  112474. fxaaEnabled: boolean;
  112475. private _samples;
  112476. /**
  112477. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112478. */
  112479. samples: number;
  112480. /**
  112481. * If image processing is enabled.
  112482. */
  112483. imageProcessingEnabled: boolean;
  112484. /**
  112485. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112486. */
  112487. glowLayerEnabled: boolean;
  112488. /**
  112489. * Enable or disable the chromaticAberration process from the pipeline
  112490. */
  112491. chromaticAberrationEnabled: boolean;
  112492. /**
  112493. * Enable or disable the grain process from the pipeline
  112494. */
  112495. grainEnabled: boolean;
  112496. /**
  112497. * @constructor
  112498. * @param name - The rendering pipeline name (default: "")
  112499. * @param hdr - If high dynamic range textures should be used (default: true)
  112500. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112501. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112502. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112503. */
  112504. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112505. /**
  112506. * Get the class name
  112507. * @returns "DefaultRenderingPipeline"
  112508. */
  112509. getClassName(): string;
  112510. /**
  112511. * Force the compilation of the entire pipeline.
  112512. */
  112513. prepare(): void;
  112514. private _hasCleared;
  112515. private _prevPostProcess;
  112516. private _prevPrevPostProcess;
  112517. private _setAutoClearAndTextureSharing;
  112518. private _depthOfFieldSceneObserver;
  112519. private _buildPipeline;
  112520. private _disposePostProcesses;
  112521. /**
  112522. * Adds a camera to the pipeline
  112523. * @param camera the camera to be added
  112524. */
  112525. addCamera(camera: Camera): void;
  112526. /**
  112527. * Removes a camera from the pipeline
  112528. * @param camera the camera to remove
  112529. */
  112530. removeCamera(camera: Camera): void;
  112531. /**
  112532. * Dispose of the pipeline and stop all post processes
  112533. */
  112534. dispose(): void;
  112535. /**
  112536. * Serialize the rendering pipeline (Used when exporting)
  112537. * @returns the serialized object
  112538. */
  112539. serialize(): any;
  112540. /**
  112541. * Parse the serialized pipeline
  112542. * @param source Source pipeline.
  112543. * @param scene The scene to load the pipeline to.
  112544. * @param rootUrl The URL of the serialized pipeline.
  112545. * @returns An instantiated pipeline from the serialized object.
  112546. */
  112547. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112548. }
  112549. }
  112550. declare module BABYLON {
  112551. /** @hidden */
  112552. export var lensHighlightsPixelShader: {
  112553. name: string;
  112554. shader: string;
  112555. };
  112556. }
  112557. declare module BABYLON {
  112558. /** @hidden */
  112559. export var depthOfFieldPixelShader: {
  112560. name: string;
  112561. shader: string;
  112562. };
  112563. }
  112564. declare module BABYLON {
  112565. /**
  112566. * BABYLON.JS Chromatic Aberration GLSL Shader
  112567. * Author: Olivier Guyot
  112568. * Separates very slightly R, G and B colors on the edges of the screen
  112569. * Inspired by Francois Tarlier & Martins Upitis
  112570. */
  112571. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112572. /**
  112573. * @ignore
  112574. * The chromatic aberration PostProcess id in the pipeline
  112575. */
  112576. LensChromaticAberrationEffect: string;
  112577. /**
  112578. * @ignore
  112579. * The highlights enhancing PostProcess id in the pipeline
  112580. */
  112581. HighlightsEnhancingEffect: string;
  112582. /**
  112583. * @ignore
  112584. * The depth-of-field PostProcess id in the pipeline
  112585. */
  112586. LensDepthOfFieldEffect: string;
  112587. private _scene;
  112588. private _depthTexture;
  112589. private _grainTexture;
  112590. private _chromaticAberrationPostProcess;
  112591. private _highlightsPostProcess;
  112592. private _depthOfFieldPostProcess;
  112593. private _edgeBlur;
  112594. private _grainAmount;
  112595. private _chromaticAberration;
  112596. private _distortion;
  112597. private _highlightsGain;
  112598. private _highlightsThreshold;
  112599. private _dofDistance;
  112600. private _dofAperture;
  112601. private _dofDarken;
  112602. private _dofPentagon;
  112603. private _blurNoise;
  112604. /**
  112605. * @constructor
  112606. *
  112607. * Effect parameters are as follow:
  112608. * {
  112609. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112610. * edge_blur: number; // from 0 to x (1 for realism)
  112611. * distortion: number; // from 0 to x (1 for realism)
  112612. * grain_amount: number; // from 0 to 1
  112613. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112614. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112615. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112616. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112617. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112618. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112619. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112620. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112621. * }
  112622. * Note: if an effect parameter is unset, effect is disabled
  112623. *
  112624. * @param name The rendering pipeline name
  112625. * @param parameters - An object containing all parameters (see above)
  112626. * @param scene The scene linked to this pipeline
  112627. * @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)
  112628. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112629. */
  112630. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112631. /**
  112632. * Get the class name
  112633. * @returns "LensRenderingPipeline"
  112634. */
  112635. getClassName(): string;
  112636. /**
  112637. * Gets associated scene
  112638. */
  112639. readonly scene: Scene;
  112640. /**
  112641. * Gets or sets the edge blur
  112642. */
  112643. edgeBlur: number;
  112644. /**
  112645. * Gets or sets the grain amount
  112646. */
  112647. grainAmount: number;
  112648. /**
  112649. * Gets or sets the chromatic aberration amount
  112650. */
  112651. chromaticAberration: number;
  112652. /**
  112653. * Gets or sets the depth of field aperture
  112654. */
  112655. dofAperture: number;
  112656. /**
  112657. * Gets or sets the edge distortion
  112658. */
  112659. edgeDistortion: number;
  112660. /**
  112661. * Gets or sets the depth of field distortion
  112662. */
  112663. dofDistortion: number;
  112664. /**
  112665. * Gets or sets the darken out of focus amount
  112666. */
  112667. darkenOutOfFocus: number;
  112668. /**
  112669. * Gets or sets a boolean indicating if blur noise is enabled
  112670. */
  112671. blurNoise: boolean;
  112672. /**
  112673. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112674. */
  112675. pentagonBokeh: boolean;
  112676. /**
  112677. * Gets or sets the highlight grain amount
  112678. */
  112679. highlightsGain: number;
  112680. /**
  112681. * Gets or sets the highlight threshold
  112682. */
  112683. highlightsThreshold: number;
  112684. /**
  112685. * Sets the amount of blur at the edges
  112686. * @param amount blur amount
  112687. */
  112688. setEdgeBlur(amount: number): void;
  112689. /**
  112690. * Sets edge blur to 0
  112691. */
  112692. disableEdgeBlur(): void;
  112693. /**
  112694. * Sets the amout of grain
  112695. * @param amount Amount of grain
  112696. */
  112697. setGrainAmount(amount: number): void;
  112698. /**
  112699. * Set grain amount to 0
  112700. */
  112701. disableGrain(): void;
  112702. /**
  112703. * Sets the chromatic aberration amount
  112704. * @param amount amount of chromatic aberration
  112705. */
  112706. setChromaticAberration(amount: number): void;
  112707. /**
  112708. * Sets chromatic aberration amount to 0
  112709. */
  112710. disableChromaticAberration(): void;
  112711. /**
  112712. * Sets the EdgeDistortion amount
  112713. * @param amount amount of EdgeDistortion
  112714. */
  112715. setEdgeDistortion(amount: number): void;
  112716. /**
  112717. * Sets edge distortion to 0
  112718. */
  112719. disableEdgeDistortion(): void;
  112720. /**
  112721. * Sets the FocusDistance amount
  112722. * @param amount amount of FocusDistance
  112723. */
  112724. setFocusDistance(amount: number): void;
  112725. /**
  112726. * Disables depth of field
  112727. */
  112728. disableDepthOfField(): void;
  112729. /**
  112730. * Sets the Aperture amount
  112731. * @param amount amount of Aperture
  112732. */
  112733. setAperture(amount: number): void;
  112734. /**
  112735. * Sets the DarkenOutOfFocus amount
  112736. * @param amount amount of DarkenOutOfFocus
  112737. */
  112738. setDarkenOutOfFocus(amount: number): void;
  112739. private _pentagonBokehIsEnabled;
  112740. /**
  112741. * Creates a pentagon bokeh effect
  112742. */
  112743. enablePentagonBokeh(): void;
  112744. /**
  112745. * Disables the pentagon bokeh effect
  112746. */
  112747. disablePentagonBokeh(): void;
  112748. /**
  112749. * Enables noise blur
  112750. */
  112751. enableNoiseBlur(): void;
  112752. /**
  112753. * Disables noise blur
  112754. */
  112755. disableNoiseBlur(): void;
  112756. /**
  112757. * Sets the HighlightsGain amount
  112758. * @param amount amount of HighlightsGain
  112759. */
  112760. setHighlightsGain(amount: number): void;
  112761. /**
  112762. * Sets the HighlightsThreshold amount
  112763. * @param amount amount of HighlightsThreshold
  112764. */
  112765. setHighlightsThreshold(amount: number): void;
  112766. /**
  112767. * Disables highlights
  112768. */
  112769. disableHighlights(): void;
  112770. /**
  112771. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112772. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112773. */
  112774. dispose(disableDepthRender?: boolean): void;
  112775. private _createChromaticAberrationPostProcess;
  112776. private _createHighlightsPostProcess;
  112777. private _createDepthOfFieldPostProcess;
  112778. private _createGrainTexture;
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /** @hidden */
  112783. export var ssao2PixelShader: {
  112784. name: string;
  112785. shader: string;
  112786. };
  112787. }
  112788. declare module BABYLON {
  112789. /** @hidden */
  112790. export var ssaoCombinePixelShader: {
  112791. name: string;
  112792. shader: string;
  112793. };
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Render pipeline to produce ssao effect
  112798. */
  112799. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112800. /**
  112801. * @ignore
  112802. * The PassPostProcess id in the pipeline that contains the original scene color
  112803. */
  112804. SSAOOriginalSceneColorEffect: string;
  112805. /**
  112806. * @ignore
  112807. * The SSAO PostProcess id in the pipeline
  112808. */
  112809. SSAORenderEffect: string;
  112810. /**
  112811. * @ignore
  112812. * The horizontal blur PostProcess id in the pipeline
  112813. */
  112814. SSAOBlurHRenderEffect: string;
  112815. /**
  112816. * @ignore
  112817. * The vertical blur PostProcess id in the pipeline
  112818. */
  112819. SSAOBlurVRenderEffect: string;
  112820. /**
  112821. * @ignore
  112822. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112823. */
  112824. SSAOCombineRenderEffect: string;
  112825. /**
  112826. * The output strength of the SSAO post-process. Default value is 1.0.
  112827. */
  112828. totalStrength: number;
  112829. /**
  112830. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112831. */
  112832. maxZ: number;
  112833. /**
  112834. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112835. */
  112836. minZAspect: number;
  112837. private _samples;
  112838. /**
  112839. * Number of samples used for the SSAO calculations. Default value is 8
  112840. */
  112841. samples: number;
  112842. private _textureSamples;
  112843. /**
  112844. * Number of samples to use for antialiasing
  112845. */
  112846. textureSamples: number;
  112847. /**
  112848. * Ratio object used for SSAO ratio and blur ratio
  112849. */
  112850. private _ratio;
  112851. /**
  112852. * Dynamically generated sphere sampler.
  112853. */
  112854. private _sampleSphere;
  112855. /**
  112856. * Blur filter offsets
  112857. */
  112858. private _samplerOffsets;
  112859. private _expensiveBlur;
  112860. /**
  112861. * If bilateral blur should be used
  112862. */
  112863. expensiveBlur: boolean;
  112864. /**
  112865. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112866. */
  112867. radius: number;
  112868. /**
  112869. * The base color of the SSAO post-process
  112870. * The final result is "base + ssao" between [0, 1]
  112871. */
  112872. base: number;
  112873. /**
  112874. * Support test.
  112875. */
  112876. static readonly IsSupported: boolean;
  112877. private _scene;
  112878. private _depthTexture;
  112879. private _normalTexture;
  112880. private _randomTexture;
  112881. private _originalColorPostProcess;
  112882. private _ssaoPostProcess;
  112883. private _blurHPostProcess;
  112884. private _blurVPostProcess;
  112885. private _ssaoCombinePostProcess;
  112886. private _firstUpdate;
  112887. /**
  112888. * Gets active scene
  112889. */
  112890. readonly scene: Scene;
  112891. /**
  112892. * @constructor
  112893. * @param name The rendering pipeline name
  112894. * @param scene The scene linked to this pipeline
  112895. * @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 }
  112896. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112897. */
  112898. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112899. /**
  112900. * Get the class name
  112901. * @returns "SSAO2RenderingPipeline"
  112902. */
  112903. getClassName(): string;
  112904. /**
  112905. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112906. */
  112907. dispose(disableGeometryBufferRenderer?: boolean): void;
  112908. private _createBlurPostProcess;
  112909. /** @hidden */
  112910. _rebuild(): void;
  112911. private _bits;
  112912. private _radicalInverse_VdC;
  112913. private _hammersley;
  112914. private _hemisphereSample_uniform;
  112915. private _generateHemisphere;
  112916. private _createSSAOPostProcess;
  112917. private _createSSAOCombinePostProcess;
  112918. private _createRandomTexture;
  112919. /**
  112920. * Serialize the rendering pipeline (Used when exporting)
  112921. * @returns the serialized object
  112922. */
  112923. serialize(): any;
  112924. /**
  112925. * Parse the serialized pipeline
  112926. * @param source Source pipeline.
  112927. * @param scene The scene to load the pipeline to.
  112928. * @param rootUrl The URL of the serialized pipeline.
  112929. * @returns An instantiated pipeline from the serialized object.
  112930. */
  112931. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112932. }
  112933. }
  112934. declare module BABYLON {
  112935. /** @hidden */
  112936. export var ssaoPixelShader: {
  112937. name: string;
  112938. shader: string;
  112939. };
  112940. }
  112941. declare module BABYLON {
  112942. /**
  112943. * Render pipeline to produce ssao effect
  112944. */
  112945. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112946. /**
  112947. * @ignore
  112948. * The PassPostProcess id in the pipeline that contains the original scene color
  112949. */
  112950. SSAOOriginalSceneColorEffect: string;
  112951. /**
  112952. * @ignore
  112953. * The SSAO PostProcess id in the pipeline
  112954. */
  112955. SSAORenderEffect: string;
  112956. /**
  112957. * @ignore
  112958. * The horizontal blur PostProcess id in the pipeline
  112959. */
  112960. SSAOBlurHRenderEffect: string;
  112961. /**
  112962. * @ignore
  112963. * The vertical blur PostProcess id in the pipeline
  112964. */
  112965. SSAOBlurVRenderEffect: string;
  112966. /**
  112967. * @ignore
  112968. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112969. */
  112970. SSAOCombineRenderEffect: string;
  112971. /**
  112972. * The output strength of the SSAO post-process. Default value is 1.0.
  112973. */
  112974. totalStrength: number;
  112975. /**
  112976. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112977. */
  112978. radius: number;
  112979. /**
  112980. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112981. * Must not be equal to fallOff and superior to fallOff.
  112982. * Default value is 0.0075
  112983. */
  112984. area: number;
  112985. /**
  112986. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  112987. * Must not be equal to area and inferior to area.
  112988. * Default value is 0.000001
  112989. */
  112990. fallOff: number;
  112991. /**
  112992. * The base color of the SSAO post-process
  112993. * The final result is "base + ssao" between [0, 1]
  112994. */
  112995. base: number;
  112996. private _scene;
  112997. private _depthTexture;
  112998. private _randomTexture;
  112999. private _originalColorPostProcess;
  113000. private _ssaoPostProcess;
  113001. private _blurHPostProcess;
  113002. private _blurVPostProcess;
  113003. private _ssaoCombinePostProcess;
  113004. private _firstUpdate;
  113005. /**
  113006. * Gets active scene
  113007. */
  113008. readonly scene: Scene;
  113009. /**
  113010. * @constructor
  113011. * @param name - The rendering pipeline name
  113012. * @param scene - The scene linked to this pipeline
  113013. * @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 }
  113014. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113015. */
  113016. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113017. /**
  113018. * Get the class name
  113019. * @returns "SSAORenderingPipeline"
  113020. */
  113021. getClassName(): string;
  113022. /**
  113023. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113024. */
  113025. dispose(disableDepthRender?: boolean): void;
  113026. private _createBlurPostProcess;
  113027. /** @hidden */
  113028. _rebuild(): void;
  113029. private _createSSAOPostProcess;
  113030. private _createSSAOCombinePostProcess;
  113031. private _createRandomTexture;
  113032. }
  113033. }
  113034. declare module BABYLON {
  113035. /** @hidden */
  113036. export var standardPixelShader: {
  113037. name: string;
  113038. shader: string;
  113039. };
  113040. }
  113041. declare module BABYLON {
  113042. /**
  113043. * Standard rendering pipeline
  113044. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113045. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113046. */
  113047. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113048. /**
  113049. * Public members
  113050. */
  113051. /**
  113052. * Post-process which contains the original scene color before the pipeline applies all the effects
  113053. */
  113054. originalPostProcess: Nullable<PostProcess>;
  113055. /**
  113056. * Post-process used to down scale an image x4
  113057. */
  113058. downSampleX4PostProcess: Nullable<PostProcess>;
  113059. /**
  113060. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113061. */
  113062. brightPassPostProcess: Nullable<PostProcess>;
  113063. /**
  113064. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113065. */
  113066. blurHPostProcesses: PostProcess[];
  113067. /**
  113068. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113069. */
  113070. blurVPostProcesses: PostProcess[];
  113071. /**
  113072. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113073. */
  113074. textureAdderPostProcess: Nullable<PostProcess>;
  113075. /**
  113076. * Post-process used to create volumetric lighting effect
  113077. */
  113078. volumetricLightPostProcess: Nullable<PostProcess>;
  113079. /**
  113080. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113081. */
  113082. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113083. /**
  113084. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113085. */
  113086. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113087. /**
  113088. * Post-process used to merge the volumetric light effect and the real scene color
  113089. */
  113090. volumetricLightMergePostProces: Nullable<PostProcess>;
  113091. /**
  113092. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113093. */
  113094. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113095. /**
  113096. * Base post-process used to calculate the average luminance of the final image for HDR
  113097. */
  113098. luminancePostProcess: Nullable<PostProcess>;
  113099. /**
  113100. * Post-processes used to create down sample post-processes in order to get
  113101. * the average luminance of the final image for HDR
  113102. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113103. */
  113104. luminanceDownSamplePostProcesses: PostProcess[];
  113105. /**
  113106. * Post-process used to create a HDR effect (light adaptation)
  113107. */
  113108. hdrPostProcess: Nullable<PostProcess>;
  113109. /**
  113110. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113111. */
  113112. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113113. /**
  113114. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113115. */
  113116. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113117. /**
  113118. * Post-process used to merge the final HDR post-process and the real scene color
  113119. */
  113120. hdrFinalPostProcess: Nullable<PostProcess>;
  113121. /**
  113122. * Post-process used to create a lens flare effect
  113123. */
  113124. lensFlarePostProcess: Nullable<PostProcess>;
  113125. /**
  113126. * Post-process that merges the result of the lens flare post-process and the real scene color
  113127. */
  113128. lensFlareComposePostProcess: Nullable<PostProcess>;
  113129. /**
  113130. * Post-process used to create a motion blur effect
  113131. */
  113132. motionBlurPostProcess: Nullable<PostProcess>;
  113133. /**
  113134. * Post-process used to create a depth of field effect
  113135. */
  113136. depthOfFieldPostProcess: Nullable<PostProcess>;
  113137. /**
  113138. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113139. */
  113140. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113141. /**
  113142. * Represents the brightness threshold in order to configure the illuminated surfaces
  113143. */
  113144. brightThreshold: number;
  113145. /**
  113146. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113147. */
  113148. blurWidth: number;
  113149. /**
  113150. * Sets if the blur for highlighted surfaces must be only horizontal
  113151. */
  113152. horizontalBlur: boolean;
  113153. /**
  113154. * Gets the overall exposure used by the pipeline
  113155. */
  113156. /**
  113157. * Sets the overall exposure used by the pipeline
  113158. */
  113159. exposure: number;
  113160. /**
  113161. * Texture used typically to simulate "dirty" on camera lens
  113162. */
  113163. lensTexture: Nullable<Texture>;
  113164. /**
  113165. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113166. */
  113167. volumetricLightCoefficient: number;
  113168. /**
  113169. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113170. */
  113171. volumetricLightPower: number;
  113172. /**
  113173. * Used the set the blur intensity to smooth the volumetric lights
  113174. */
  113175. volumetricLightBlurScale: number;
  113176. /**
  113177. * Light (spot or directional) used to generate the volumetric lights rays
  113178. * The source light must have a shadow generate so the pipeline can get its
  113179. * depth map
  113180. */
  113181. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113182. /**
  113183. * For eye adaptation, represents the minimum luminance the eye can see
  113184. */
  113185. hdrMinimumLuminance: number;
  113186. /**
  113187. * For eye adaptation, represents the decrease luminance speed
  113188. */
  113189. hdrDecreaseRate: number;
  113190. /**
  113191. * For eye adaptation, represents the increase luminance speed
  113192. */
  113193. hdrIncreaseRate: number;
  113194. /**
  113195. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113196. */
  113197. /**
  113198. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113199. */
  113200. hdrAutoExposure: boolean;
  113201. /**
  113202. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113203. */
  113204. lensColorTexture: Nullable<Texture>;
  113205. /**
  113206. * The overall strengh for the lens flare effect
  113207. */
  113208. lensFlareStrength: number;
  113209. /**
  113210. * Dispersion coefficient for lens flare ghosts
  113211. */
  113212. lensFlareGhostDispersal: number;
  113213. /**
  113214. * Main lens flare halo width
  113215. */
  113216. lensFlareHaloWidth: number;
  113217. /**
  113218. * Based on the lens distortion effect, defines how much the lens flare result
  113219. * is distorted
  113220. */
  113221. lensFlareDistortionStrength: number;
  113222. /**
  113223. * Lens star texture must be used to simulate rays on the flares and is available
  113224. * in the documentation
  113225. */
  113226. lensStarTexture: Nullable<Texture>;
  113227. /**
  113228. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113229. * flare effect by taking account of the dirt texture
  113230. */
  113231. lensFlareDirtTexture: Nullable<Texture>;
  113232. /**
  113233. * Represents the focal length for the depth of field effect
  113234. */
  113235. depthOfFieldDistance: number;
  113236. /**
  113237. * Represents the blur intensity for the blurred part of the depth of field effect
  113238. */
  113239. depthOfFieldBlurWidth: number;
  113240. /**
  113241. * For motion blur, defines how much the image is blurred by the movement
  113242. */
  113243. motionStrength: number;
  113244. /**
  113245. * List of animations for the pipeline (IAnimatable implementation)
  113246. */
  113247. animations: Animation[];
  113248. /**
  113249. * Private members
  113250. */
  113251. private _scene;
  113252. private _currentDepthOfFieldSource;
  113253. private _basePostProcess;
  113254. private _fixedExposure;
  113255. private _currentExposure;
  113256. private _hdrAutoExposure;
  113257. private _hdrCurrentLuminance;
  113258. private _floatTextureType;
  113259. private _ratio;
  113260. private _bloomEnabled;
  113261. private _depthOfFieldEnabled;
  113262. private _vlsEnabled;
  113263. private _lensFlareEnabled;
  113264. private _hdrEnabled;
  113265. private _motionBlurEnabled;
  113266. private _fxaaEnabled;
  113267. private _motionBlurSamples;
  113268. private _volumetricLightStepsCount;
  113269. private _samples;
  113270. /**
  113271. * @ignore
  113272. * Specifies if the bloom pipeline is enabled
  113273. */
  113274. BloomEnabled: boolean;
  113275. /**
  113276. * @ignore
  113277. * Specifies if the depth of field pipeline is enabed
  113278. */
  113279. DepthOfFieldEnabled: boolean;
  113280. /**
  113281. * @ignore
  113282. * Specifies if the lens flare pipeline is enabed
  113283. */
  113284. LensFlareEnabled: boolean;
  113285. /**
  113286. * @ignore
  113287. * Specifies if the HDR pipeline is enabled
  113288. */
  113289. HDREnabled: boolean;
  113290. /**
  113291. * @ignore
  113292. * Specifies if the volumetric lights scattering effect is enabled
  113293. */
  113294. VLSEnabled: boolean;
  113295. /**
  113296. * @ignore
  113297. * Specifies if the motion blur effect is enabled
  113298. */
  113299. MotionBlurEnabled: boolean;
  113300. /**
  113301. * Specifies if anti-aliasing is enabled
  113302. */
  113303. fxaaEnabled: boolean;
  113304. /**
  113305. * Specifies the number of steps used to calculate the volumetric lights
  113306. * Typically in interval [50, 200]
  113307. */
  113308. volumetricLightStepsCount: number;
  113309. /**
  113310. * Specifies the number of samples used for the motion blur effect
  113311. * Typically in interval [16, 64]
  113312. */
  113313. motionBlurSamples: number;
  113314. /**
  113315. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113316. */
  113317. samples: number;
  113318. /**
  113319. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113320. * @constructor
  113321. * @param name The rendering pipeline name
  113322. * @param scene The scene linked to this pipeline
  113323. * @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)
  113324. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113325. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113326. */
  113327. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113328. private _buildPipeline;
  113329. private _createDownSampleX4PostProcess;
  113330. private _createBrightPassPostProcess;
  113331. private _createBlurPostProcesses;
  113332. private _createTextureAdderPostProcess;
  113333. private _createVolumetricLightPostProcess;
  113334. private _createLuminancePostProcesses;
  113335. private _createHdrPostProcess;
  113336. private _createLensFlarePostProcess;
  113337. private _createDepthOfFieldPostProcess;
  113338. private _createMotionBlurPostProcess;
  113339. private _getDepthTexture;
  113340. private _disposePostProcesses;
  113341. /**
  113342. * Dispose of the pipeline and stop all post processes
  113343. */
  113344. dispose(): void;
  113345. /**
  113346. * Serialize the rendering pipeline (Used when exporting)
  113347. * @returns the serialized object
  113348. */
  113349. serialize(): any;
  113350. /**
  113351. * Parse the serialized pipeline
  113352. * @param source Source pipeline.
  113353. * @param scene The scene to load the pipeline to.
  113354. * @param rootUrl The URL of the serialized pipeline.
  113355. * @returns An instantiated pipeline from the serialized object.
  113356. */
  113357. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113358. /**
  113359. * Luminance steps
  113360. */
  113361. static LuminanceSteps: number;
  113362. }
  113363. }
  113364. declare module BABYLON {
  113365. /** @hidden */
  113366. export var tonemapPixelShader: {
  113367. name: string;
  113368. shader: string;
  113369. };
  113370. }
  113371. declare module BABYLON {
  113372. /** Defines operator used for tonemapping */
  113373. export enum TonemappingOperator {
  113374. /** Hable */
  113375. Hable = 0,
  113376. /** Reinhard */
  113377. Reinhard = 1,
  113378. /** HejiDawson */
  113379. HejiDawson = 2,
  113380. /** Photographic */
  113381. Photographic = 3
  113382. }
  113383. /**
  113384. * Defines a post process to apply tone mapping
  113385. */
  113386. export class TonemapPostProcess extends PostProcess {
  113387. private _operator;
  113388. /** Defines the required exposure adjustement */
  113389. exposureAdjustment: number;
  113390. /**
  113391. * Creates a new TonemapPostProcess
  113392. * @param name defines the name of the postprocess
  113393. * @param _operator defines the operator to use
  113394. * @param exposureAdjustment defines the required exposure adjustement
  113395. * @param camera defines the camera to use (can be null)
  113396. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113397. * @param engine defines the hosting engine (can be ignore if camera is set)
  113398. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113399. */
  113400. constructor(name: string, _operator: TonemappingOperator,
  113401. /** Defines the required exposure adjustement */
  113402. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113403. }
  113404. }
  113405. declare module BABYLON {
  113406. /** @hidden */
  113407. export var depthVertexShader: {
  113408. name: string;
  113409. shader: string;
  113410. };
  113411. }
  113412. declare module BABYLON {
  113413. /** @hidden */
  113414. export var volumetricLightScatteringPixelShader: {
  113415. name: string;
  113416. shader: string;
  113417. };
  113418. }
  113419. declare module BABYLON {
  113420. /** @hidden */
  113421. export var volumetricLightScatteringPassPixelShader: {
  113422. name: string;
  113423. shader: string;
  113424. };
  113425. }
  113426. declare module BABYLON {
  113427. /**
  113428. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113429. */
  113430. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113431. private _volumetricLightScatteringPass;
  113432. private _volumetricLightScatteringRTT;
  113433. private _viewPort;
  113434. private _screenCoordinates;
  113435. private _cachedDefines;
  113436. /**
  113437. * If not undefined, the mesh position is computed from the attached node position
  113438. */
  113439. attachedNode: {
  113440. position: Vector3;
  113441. };
  113442. /**
  113443. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113444. */
  113445. customMeshPosition: Vector3;
  113446. /**
  113447. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113448. */
  113449. useCustomMeshPosition: boolean;
  113450. /**
  113451. * If the post-process should inverse the light scattering direction
  113452. */
  113453. invert: boolean;
  113454. /**
  113455. * The internal mesh used by the post-process
  113456. */
  113457. mesh: Mesh;
  113458. /**
  113459. * @hidden
  113460. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113461. */
  113462. useDiffuseColor: boolean;
  113463. /**
  113464. * Array containing the excluded meshes not rendered in the internal pass
  113465. */
  113466. excludedMeshes: AbstractMesh[];
  113467. /**
  113468. * Controls the overall intensity of the post-process
  113469. */
  113470. exposure: number;
  113471. /**
  113472. * Dissipates each sample's contribution in range [0, 1]
  113473. */
  113474. decay: number;
  113475. /**
  113476. * Controls the overall intensity of each sample
  113477. */
  113478. weight: number;
  113479. /**
  113480. * Controls the density of each sample
  113481. */
  113482. density: number;
  113483. /**
  113484. * @constructor
  113485. * @param name The post-process name
  113486. * @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)
  113487. * @param camera The camera that the post-process will be attached to
  113488. * @param mesh The mesh used to create the light scattering
  113489. * @param samples The post-process quality, default 100
  113490. * @param samplingModeThe post-process filtering mode
  113491. * @param engine The babylon engine
  113492. * @param reusable If the post-process is reusable
  113493. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113494. */
  113495. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113496. /**
  113497. * Returns the string "VolumetricLightScatteringPostProcess"
  113498. * @returns "VolumetricLightScatteringPostProcess"
  113499. */
  113500. getClassName(): string;
  113501. private _isReady;
  113502. /**
  113503. * Sets the new light position for light scattering effect
  113504. * @param position The new custom light position
  113505. */
  113506. setCustomMeshPosition(position: Vector3): void;
  113507. /**
  113508. * Returns the light position for light scattering effect
  113509. * @return Vector3 The custom light position
  113510. */
  113511. getCustomMeshPosition(): Vector3;
  113512. /**
  113513. * Disposes the internal assets and detaches the post-process from the camera
  113514. */
  113515. dispose(camera: Camera): void;
  113516. /**
  113517. * Returns the render target texture used by the post-process
  113518. * @return the render target texture used by the post-process
  113519. */
  113520. getPass(): RenderTargetTexture;
  113521. private _meshExcluded;
  113522. private _createPass;
  113523. private _updateMeshScreenCoordinates;
  113524. /**
  113525. * Creates a default mesh for the Volumeric Light Scattering post-process
  113526. * @param name The mesh name
  113527. * @param scene The scene where to create the mesh
  113528. * @return the default mesh
  113529. */
  113530. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113531. }
  113532. }
  113533. declare module BABYLON {
  113534. interface Scene {
  113535. /** @hidden (Backing field) */
  113536. _boundingBoxRenderer: BoundingBoxRenderer;
  113537. /** @hidden (Backing field) */
  113538. _forceShowBoundingBoxes: boolean;
  113539. /**
  113540. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113541. */
  113542. forceShowBoundingBoxes: boolean;
  113543. /**
  113544. * Gets the bounding box renderer associated with the scene
  113545. * @returns a BoundingBoxRenderer
  113546. */
  113547. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113548. }
  113549. interface AbstractMesh {
  113550. /** @hidden (Backing field) */
  113551. _showBoundingBox: boolean;
  113552. /**
  113553. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113554. */
  113555. showBoundingBox: boolean;
  113556. }
  113557. /**
  113558. * Component responsible of rendering the bounding box of the meshes in a scene.
  113559. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113560. */
  113561. export class BoundingBoxRenderer implements ISceneComponent {
  113562. /**
  113563. * The component name helpfull to identify the component in the list of scene components.
  113564. */
  113565. readonly name: string;
  113566. /**
  113567. * The scene the component belongs to.
  113568. */
  113569. scene: Scene;
  113570. /**
  113571. * Color of the bounding box lines placed in front of an object
  113572. */
  113573. frontColor: Color3;
  113574. /**
  113575. * Color of the bounding box lines placed behind an object
  113576. */
  113577. backColor: Color3;
  113578. /**
  113579. * Defines if the renderer should show the back lines or not
  113580. */
  113581. showBackLines: boolean;
  113582. /**
  113583. * @hidden
  113584. */
  113585. renderList: SmartArray<BoundingBox>;
  113586. private _colorShader;
  113587. private _vertexBuffers;
  113588. private _indexBuffer;
  113589. /**
  113590. * Instantiates a new bounding box renderer in a scene.
  113591. * @param scene the scene the renderer renders in
  113592. */
  113593. constructor(scene: Scene);
  113594. /**
  113595. * Registers the component in a given scene
  113596. */
  113597. register(): void;
  113598. private _evaluateSubMesh;
  113599. private _activeMesh;
  113600. private _prepareRessources;
  113601. private _createIndexBuffer;
  113602. /**
  113603. * Rebuilds the elements related to this component in case of
  113604. * context lost for instance.
  113605. */
  113606. rebuild(): void;
  113607. /**
  113608. * @hidden
  113609. */
  113610. reset(): void;
  113611. /**
  113612. * Render the bounding boxes of a specific rendering group
  113613. * @param renderingGroupId defines the rendering group to render
  113614. */
  113615. render(renderingGroupId: number): void;
  113616. /**
  113617. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113618. * @param mesh Define the mesh to render the occlusion bounding box for
  113619. */
  113620. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113621. /**
  113622. * Dispose and release the resources attached to this renderer.
  113623. */
  113624. dispose(): void;
  113625. }
  113626. }
  113627. declare module BABYLON {
  113628. /** @hidden */
  113629. export var depthPixelShader: {
  113630. name: string;
  113631. shader: string;
  113632. };
  113633. }
  113634. declare module BABYLON {
  113635. /**
  113636. * This represents a depth renderer in Babylon.
  113637. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113638. */
  113639. export class DepthRenderer {
  113640. private _scene;
  113641. private _depthMap;
  113642. private _effect;
  113643. private _cachedDefines;
  113644. private _camera;
  113645. /**
  113646. * Specifiess that the depth renderer will only be used within
  113647. * the camera it is created for.
  113648. * This can help forcing its rendering during the camera processing.
  113649. */
  113650. useOnlyInActiveCamera: boolean;
  113651. /** @hidden */
  113652. static _SceneComponentInitialization: (scene: Scene) => void;
  113653. /**
  113654. * Instantiates a depth renderer
  113655. * @param scene The scene the renderer belongs to
  113656. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113657. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113658. */
  113659. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113660. /**
  113661. * Creates the depth rendering effect and checks if the effect is ready.
  113662. * @param subMesh The submesh to be used to render the depth map of
  113663. * @param useInstances If multiple world instances should be used
  113664. * @returns if the depth renderer is ready to render the depth map
  113665. */
  113666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113667. /**
  113668. * Gets the texture which the depth map will be written to.
  113669. * @returns The depth map texture
  113670. */
  113671. getDepthMap(): RenderTargetTexture;
  113672. /**
  113673. * Disposes of the depth renderer.
  113674. */
  113675. dispose(): void;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. interface Scene {
  113680. /** @hidden (Backing field) */
  113681. _depthRenderer: {
  113682. [id: string]: DepthRenderer;
  113683. };
  113684. /**
  113685. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113686. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113687. * @returns the created depth renderer
  113688. */
  113689. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113690. /**
  113691. * Disables a depth renderer for a given camera
  113692. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113693. */
  113694. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113695. }
  113696. /**
  113697. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113698. * in several rendering techniques.
  113699. */
  113700. export class DepthRendererSceneComponent implements ISceneComponent {
  113701. /**
  113702. * The component name helpfull to identify the component in the list of scene components.
  113703. */
  113704. readonly name: string;
  113705. /**
  113706. * The scene the component belongs to.
  113707. */
  113708. scene: Scene;
  113709. /**
  113710. * Creates a new instance of the component for the given scene
  113711. * @param scene Defines the scene to register the component in
  113712. */
  113713. constructor(scene: Scene);
  113714. /**
  113715. * Registers the component in a given scene
  113716. */
  113717. register(): void;
  113718. /**
  113719. * Rebuilds the elements related to this component in case of
  113720. * context lost for instance.
  113721. */
  113722. rebuild(): void;
  113723. /**
  113724. * Disposes the component and the associated ressources
  113725. */
  113726. dispose(): void;
  113727. private _gatherRenderTargets;
  113728. private _gatherActiveCameraRenderTargets;
  113729. }
  113730. }
  113731. declare module BABYLON {
  113732. /** @hidden */
  113733. export var outlinePixelShader: {
  113734. name: string;
  113735. shader: string;
  113736. };
  113737. }
  113738. declare module BABYLON {
  113739. /** @hidden */
  113740. export var outlineVertexShader: {
  113741. name: string;
  113742. shader: string;
  113743. };
  113744. }
  113745. declare module BABYLON {
  113746. interface Scene {
  113747. /** @hidden */
  113748. _outlineRenderer: OutlineRenderer;
  113749. /**
  113750. * Gets the outline renderer associated with the scene
  113751. * @returns a OutlineRenderer
  113752. */
  113753. getOutlineRenderer(): OutlineRenderer;
  113754. }
  113755. interface AbstractMesh {
  113756. /** @hidden (Backing field) */
  113757. _renderOutline: boolean;
  113758. /**
  113759. * Gets or sets a boolean indicating if the outline must be rendered as well
  113760. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113761. */
  113762. renderOutline: boolean;
  113763. /** @hidden (Backing field) */
  113764. _renderOverlay: boolean;
  113765. /**
  113766. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113767. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113768. */
  113769. renderOverlay: boolean;
  113770. }
  113771. /**
  113772. * This class is responsible to draw bothe outline/overlay of meshes.
  113773. * It should not be used directly but through the available method on mesh.
  113774. */
  113775. export class OutlineRenderer implements ISceneComponent {
  113776. /**
  113777. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113778. */
  113779. private static _StencilReference;
  113780. /**
  113781. * The name of the component. Each component must have a unique name.
  113782. */
  113783. name: string;
  113784. /**
  113785. * The scene the component belongs to.
  113786. */
  113787. scene: Scene;
  113788. /**
  113789. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113790. */
  113791. zOffset: number;
  113792. private _engine;
  113793. private _effect;
  113794. private _cachedDefines;
  113795. private _savedDepthWrite;
  113796. /**
  113797. * Instantiates a new outline renderer. (There could be only one per scene).
  113798. * @param scene Defines the scene it belongs to
  113799. */
  113800. constructor(scene: Scene);
  113801. /**
  113802. * Register the component to one instance of a scene.
  113803. */
  113804. register(): void;
  113805. /**
  113806. * Rebuilds the elements related to this component in case of
  113807. * context lost for instance.
  113808. */
  113809. rebuild(): void;
  113810. /**
  113811. * Disposes the component and the associated ressources.
  113812. */
  113813. dispose(): void;
  113814. /**
  113815. * Renders the outline in the canvas.
  113816. * @param subMesh Defines the sumesh to render
  113817. * @param batch Defines the batch of meshes in case of instances
  113818. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113819. */
  113820. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113821. /**
  113822. * Returns whether or not the outline renderer is ready for a given submesh.
  113823. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113824. * @param subMesh Defines the submesh to check readyness for
  113825. * @param useInstances Defines wheter wee are trying to render instances or not
  113826. * @returns true if ready otherwise false
  113827. */
  113828. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113829. private _beforeRenderingMesh;
  113830. private _afterRenderingMesh;
  113831. }
  113832. }
  113833. declare module BABYLON {
  113834. /**
  113835. * Defines the list of states available for a task inside a AssetsManager
  113836. */
  113837. export enum AssetTaskState {
  113838. /**
  113839. * Initialization
  113840. */
  113841. INIT = 0,
  113842. /**
  113843. * Running
  113844. */
  113845. RUNNING = 1,
  113846. /**
  113847. * Done
  113848. */
  113849. DONE = 2,
  113850. /**
  113851. * Error
  113852. */
  113853. ERROR = 3
  113854. }
  113855. /**
  113856. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113857. */
  113858. export abstract class AbstractAssetTask {
  113859. /**
  113860. * Task name
  113861. */ name: string;
  113862. /**
  113863. * Callback called when the task is successful
  113864. */
  113865. onSuccess: (task: any) => void;
  113866. /**
  113867. * Callback called when the task is not successful
  113868. */
  113869. onError: (task: any, message?: string, exception?: any) => void;
  113870. /**
  113871. * Creates a new AssetsManager
  113872. * @param name defines the name of the task
  113873. */
  113874. constructor(
  113875. /**
  113876. * Task name
  113877. */ name: string);
  113878. private _isCompleted;
  113879. private _taskState;
  113880. private _errorObject;
  113881. /**
  113882. * Get if the task is completed
  113883. */
  113884. readonly isCompleted: boolean;
  113885. /**
  113886. * Gets the current state of the task
  113887. */
  113888. readonly taskState: AssetTaskState;
  113889. /**
  113890. * Gets the current error object (if task is in error)
  113891. */
  113892. readonly errorObject: {
  113893. message?: string;
  113894. exception?: any;
  113895. };
  113896. /**
  113897. * Internal only
  113898. * @hidden
  113899. */
  113900. _setErrorObject(message?: string, exception?: any): void;
  113901. /**
  113902. * Execute the current task
  113903. * @param scene defines the scene where you want your assets to be loaded
  113904. * @param onSuccess is a callback called when the task is successfully executed
  113905. * @param onError is a callback called if an error occurs
  113906. */
  113907. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113908. /**
  113909. * Execute the current task
  113910. * @param scene defines the scene where you want your assets to be loaded
  113911. * @param onSuccess is a callback called when the task is successfully executed
  113912. * @param onError is a callback called if an error occurs
  113913. */
  113914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113915. /**
  113916. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113917. * This can be used with failed tasks that have the reason for failure fixed.
  113918. */
  113919. reset(): void;
  113920. private onErrorCallback;
  113921. private onDoneCallback;
  113922. }
  113923. /**
  113924. * Define the interface used by progress events raised during assets loading
  113925. */
  113926. export interface IAssetsProgressEvent {
  113927. /**
  113928. * Defines the number of remaining tasks to process
  113929. */
  113930. remainingCount: number;
  113931. /**
  113932. * Defines the total number of tasks
  113933. */
  113934. totalCount: number;
  113935. /**
  113936. * Defines the task that was just processed
  113937. */
  113938. task: AbstractAssetTask;
  113939. }
  113940. /**
  113941. * Class used to share progress information about assets loading
  113942. */
  113943. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113944. /**
  113945. * Defines the number of remaining tasks to process
  113946. */
  113947. remainingCount: number;
  113948. /**
  113949. * Defines the total number of tasks
  113950. */
  113951. totalCount: number;
  113952. /**
  113953. * Defines the task that was just processed
  113954. */
  113955. task: AbstractAssetTask;
  113956. /**
  113957. * Creates a AssetsProgressEvent
  113958. * @param remainingCount defines the number of remaining tasks to process
  113959. * @param totalCount defines the total number of tasks
  113960. * @param task defines the task that was just processed
  113961. */
  113962. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113963. }
  113964. /**
  113965. * Define a task used by AssetsManager to load meshes
  113966. */
  113967. export class MeshAssetTask extends AbstractAssetTask {
  113968. /**
  113969. * Defines the name of the task
  113970. */
  113971. name: string;
  113972. /**
  113973. * Defines the list of mesh's names you want to load
  113974. */
  113975. meshesNames: any;
  113976. /**
  113977. * Defines the root url to use as a base to load your meshes and associated resources
  113978. */
  113979. rootUrl: string;
  113980. /**
  113981. * Defines the filename of the scene to load from
  113982. */
  113983. sceneFilename: string;
  113984. /**
  113985. * Gets the list of loaded meshes
  113986. */
  113987. loadedMeshes: Array<AbstractMesh>;
  113988. /**
  113989. * Gets the list of loaded particle systems
  113990. */
  113991. loadedParticleSystems: Array<IParticleSystem>;
  113992. /**
  113993. * Gets the list of loaded skeletons
  113994. */
  113995. loadedSkeletons: Array<Skeleton>;
  113996. /**
  113997. * Gets the list of loaded animation groups
  113998. */
  113999. loadedAnimationGroups: Array<AnimationGroup>;
  114000. /**
  114001. * Callback called when the task is successful
  114002. */
  114003. onSuccess: (task: MeshAssetTask) => void;
  114004. /**
  114005. * Callback called when the task is successful
  114006. */
  114007. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114008. /**
  114009. * Creates a new MeshAssetTask
  114010. * @param name defines the name of the task
  114011. * @param meshesNames defines the list of mesh's names you want to load
  114012. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114013. * @param sceneFilename defines the filename of the scene to load from
  114014. */
  114015. constructor(
  114016. /**
  114017. * Defines the name of the task
  114018. */
  114019. name: string,
  114020. /**
  114021. * Defines the list of mesh's names you want to load
  114022. */
  114023. meshesNames: any,
  114024. /**
  114025. * Defines the root url to use as a base to load your meshes and associated resources
  114026. */
  114027. rootUrl: string,
  114028. /**
  114029. * Defines the filename of the scene to load from
  114030. */
  114031. sceneFilename: string);
  114032. /**
  114033. * Execute the current task
  114034. * @param scene defines the scene where you want your assets to be loaded
  114035. * @param onSuccess is a callback called when the task is successfully executed
  114036. * @param onError is a callback called if an error occurs
  114037. */
  114038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114039. }
  114040. /**
  114041. * Define a task used by AssetsManager to load text content
  114042. */
  114043. export class TextFileAssetTask extends AbstractAssetTask {
  114044. /**
  114045. * Defines the name of the task
  114046. */
  114047. name: string;
  114048. /**
  114049. * Defines the location of the file to load
  114050. */
  114051. url: string;
  114052. /**
  114053. * Gets the loaded text string
  114054. */
  114055. text: string;
  114056. /**
  114057. * Callback called when the task is successful
  114058. */
  114059. onSuccess: (task: TextFileAssetTask) => void;
  114060. /**
  114061. * Callback called when the task is successful
  114062. */
  114063. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114064. /**
  114065. * Creates a new TextFileAssetTask object
  114066. * @param name defines the name of the task
  114067. * @param url defines the location of the file to load
  114068. */
  114069. constructor(
  114070. /**
  114071. * Defines the name of the task
  114072. */
  114073. name: string,
  114074. /**
  114075. * Defines the location of the file to load
  114076. */
  114077. url: string);
  114078. /**
  114079. * Execute the current task
  114080. * @param scene defines the scene where you want your assets to be loaded
  114081. * @param onSuccess is a callback called when the task is successfully executed
  114082. * @param onError is a callback called if an error occurs
  114083. */
  114084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114085. }
  114086. /**
  114087. * Define a task used by AssetsManager to load binary data
  114088. */
  114089. export class BinaryFileAssetTask extends AbstractAssetTask {
  114090. /**
  114091. * Defines the name of the task
  114092. */
  114093. name: string;
  114094. /**
  114095. * Defines the location of the file to load
  114096. */
  114097. url: string;
  114098. /**
  114099. * Gets the lodaded data (as an array buffer)
  114100. */
  114101. data: ArrayBuffer;
  114102. /**
  114103. * Callback called when the task is successful
  114104. */
  114105. onSuccess: (task: BinaryFileAssetTask) => void;
  114106. /**
  114107. * Callback called when the task is successful
  114108. */
  114109. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114110. /**
  114111. * Creates a new BinaryFileAssetTask object
  114112. * @param name defines the name of the new task
  114113. * @param url defines the location of the file to load
  114114. */
  114115. constructor(
  114116. /**
  114117. * Defines the name of the task
  114118. */
  114119. name: string,
  114120. /**
  114121. * Defines the location of the file to load
  114122. */
  114123. url: string);
  114124. /**
  114125. * Execute the current task
  114126. * @param scene defines the scene where you want your assets to be loaded
  114127. * @param onSuccess is a callback called when the task is successfully executed
  114128. * @param onError is a callback called if an error occurs
  114129. */
  114130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114131. }
  114132. /**
  114133. * Define a task used by AssetsManager to load images
  114134. */
  114135. export class ImageAssetTask extends AbstractAssetTask {
  114136. /**
  114137. * Defines the name of the task
  114138. */
  114139. name: string;
  114140. /**
  114141. * Defines the location of the image to load
  114142. */
  114143. url: string;
  114144. /**
  114145. * Gets the loaded images
  114146. */
  114147. image: HTMLImageElement;
  114148. /**
  114149. * Callback called when the task is successful
  114150. */
  114151. onSuccess: (task: ImageAssetTask) => void;
  114152. /**
  114153. * Callback called when the task is successful
  114154. */
  114155. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114156. /**
  114157. * Creates a new ImageAssetTask
  114158. * @param name defines the name of the task
  114159. * @param url defines the location of the image to load
  114160. */
  114161. constructor(
  114162. /**
  114163. * Defines the name of the task
  114164. */
  114165. name: string,
  114166. /**
  114167. * Defines the location of the image to load
  114168. */
  114169. url: string);
  114170. /**
  114171. * Execute the current task
  114172. * @param scene defines the scene where you want your assets to be loaded
  114173. * @param onSuccess is a callback called when the task is successfully executed
  114174. * @param onError is a callback called if an error occurs
  114175. */
  114176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114177. }
  114178. /**
  114179. * Defines the interface used by texture loading tasks
  114180. */
  114181. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114182. /**
  114183. * Gets the loaded texture
  114184. */
  114185. texture: TEX;
  114186. }
  114187. /**
  114188. * Define a task used by AssetsManager to load 2D textures
  114189. */
  114190. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  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. * Defines if mipmap should not be generated (default is false)
  114201. */
  114202. noMipmap?: boolean | undefined;
  114203. /**
  114204. * Defines if texture must be inverted on Y axis (default is false)
  114205. */
  114206. invertY?: boolean | undefined;
  114207. /**
  114208. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114209. */
  114210. samplingMode: number;
  114211. /**
  114212. * Gets the loaded texture
  114213. */
  114214. texture: Texture;
  114215. /**
  114216. * Callback called when the task is successful
  114217. */
  114218. onSuccess: (task: TextureAssetTask) => void;
  114219. /**
  114220. * Callback called when the task is successful
  114221. */
  114222. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114223. /**
  114224. * Creates a new TextureAssetTask object
  114225. * @param name defines the name of the task
  114226. * @param url defines the location of the file to load
  114227. * @param noMipmap defines if mipmap should not be generated (default is false)
  114228. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114229. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114230. */
  114231. constructor(
  114232. /**
  114233. * Defines the name of the task
  114234. */
  114235. name: string,
  114236. /**
  114237. * Defines the location of the file to load
  114238. */
  114239. url: string,
  114240. /**
  114241. * Defines if mipmap should not be generated (default is false)
  114242. */
  114243. noMipmap?: boolean | undefined,
  114244. /**
  114245. * Defines if texture must be inverted on Y axis (default is false)
  114246. */
  114247. invertY?: boolean | undefined,
  114248. /**
  114249. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114250. */
  114251. samplingMode?: number);
  114252. /**
  114253. * Execute the current task
  114254. * @param scene defines the scene where you want your assets to be loaded
  114255. * @param onSuccess is a callback called when the task is successfully executed
  114256. * @param onError is a callback called if an error occurs
  114257. */
  114258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114259. }
  114260. /**
  114261. * Define a task used by AssetsManager to load cube textures
  114262. */
  114263. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114264. /**
  114265. * Defines the name of the task
  114266. */
  114267. name: string;
  114268. /**
  114269. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114270. */
  114271. url: string;
  114272. /**
  114273. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114274. */
  114275. extensions?: string[] | undefined;
  114276. /**
  114277. * Defines if mipmaps should not be generated (default is false)
  114278. */
  114279. noMipmap?: boolean | undefined;
  114280. /**
  114281. * Defines the explicit list of files (undefined by default)
  114282. */
  114283. files?: string[] | undefined;
  114284. /**
  114285. * Gets the loaded texture
  114286. */
  114287. texture: CubeTexture;
  114288. /**
  114289. * Callback called when the task is successful
  114290. */
  114291. onSuccess: (task: CubeTextureAssetTask) => void;
  114292. /**
  114293. * Callback called when the task is successful
  114294. */
  114295. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114296. /**
  114297. * Creates a new CubeTextureAssetTask
  114298. * @param name defines the name of the task
  114299. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114300. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114302. * @param files defines the explicit list of files (undefined by default)
  114303. */
  114304. constructor(
  114305. /**
  114306. * Defines the name of the task
  114307. */
  114308. name: string,
  114309. /**
  114310. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114311. */
  114312. url: string,
  114313. /**
  114314. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114315. */
  114316. extensions?: string[] | undefined,
  114317. /**
  114318. * Defines if mipmaps should not be generated (default is false)
  114319. */
  114320. noMipmap?: boolean | undefined,
  114321. /**
  114322. * Defines the explicit list of files (undefined by default)
  114323. */
  114324. files?: string[] | undefined);
  114325. /**
  114326. * Execute the current task
  114327. * @param scene defines the scene where you want your assets to be loaded
  114328. * @param onSuccess is a callback called when the task is successfully executed
  114329. * @param onError is a callback called if an error occurs
  114330. */
  114331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114332. }
  114333. /**
  114334. * Define a task used by AssetsManager to load HDR cube textures
  114335. */
  114336. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114337. /**
  114338. * Defines the name of the task
  114339. */
  114340. name: string;
  114341. /**
  114342. * Defines the location of the file to load
  114343. */
  114344. url: string;
  114345. /**
  114346. * Defines the desired size (the more it increases the longer the generation will be)
  114347. */
  114348. size: number;
  114349. /**
  114350. * Defines if mipmaps should not be generated (default is false)
  114351. */
  114352. noMipmap: boolean;
  114353. /**
  114354. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114355. */
  114356. generateHarmonics: boolean;
  114357. /**
  114358. * 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)
  114359. */
  114360. gammaSpace: boolean;
  114361. /**
  114362. * Internal Use Only
  114363. */
  114364. reserved: boolean;
  114365. /**
  114366. * Gets the loaded texture
  114367. */
  114368. texture: HDRCubeTexture;
  114369. /**
  114370. * Callback called when the task is successful
  114371. */
  114372. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114373. /**
  114374. * Callback called when the task is successful
  114375. */
  114376. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114377. /**
  114378. * Creates a new HDRCubeTextureAssetTask object
  114379. * @param name defines the name of the task
  114380. * @param url defines the location of the file to load
  114381. * @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.
  114382. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114383. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114384. * @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)
  114385. * @param reserved Internal use only
  114386. */
  114387. constructor(
  114388. /**
  114389. * Defines the name of the task
  114390. */
  114391. name: string,
  114392. /**
  114393. * Defines the location of the file to load
  114394. */
  114395. url: string,
  114396. /**
  114397. * Defines the desired size (the more it increases the longer the generation will be)
  114398. */
  114399. size: number,
  114400. /**
  114401. * Defines if mipmaps should not be generated (default is false)
  114402. */
  114403. noMipmap?: boolean,
  114404. /**
  114405. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114406. */
  114407. generateHarmonics?: boolean,
  114408. /**
  114409. * 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)
  114410. */
  114411. gammaSpace?: boolean,
  114412. /**
  114413. * Internal Use Only
  114414. */
  114415. reserved?: boolean);
  114416. /**
  114417. * Execute the current task
  114418. * @param scene defines the scene where you want your assets to be loaded
  114419. * @param onSuccess is a callback called when the task is successfully executed
  114420. * @param onError is a callback called if an error occurs
  114421. */
  114422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114423. }
  114424. /**
  114425. * Define a task used by AssetsManager to load Equirectangular cube textures
  114426. */
  114427. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114428. /**
  114429. * Defines the name of the task
  114430. */
  114431. name: string;
  114432. /**
  114433. * Defines the location of the file to load
  114434. */
  114435. url: string;
  114436. /**
  114437. * Defines the desired size (the more it increases the longer the generation will be)
  114438. */
  114439. size: number;
  114440. /**
  114441. * Defines if mipmaps should not be generated (default is false)
  114442. */
  114443. noMipmap: boolean;
  114444. /**
  114445. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114446. * but the standard material would require them in Gamma space) (default is true)
  114447. */
  114448. gammaSpace: boolean;
  114449. /**
  114450. * Gets the loaded texture
  114451. */
  114452. texture: EquiRectangularCubeTexture;
  114453. /**
  114454. * Callback called when the task is successful
  114455. */
  114456. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114457. /**
  114458. * Callback called when the task is successful
  114459. */
  114460. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114461. /**
  114462. * Creates a new EquiRectangularCubeTextureAssetTask object
  114463. * @param name defines the name of the task
  114464. * @param url defines the location of the file to load
  114465. * @param size defines the desired size (the more it increases the longer the generation will be)
  114466. * If the size is omitted this implies you are using a preprocessed cubemap.
  114467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114468. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114469. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114470. * (default is true)
  114471. */
  114472. constructor(
  114473. /**
  114474. * Defines the name of the task
  114475. */
  114476. name: string,
  114477. /**
  114478. * Defines the location of the file to load
  114479. */
  114480. url: string,
  114481. /**
  114482. * Defines the desired size (the more it increases the longer the generation will be)
  114483. */
  114484. size: number,
  114485. /**
  114486. * Defines if mipmaps should not be generated (default is false)
  114487. */
  114488. noMipmap?: boolean,
  114489. /**
  114490. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114491. * but the standard material would require them in Gamma space) (default is true)
  114492. */
  114493. gammaSpace?: boolean);
  114494. /**
  114495. * Execute the current task
  114496. * @param scene defines the scene where you want your assets to be loaded
  114497. * @param onSuccess is a callback called when the task is successfully executed
  114498. * @param onError is a callback called if an error occurs
  114499. */
  114500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114501. }
  114502. /**
  114503. * This class can be used to easily import assets into a scene
  114504. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114505. */
  114506. export class AssetsManager {
  114507. private _scene;
  114508. private _isLoading;
  114509. protected _tasks: AbstractAssetTask[];
  114510. protected _waitingTasksCount: number;
  114511. protected _totalTasksCount: number;
  114512. /**
  114513. * Callback called when all tasks are processed
  114514. */
  114515. onFinish: (tasks: AbstractAssetTask[]) => void;
  114516. /**
  114517. * Callback called when a task is successful
  114518. */
  114519. onTaskSuccess: (task: AbstractAssetTask) => void;
  114520. /**
  114521. * Callback called when a task had an error
  114522. */
  114523. onTaskError: (task: AbstractAssetTask) => void;
  114524. /**
  114525. * Callback called when a task is done (whatever the result is)
  114526. */
  114527. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114528. /**
  114529. * Observable called when all tasks are processed
  114530. */
  114531. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114532. /**
  114533. * Observable called when a task had an error
  114534. */
  114535. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114536. /**
  114537. * Observable called when all tasks were executed
  114538. */
  114539. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114540. /**
  114541. * Observable called when a task is done (whatever the result is)
  114542. */
  114543. onProgressObservable: Observable<IAssetsProgressEvent>;
  114544. /**
  114545. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114547. */
  114548. useDefaultLoadingScreen: boolean;
  114549. /**
  114550. * Creates a new AssetsManager
  114551. * @param scene defines the scene to work on
  114552. */
  114553. constructor(scene: Scene);
  114554. /**
  114555. * Add a MeshAssetTask to the list of active tasks
  114556. * @param taskName defines the name of the new task
  114557. * @param meshesNames defines the name of meshes to load
  114558. * @param rootUrl defines the root url to use to locate files
  114559. * @param sceneFilename defines the filename of the scene file
  114560. * @returns a new MeshAssetTask object
  114561. */
  114562. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114563. /**
  114564. * Add a TextFileAssetTask to the list of active tasks
  114565. * @param taskName defines the name of the new task
  114566. * @param url defines the url of the file to load
  114567. * @returns a new TextFileAssetTask object
  114568. */
  114569. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114570. /**
  114571. * Add a BinaryFileAssetTask to the list of active tasks
  114572. * @param taskName defines the name of the new task
  114573. * @param url defines the url of the file to load
  114574. * @returns a new BinaryFileAssetTask object
  114575. */
  114576. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114577. /**
  114578. * Add a ImageAssetTask to the list of active tasks
  114579. * @param taskName defines the name of the new task
  114580. * @param url defines the url of the file to load
  114581. * @returns a new ImageAssetTask object
  114582. */
  114583. addImageTask(taskName: string, url: string): ImageAssetTask;
  114584. /**
  114585. * Add a TextureAssetTask to the list of active tasks
  114586. * @param taskName defines the name of the new task
  114587. * @param url defines the url of the file to load
  114588. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114589. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114590. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114591. * @returns a new TextureAssetTask object
  114592. */
  114593. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114594. /**
  114595. * Add a CubeTextureAssetTask to the list of active tasks
  114596. * @param taskName defines the name of the new task
  114597. * @param url defines the url of the file to load
  114598. * @param extensions defines the extension to use to load the cube map (can be null)
  114599. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114600. * @param files defines the list of files to load (can be null)
  114601. * @returns a new CubeTextureAssetTask object
  114602. */
  114603. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114604. /**
  114605. *
  114606. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114607. * @param taskName defines the name of the new task
  114608. * @param url defines the url of the file to load
  114609. * @param size defines the size you want for the cubemap (can be null)
  114610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114611. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114612. * @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)
  114613. * @param reserved Internal use only
  114614. * @returns a new HDRCubeTextureAssetTask object
  114615. */
  114616. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114617. /**
  114618. *
  114619. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114620. * @param taskName defines the name of the new task
  114621. * @param url defines the url of the file to load
  114622. * @param size defines the size you want for the cubemap (can be null)
  114623. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114624. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114625. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114626. * @returns a new EquiRectangularCubeTextureAssetTask object
  114627. */
  114628. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114629. /**
  114630. * Remove a task from the assets manager.
  114631. * @param task the task to remove
  114632. */
  114633. removeTask(task: AbstractAssetTask): void;
  114634. private _decreaseWaitingTasksCount;
  114635. private _runTask;
  114636. /**
  114637. * Reset the AssetsManager and remove all tasks
  114638. * @return the current instance of the AssetsManager
  114639. */
  114640. reset(): AssetsManager;
  114641. /**
  114642. * Start the loading process
  114643. * @return the current instance of the AssetsManager
  114644. */
  114645. load(): AssetsManager;
  114646. /**
  114647. * Start the loading process as an async operation
  114648. * @return a promise returning the list of failed tasks
  114649. */
  114650. loadAsync(): Promise<void>;
  114651. }
  114652. }
  114653. declare module BABYLON {
  114654. /**
  114655. * Wrapper class for promise with external resolve and reject.
  114656. */
  114657. export class Deferred<T> {
  114658. /**
  114659. * The promise associated with this deferred object.
  114660. */
  114661. readonly promise: Promise<T>;
  114662. private _resolve;
  114663. private _reject;
  114664. /**
  114665. * The resolve method of the promise associated with this deferred object.
  114666. */
  114667. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114668. /**
  114669. * The reject method of the promise associated with this deferred object.
  114670. */
  114671. readonly reject: (reason?: any) => void;
  114672. /**
  114673. * Constructor for this deferred object.
  114674. */
  114675. constructor();
  114676. }
  114677. }
  114678. declare module BABYLON {
  114679. /**
  114680. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114681. */
  114682. export class MeshExploder {
  114683. private _centerMesh;
  114684. private _meshes;
  114685. private _meshesOrigins;
  114686. private _toCenterVectors;
  114687. private _scaledDirection;
  114688. private _newPosition;
  114689. private _centerPosition;
  114690. /**
  114691. * Explodes meshes from a center mesh.
  114692. * @param meshes The meshes to explode.
  114693. * @param centerMesh The mesh to be center of explosion.
  114694. */
  114695. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114696. private _setCenterMesh;
  114697. /**
  114698. * Get class name
  114699. * @returns "MeshExploder"
  114700. */
  114701. getClassName(): string;
  114702. /**
  114703. * "Exploded meshes"
  114704. * @returns Array of meshes with the centerMesh at index 0.
  114705. */
  114706. getMeshes(): Array<Mesh>;
  114707. /**
  114708. * Explodes meshes giving a specific direction
  114709. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114710. */
  114711. explode(direction?: number): void;
  114712. }
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * Class used to help managing file picking and drag'n'drop
  114717. */
  114718. export class FilesInput {
  114719. /**
  114720. * List of files ready to be loaded
  114721. */
  114722. static readonly FilesToLoad: {
  114723. [key: string]: File;
  114724. };
  114725. /**
  114726. * Callback called when a file is processed
  114727. */
  114728. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114729. private _engine;
  114730. private _currentScene;
  114731. private _sceneLoadedCallback;
  114732. private _progressCallback;
  114733. private _additionalRenderLoopLogicCallback;
  114734. private _textureLoadingCallback;
  114735. private _startingProcessingFilesCallback;
  114736. private _onReloadCallback;
  114737. private _errorCallback;
  114738. private _elementToMonitor;
  114739. private _sceneFileToLoad;
  114740. private _filesToLoad;
  114741. /**
  114742. * Creates a new FilesInput
  114743. * @param engine defines the rendering engine
  114744. * @param scene defines the hosting scene
  114745. * @param sceneLoadedCallback callback called when scene is loaded
  114746. * @param progressCallback callback called to track progress
  114747. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114748. * @param textureLoadingCallback callback called when a texture is loading
  114749. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114750. * @param onReloadCallback callback called when a reload is requested
  114751. * @param errorCallback callback call if an error occurs
  114752. */
  114753. 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);
  114754. private _dragEnterHandler;
  114755. private _dragOverHandler;
  114756. private _dropHandler;
  114757. /**
  114758. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114759. * @param elementToMonitor defines the DOM element to track
  114760. */
  114761. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114762. /**
  114763. * Release all associated resources
  114764. */
  114765. dispose(): void;
  114766. private renderFunction;
  114767. private drag;
  114768. private drop;
  114769. private _traverseFolder;
  114770. private _processFiles;
  114771. /**
  114772. * Load files from a drop event
  114773. * @param event defines the drop event to use as source
  114774. */
  114775. loadFiles(event: any): void;
  114776. private _processReload;
  114777. /**
  114778. * Reload the current scene from the loaded files
  114779. */
  114780. reload(): void;
  114781. }
  114782. }
  114783. declare module BABYLON {
  114784. /**
  114785. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114787. */
  114788. export class SceneOptimization {
  114789. /**
  114790. * Defines the priority of this optimization (0 by default which means first in the list)
  114791. */
  114792. priority: number;
  114793. /**
  114794. * Gets a string describing the action executed by the current optimization
  114795. * @returns description string
  114796. */
  114797. getDescription(): string;
  114798. /**
  114799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114800. * @param scene defines the current scene where to apply this optimization
  114801. * @param optimizer defines the current optimizer
  114802. * @returns true if everything that can be done was applied
  114803. */
  114804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114805. /**
  114806. * Creates the SceneOptimization object
  114807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114808. * @param desc defines the description associated with the optimization
  114809. */
  114810. constructor(
  114811. /**
  114812. * Defines the priority of this optimization (0 by default which means first in the list)
  114813. */
  114814. priority?: number);
  114815. }
  114816. /**
  114817. * Defines an optimization used to reduce the size of render target textures
  114818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114819. */
  114820. export class TextureOptimization extends SceneOptimization {
  114821. /**
  114822. * Defines the priority of this optimization (0 by default which means first in the list)
  114823. */
  114824. priority: number;
  114825. /**
  114826. * 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
  114827. */
  114828. maximumSize: number;
  114829. /**
  114830. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114831. */
  114832. step: number;
  114833. /**
  114834. * Gets a string describing the action executed by the current optimization
  114835. * @returns description string
  114836. */
  114837. getDescription(): string;
  114838. /**
  114839. * Creates the TextureOptimization object
  114840. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114841. * @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
  114842. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114843. */
  114844. constructor(
  114845. /**
  114846. * Defines the priority of this optimization (0 by default which means first in the list)
  114847. */
  114848. priority?: number,
  114849. /**
  114850. * 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
  114851. */
  114852. maximumSize?: number,
  114853. /**
  114854. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114855. */
  114856. step?: number);
  114857. /**
  114858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114859. * @param scene defines the current scene where to apply this optimization
  114860. * @param optimizer defines the current optimizer
  114861. * @returns true if everything that can be done was applied
  114862. */
  114863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114864. }
  114865. /**
  114866. * Defines an optimization used to increase or decrease the rendering resolution
  114867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114868. */
  114869. export class HardwareScalingOptimization extends SceneOptimization {
  114870. /**
  114871. * Defines the priority of this optimization (0 by default which means first in the list)
  114872. */
  114873. priority: number;
  114874. /**
  114875. * Defines the maximum scale to use (2 by default)
  114876. */
  114877. maximumScale: number;
  114878. /**
  114879. * Defines the step to use between two passes (0.5 by default)
  114880. */
  114881. step: number;
  114882. private _currentScale;
  114883. private _directionOffset;
  114884. /**
  114885. * Gets a string describing the action executed by the current optimization
  114886. * @return description string
  114887. */
  114888. getDescription(): string;
  114889. /**
  114890. * Creates the HardwareScalingOptimization object
  114891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114892. * @param maximumScale defines the maximum scale to use (2 by default)
  114893. * @param step defines the step to use between two passes (0.5 by default)
  114894. */
  114895. constructor(
  114896. /**
  114897. * Defines the priority of this optimization (0 by default which means first in the list)
  114898. */
  114899. priority?: number,
  114900. /**
  114901. * Defines the maximum scale to use (2 by default)
  114902. */
  114903. maximumScale?: number,
  114904. /**
  114905. * Defines the step to use between two passes (0.5 by default)
  114906. */
  114907. step?: number);
  114908. /**
  114909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114910. * @param scene defines the current scene where to apply this optimization
  114911. * @param optimizer defines the current optimizer
  114912. * @returns true if everything that can be done was applied
  114913. */
  114914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114915. }
  114916. /**
  114917. * Defines an optimization used to remove shadows
  114918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114919. */
  114920. export class ShadowsOptimization extends SceneOptimization {
  114921. /**
  114922. * Gets a string describing the action executed by the current optimization
  114923. * @return description string
  114924. */
  114925. getDescription(): string;
  114926. /**
  114927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114928. * @param scene defines the current scene where to apply this optimization
  114929. * @param optimizer defines the current optimizer
  114930. * @returns true if everything that can be done was applied
  114931. */
  114932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114933. }
  114934. /**
  114935. * Defines an optimization used to turn post-processes off
  114936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114937. */
  114938. export class PostProcessesOptimization extends SceneOptimization {
  114939. /**
  114940. * Gets a string describing the action executed by the current optimization
  114941. * @return description string
  114942. */
  114943. getDescription(): string;
  114944. /**
  114945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114946. * @param scene defines the current scene where to apply this optimization
  114947. * @param optimizer defines the current optimizer
  114948. * @returns true if everything that can be done was applied
  114949. */
  114950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114951. }
  114952. /**
  114953. * Defines an optimization used to turn lens flares off
  114954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114955. */
  114956. export class LensFlaresOptimization extends SceneOptimization {
  114957. /**
  114958. * Gets a string describing the action executed by the current optimization
  114959. * @return description string
  114960. */
  114961. getDescription(): string;
  114962. /**
  114963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114964. * @param scene defines the current scene where to apply this optimization
  114965. * @param optimizer defines the current optimizer
  114966. * @returns true if everything that can be done was applied
  114967. */
  114968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114969. }
  114970. /**
  114971. * Defines an optimization based on user defined callback.
  114972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114973. */
  114974. export class CustomOptimization extends SceneOptimization {
  114975. /**
  114976. * Callback called to apply the custom optimization.
  114977. */
  114978. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114979. /**
  114980. * Callback called to get custom description
  114981. */
  114982. onGetDescription: () => string;
  114983. /**
  114984. * Gets a string describing the action executed by the current optimization
  114985. * @returns description string
  114986. */
  114987. getDescription(): string;
  114988. /**
  114989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114990. * @param scene defines the current scene where to apply this optimization
  114991. * @param optimizer defines the current optimizer
  114992. * @returns true if everything that can be done was applied
  114993. */
  114994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114995. }
  114996. /**
  114997. * Defines an optimization used to turn particles off
  114998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114999. */
  115000. export class ParticlesOptimization extends SceneOptimization {
  115001. /**
  115002. * Gets a string describing the action executed by the current optimization
  115003. * @return description string
  115004. */
  115005. getDescription(): string;
  115006. /**
  115007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115008. * @param scene defines the current scene where to apply this optimization
  115009. * @param optimizer defines the current optimizer
  115010. * @returns true if everything that can be done was applied
  115011. */
  115012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115013. }
  115014. /**
  115015. * Defines an optimization used to turn render targets off
  115016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115017. */
  115018. export class RenderTargetsOptimization extends SceneOptimization {
  115019. /**
  115020. * Gets a string describing the action executed by the current optimization
  115021. * @return description string
  115022. */
  115023. getDescription(): string;
  115024. /**
  115025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115026. * @param scene defines the current scene where to apply this optimization
  115027. * @param optimizer defines the current optimizer
  115028. * @returns true if everything that can be done was applied
  115029. */
  115030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115031. }
  115032. /**
  115033. * Defines an optimization used to merge meshes with compatible materials
  115034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115035. */
  115036. export class MergeMeshesOptimization extends SceneOptimization {
  115037. private static _UpdateSelectionTree;
  115038. /**
  115039. * Gets or sets a boolean which defines if optimization octree has to be updated
  115040. */
  115041. /**
  115042. * Gets or sets a boolean which defines if optimization octree has to be updated
  115043. */
  115044. static UpdateSelectionTree: boolean;
  115045. /**
  115046. * Gets a string describing the action executed by the current optimization
  115047. * @return description string
  115048. */
  115049. getDescription(): string;
  115050. private _canBeMerged;
  115051. /**
  115052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115053. * @param scene defines the current scene where to apply this optimization
  115054. * @param optimizer defines the current optimizer
  115055. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115056. * @returns true if everything that can be done was applied
  115057. */
  115058. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115059. }
  115060. /**
  115061. * Defines a list of options used by SceneOptimizer
  115062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115063. */
  115064. export class SceneOptimizerOptions {
  115065. /**
  115066. * Defines the target frame rate to reach (60 by default)
  115067. */
  115068. targetFrameRate: number;
  115069. /**
  115070. * Defines the interval between two checkes (2000ms by default)
  115071. */
  115072. trackerDuration: number;
  115073. /**
  115074. * Gets the list of optimizations to apply
  115075. */
  115076. optimizations: SceneOptimization[];
  115077. /**
  115078. * Creates a new list of options used by SceneOptimizer
  115079. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115080. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115081. */
  115082. constructor(
  115083. /**
  115084. * Defines the target frame rate to reach (60 by default)
  115085. */
  115086. targetFrameRate?: number,
  115087. /**
  115088. * Defines the interval between two checkes (2000ms by default)
  115089. */
  115090. trackerDuration?: number);
  115091. /**
  115092. * Add a new optimization
  115093. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115094. * @returns the current SceneOptimizerOptions
  115095. */
  115096. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115097. /**
  115098. * Add a new custom optimization
  115099. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115100. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115101. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115102. * @returns the current SceneOptimizerOptions
  115103. */
  115104. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115105. /**
  115106. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115107. * @param targetFrameRate defines the target frame rate (60 by default)
  115108. * @returns a SceneOptimizerOptions object
  115109. */
  115110. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115111. /**
  115112. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115113. * @param targetFrameRate defines the target frame rate (60 by default)
  115114. * @returns a SceneOptimizerOptions object
  115115. */
  115116. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115117. /**
  115118. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115119. * @param targetFrameRate defines the target frame rate (60 by default)
  115120. * @returns a SceneOptimizerOptions object
  115121. */
  115122. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115123. }
  115124. /**
  115125. * Class used to run optimizations in order to reach a target frame rate
  115126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115127. */
  115128. export class SceneOptimizer implements IDisposable {
  115129. private _isRunning;
  115130. private _options;
  115131. private _scene;
  115132. private _currentPriorityLevel;
  115133. private _targetFrameRate;
  115134. private _trackerDuration;
  115135. private _currentFrameRate;
  115136. private _sceneDisposeObserver;
  115137. private _improvementMode;
  115138. /**
  115139. * Defines an observable called when the optimizer reaches the target frame rate
  115140. */
  115141. onSuccessObservable: Observable<SceneOptimizer>;
  115142. /**
  115143. * Defines an observable called when the optimizer enables an optimization
  115144. */
  115145. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115146. /**
  115147. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115148. */
  115149. onFailureObservable: Observable<SceneOptimizer>;
  115150. /**
  115151. * Gets a boolean indicating if the optimizer is in improvement mode
  115152. */
  115153. readonly isInImprovementMode: boolean;
  115154. /**
  115155. * Gets the current priority level (0 at start)
  115156. */
  115157. readonly currentPriorityLevel: number;
  115158. /**
  115159. * Gets the current frame rate checked by the SceneOptimizer
  115160. */
  115161. readonly currentFrameRate: number;
  115162. /**
  115163. * Gets or sets the current target frame rate (60 by default)
  115164. */
  115165. /**
  115166. * Gets or sets the current target frame rate (60 by default)
  115167. */
  115168. targetFrameRate: number;
  115169. /**
  115170. * Gets or sets the current interval between two checks (every 2000ms by default)
  115171. */
  115172. /**
  115173. * Gets or sets the current interval between two checks (every 2000ms by default)
  115174. */
  115175. trackerDuration: number;
  115176. /**
  115177. * Gets the list of active optimizations
  115178. */
  115179. readonly optimizations: SceneOptimization[];
  115180. /**
  115181. * Creates a new SceneOptimizer
  115182. * @param scene defines the scene to work on
  115183. * @param options defines the options to use with the SceneOptimizer
  115184. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115185. * @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)
  115186. */
  115187. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115188. /**
  115189. * Stops the current optimizer
  115190. */
  115191. stop(): void;
  115192. /**
  115193. * Reset the optimizer to initial step (current priority level = 0)
  115194. */
  115195. reset(): void;
  115196. /**
  115197. * Start the optimizer. By default it will try to reach a specific framerate
  115198. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115199. */
  115200. start(): void;
  115201. private _checkCurrentState;
  115202. /**
  115203. * Release all resources
  115204. */
  115205. dispose(): void;
  115206. /**
  115207. * Helper function to create a SceneOptimizer with one single line of code
  115208. * @param scene defines the scene to work on
  115209. * @param options defines the options to use with the SceneOptimizer
  115210. * @param onSuccess defines a callback to call on success
  115211. * @param onFailure defines a callback to call on failure
  115212. * @returns the new SceneOptimizer object
  115213. */
  115214. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * Class used to serialize a scene into a string
  115220. */
  115221. export class SceneSerializer {
  115222. /**
  115223. * Clear cache used by a previous serialization
  115224. */
  115225. static ClearCache(): void;
  115226. /**
  115227. * Serialize a scene into a JSON compatible object
  115228. * @param scene defines the scene to serialize
  115229. * @returns a JSON compatible object
  115230. */
  115231. static Serialize(scene: Scene): any;
  115232. /**
  115233. * Serialize a mesh into a JSON compatible object
  115234. * @param toSerialize defines the mesh to serialize
  115235. * @param withParents defines if parents must be serialized as well
  115236. * @param withChildren defines if children must be serialized as well
  115237. * @returns a JSON compatible object
  115238. */
  115239. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115240. }
  115241. }
  115242. declare module BABYLON {
  115243. /**
  115244. * Class used to host texture specific utilities
  115245. */
  115246. export class TextureTools {
  115247. /**
  115248. * Uses the GPU to create a copy texture rescaled at a given size
  115249. * @param texture Texture to copy from
  115250. * @param width defines the desired width
  115251. * @param height defines the desired height
  115252. * @param useBilinearMode defines if bilinear mode has to be used
  115253. * @return the generated texture
  115254. */
  115255. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115256. }
  115257. }
  115258. declare module BABYLON {
  115259. /**
  115260. * This represents the different options avilable for the video capture.
  115261. */
  115262. export interface VideoRecorderOptions {
  115263. /** Defines the mime type of the video */
  115264. mimeType: string;
  115265. /** Defines the video the video should be recorded at */
  115266. fps: number;
  115267. /** Defines the chunk size for the recording data */
  115268. recordChunckSize: number;
  115269. /** The audio tracks to attach to the record */
  115270. audioTracks?: MediaStreamTrack[];
  115271. }
  115272. /**
  115273. * This can helps recording videos from BabylonJS.
  115274. * This is based on the available WebRTC functionalities of the browser.
  115275. *
  115276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115277. */
  115278. export class VideoRecorder {
  115279. private static readonly _defaultOptions;
  115280. /**
  115281. * Returns wehther or not the VideoRecorder is available in your browser.
  115282. * @param engine Defines the Babylon Engine to check the support for
  115283. * @returns true if supported otherwise false
  115284. */
  115285. static IsSupported(engine: Engine): boolean;
  115286. private readonly _options;
  115287. private _canvas;
  115288. private _mediaRecorder;
  115289. private _recordedChunks;
  115290. private _fileName;
  115291. private _resolve;
  115292. private _reject;
  115293. /**
  115294. * True wether a recording is already in progress.
  115295. */
  115296. readonly isRecording: boolean;
  115297. /**
  115298. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115299. * a video file.
  115300. * @param engine Defines the BabylonJS Engine you wish to record
  115301. * @param options Defines options that can be used to customized the capture
  115302. */
  115303. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115304. /**
  115305. * Stops the current recording before the default capture timeout passed in the startRecording
  115306. * functions.
  115307. */
  115308. stopRecording(): void;
  115309. /**
  115310. * Starts recording the canvas for a max duration specified in parameters.
  115311. * @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.
  115312. * @param maxDuration Defines the maximum recording time in seconds.
  115313. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115314. * @return a promise callback at the end of the recording with the video data in Blob.
  115315. */
  115316. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115317. /**
  115318. * Releases internal resources used during the recording.
  115319. */
  115320. dispose(): void;
  115321. private _handleDataAvailable;
  115322. private _handleError;
  115323. private _handleStop;
  115324. }
  115325. }
  115326. declare module BABYLON {
  115327. /**
  115328. * Helper class to push actions to a pool of workers.
  115329. */
  115330. export class WorkerPool implements IDisposable {
  115331. private _workerInfos;
  115332. private _pendingActions;
  115333. /**
  115334. * Constructor
  115335. * @param workers Array of workers to use for actions
  115336. */
  115337. constructor(workers: Array<Worker>);
  115338. /**
  115339. * Terminates all workers and clears any pending actions.
  115340. */
  115341. dispose(): void;
  115342. /**
  115343. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115344. * pended until a worker has completed its action.
  115345. * @param action The action to perform. Call onComplete when the action is complete.
  115346. */
  115347. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115348. private _execute;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. /**
  115353. * Class containing a set of static utilities functions for screenshots
  115354. */
  115355. export class ScreenshotTools {
  115356. /**
  115357. * Captures a screenshot of the current rendering
  115358. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115359. * @param engine defines the rendering engine
  115360. * @param camera defines the source camera
  115361. * @param size This parameter can be set to a single number or to an object with the
  115362. * following (optional) properties: precision, width, height. If a single number is passed,
  115363. * it will be used for both width and height. If an object is passed, the screenshot size
  115364. * will be derived from the parameters. The precision property is a multiplier allowing
  115365. * rendering at a higher or lower resolution
  115366. * @param successCallback defines the callback receives a single parameter which contains the
  115367. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115368. * src parameter of an <img> to display it
  115369. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115370. * Check your browser for supported MIME types
  115371. */
  115372. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115373. /**
  115374. * Generates an image screenshot from the specified camera.
  115375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115376. * @param engine The engine to use for rendering
  115377. * @param camera The camera to use for rendering
  115378. * @param size This parameter can be set to a single number or to an object with the
  115379. * following (optional) properties: precision, width, height. If a single number is passed,
  115380. * it will be used for both width and height. If an object is passed, the screenshot size
  115381. * will be derived from the parameters. The precision property is a multiplier allowing
  115382. * rendering at a higher or lower resolution
  115383. * @param successCallback The callback receives a single parameter which contains the
  115384. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115385. * src parameter of an <img> to display it
  115386. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115387. * Check your browser for supported MIME types
  115388. * @param samples Texture samples (default: 1)
  115389. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115390. * @param fileName A name for for the downloaded file.
  115391. */
  115392. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115393. }
  115394. }
  115395. declare module BABYLON {
  115396. /**
  115397. * A cursor which tracks a point on a path
  115398. */
  115399. export class PathCursor {
  115400. private path;
  115401. /**
  115402. * Stores path cursor callbacks for when an onchange event is triggered
  115403. */
  115404. private _onchange;
  115405. /**
  115406. * The value of the path cursor
  115407. */
  115408. value: number;
  115409. /**
  115410. * The animation array of the path cursor
  115411. */
  115412. animations: Animation[];
  115413. /**
  115414. * Initializes the path cursor
  115415. * @param path The path to track
  115416. */
  115417. constructor(path: Path2);
  115418. /**
  115419. * Gets the cursor point on the path
  115420. * @returns A point on the path cursor at the cursor location
  115421. */
  115422. getPoint(): Vector3;
  115423. /**
  115424. * Moves the cursor ahead by the step amount
  115425. * @param step The amount to move the cursor forward
  115426. * @returns This path cursor
  115427. */
  115428. moveAhead(step?: number): PathCursor;
  115429. /**
  115430. * Moves the cursor behind by the step amount
  115431. * @param step The amount to move the cursor back
  115432. * @returns This path cursor
  115433. */
  115434. moveBack(step?: number): PathCursor;
  115435. /**
  115436. * Moves the cursor by the step amount
  115437. * If the step amount is greater than one, an exception is thrown
  115438. * @param step The amount to move the cursor
  115439. * @returns This path cursor
  115440. */
  115441. move(step: number): PathCursor;
  115442. /**
  115443. * Ensures that the value is limited between zero and one
  115444. * @returns This path cursor
  115445. */
  115446. private ensureLimits;
  115447. /**
  115448. * Runs onchange callbacks on change (used by the animation engine)
  115449. * @returns This path cursor
  115450. */
  115451. private raiseOnChange;
  115452. /**
  115453. * Executes a function on change
  115454. * @param f A path cursor onchange callback
  115455. * @returns This path cursor
  115456. */
  115457. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115458. }
  115459. }
  115460. declare module BABYLON {
  115461. /** @hidden */
  115462. export var blurPixelShader: {
  115463. name: string;
  115464. shader: string;
  115465. };
  115466. }
  115467. declare module BABYLON {
  115468. /** @hidden */
  115469. export var bones300Declaration: {
  115470. name: string;
  115471. shader: string;
  115472. };
  115473. }
  115474. declare module BABYLON {
  115475. /** @hidden */
  115476. export var instances300Declaration: {
  115477. name: string;
  115478. shader: string;
  115479. };
  115480. }
  115481. declare module BABYLON {
  115482. /** @hidden */
  115483. export var pointCloudVertexDeclaration: {
  115484. name: string;
  115485. shader: string;
  115486. };
  115487. }
  115488. // Mixins
  115489. interface Window {
  115490. mozIndexedDB: IDBFactory;
  115491. webkitIndexedDB: IDBFactory;
  115492. msIndexedDB: IDBFactory;
  115493. webkitURL: typeof URL;
  115494. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115495. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115496. WebGLRenderingContext: WebGLRenderingContext;
  115497. MSGesture: MSGesture;
  115498. CANNON: any;
  115499. AudioContext: AudioContext;
  115500. webkitAudioContext: AudioContext;
  115501. PointerEvent: any;
  115502. Math: Math;
  115503. Uint8Array: Uint8ArrayConstructor;
  115504. Float32Array: Float32ArrayConstructor;
  115505. mozURL: typeof URL;
  115506. msURL: typeof URL;
  115507. VRFrameData: any; // WebVR, from specs 1.1
  115508. DracoDecoderModule: any;
  115509. setImmediate(handler: (...args: any[]) => void): number;
  115510. }
  115511. interface HTMLCanvasElement {
  115512. requestPointerLock(): void;
  115513. msRequestPointerLock?(): void;
  115514. mozRequestPointerLock?(): void;
  115515. webkitRequestPointerLock?(): void;
  115516. /** Track wether a record is in progress */
  115517. isRecording: boolean;
  115518. /** Capture Stream method defined by some browsers */
  115519. captureStream(fps?: number): MediaStream;
  115520. }
  115521. interface CanvasRenderingContext2D {
  115522. msImageSmoothingEnabled: boolean;
  115523. }
  115524. interface MouseEvent {
  115525. mozMovementX: number;
  115526. mozMovementY: number;
  115527. webkitMovementX: number;
  115528. webkitMovementY: number;
  115529. msMovementX: number;
  115530. msMovementY: number;
  115531. }
  115532. interface Navigator {
  115533. mozGetVRDevices: (any: any) => any;
  115534. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115535. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115536. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115537. webkitGetGamepads(): Gamepad[];
  115538. msGetGamepads(): Gamepad[];
  115539. webkitGamepads(): Gamepad[];
  115540. }
  115541. interface HTMLVideoElement {
  115542. mozSrcObject: any;
  115543. }
  115544. interface Math {
  115545. fround(x: number): number;
  115546. imul(a: number, b: number): number;
  115547. }
  115548. interface WebGLProgram {
  115549. context?: WebGLRenderingContext;
  115550. vertexShader?: WebGLShader;
  115551. fragmentShader?: WebGLShader;
  115552. isParallelCompiled: boolean;
  115553. onCompiled?: () => void;
  115554. }
  115555. interface WebGLRenderingContext {
  115556. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115557. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115558. vertexAttribDivisor(index: number, divisor: number): void;
  115559. createVertexArray(): any;
  115560. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115561. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115562. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115563. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115564. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115565. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115566. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115567. // Queries
  115568. createQuery(): WebGLQuery;
  115569. deleteQuery(query: WebGLQuery): void;
  115570. beginQuery(target: number, query: WebGLQuery): void;
  115571. endQuery(target: number): void;
  115572. getQueryParameter(query: WebGLQuery, pname: number): any;
  115573. getQuery(target: number, pname: number): any;
  115574. MAX_SAMPLES: number;
  115575. RGBA8: number;
  115576. READ_FRAMEBUFFER: number;
  115577. DRAW_FRAMEBUFFER: number;
  115578. UNIFORM_BUFFER: number;
  115579. HALF_FLOAT_OES: number;
  115580. RGBA16F: number;
  115581. RGBA32F: number;
  115582. R32F: number;
  115583. RG32F: number;
  115584. RGB32F: number;
  115585. R16F: number;
  115586. RG16F: number;
  115587. RGB16F: number;
  115588. RED: number;
  115589. RG: number;
  115590. R8: number;
  115591. RG8: number;
  115592. UNSIGNED_INT_24_8: number;
  115593. DEPTH24_STENCIL8: number;
  115594. /* Multiple Render Targets */
  115595. drawBuffers(buffers: number[]): void;
  115596. readBuffer(src: number): void;
  115597. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115598. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115599. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115600. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115601. // Occlusion Query
  115602. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115603. ANY_SAMPLES_PASSED: number;
  115604. QUERY_RESULT_AVAILABLE: number;
  115605. QUERY_RESULT: number;
  115606. }
  115607. interface WebGLBuffer {
  115608. references: number;
  115609. capacity: number;
  115610. is32Bits: boolean;
  115611. }
  115612. interface WebGLProgram {
  115613. transformFeedback?: WebGLTransformFeedback | null;
  115614. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115615. }
  115616. interface EXT_disjoint_timer_query {
  115617. QUERY_COUNTER_BITS_EXT: number;
  115618. TIME_ELAPSED_EXT: number;
  115619. TIMESTAMP_EXT: number;
  115620. GPU_DISJOINT_EXT: number;
  115621. QUERY_RESULT_EXT: number;
  115622. QUERY_RESULT_AVAILABLE_EXT: number;
  115623. queryCounterEXT(query: WebGLQuery, target: number): void;
  115624. createQueryEXT(): WebGLQuery;
  115625. beginQueryEXT(target: number, query: WebGLQuery): void;
  115626. endQueryEXT(target: number): void;
  115627. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115628. deleteQueryEXT(query: WebGLQuery): void;
  115629. }
  115630. interface WebGLUniformLocation {
  115631. _currentState: any;
  115632. }
  115633. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115634. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115635. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115636. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115637. interface WebGLRenderingContext {
  115638. readonly RASTERIZER_DISCARD: number;
  115639. readonly DEPTH_COMPONENT24: number;
  115640. readonly TEXTURE_3D: number;
  115641. readonly TEXTURE_2D_ARRAY: number;
  115642. readonly TEXTURE_COMPARE_FUNC: number;
  115643. readonly TEXTURE_COMPARE_MODE: number;
  115644. readonly COMPARE_REF_TO_TEXTURE: number;
  115645. readonly TEXTURE_WRAP_R: number;
  115646. readonly HALF_FLOAT: number;
  115647. readonly RGB8: number;
  115648. readonly RED_INTEGER: number;
  115649. readonly RG_INTEGER: number;
  115650. readonly RGB_INTEGER: number;
  115651. readonly RGBA_INTEGER: number;
  115652. readonly R8_SNORM: number;
  115653. readonly RG8_SNORM: number;
  115654. readonly RGB8_SNORM: number;
  115655. readonly RGBA8_SNORM: number;
  115656. readonly R8I: number;
  115657. readonly RG8I: number;
  115658. readonly RGB8I: number;
  115659. readonly RGBA8I: number;
  115660. readonly R8UI: number;
  115661. readonly RG8UI: number;
  115662. readonly RGB8UI: number;
  115663. readonly RGBA8UI: number;
  115664. readonly R16I: number;
  115665. readonly RG16I: number;
  115666. readonly RGB16I: number;
  115667. readonly RGBA16I: number;
  115668. readonly R16UI: number;
  115669. readonly RG16UI: number;
  115670. readonly RGB16UI: number;
  115671. readonly RGBA16UI: number;
  115672. readonly R32I: number;
  115673. readonly RG32I: number;
  115674. readonly RGB32I: number;
  115675. readonly RGBA32I: number;
  115676. readonly R32UI: number;
  115677. readonly RG32UI: number;
  115678. readonly RGB32UI: number;
  115679. readonly RGBA32UI: number;
  115680. readonly RGB10_A2UI: number;
  115681. readonly R11F_G11F_B10F: number;
  115682. readonly RGB9_E5: number;
  115683. readonly RGB10_A2: number;
  115684. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115685. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115686. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115687. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115688. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115689. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115690. 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;
  115691. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115692. readonly TRANSFORM_FEEDBACK: number;
  115693. readonly INTERLEAVED_ATTRIBS: number;
  115694. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115695. createTransformFeedback(): WebGLTransformFeedback;
  115696. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115697. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115698. beginTransformFeedback(primitiveMode: number): void;
  115699. endTransformFeedback(): void;
  115700. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115701. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115702. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115703. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115704. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115705. }
  115706. interface ImageBitmap {
  115707. readonly width: number;
  115708. readonly height: number;
  115709. close(): void;
  115710. }
  115711. interface WebGLQuery extends WebGLObject {
  115712. }
  115713. declare var WebGLQuery: {
  115714. prototype: WebGLQuery;
  115715. new(): WebGLQuery;
  115716. };
  115717. interface WebGLSampler extends WebGLObject {
  115718. }
  115719. declare var WebGLSampler: {
  115720. prototype: WebGLSampler;
  115721. new(): WebGLSampler;
  115722. };
  115723. interface WebGLSync extends WebGLObject {
  115724. }
  115725. declare var WebGLSync: {
  115726. prototype: WebGLSync;
  115727. new(): WebGLSync;
  115728. };
  115729. interface WebGLTransformFeedback extends WebGLObject {
  115730. }
  115731. declare var WebGLTransformFeedback: {
  115732. prototype: WebGLTransformFeedback;
  115733. new(): WebGLTransformFeedback;
  115734. };
  115735. interface WebGLVertexArrayObject extends WebGLObject {
  115736. }
  115737. declare var WebGLVertexArrayObject: {
  115738. prototype: WebGLVertexArrayObject;
  115739. new(): WebGLVertexArrayObject;
  115740. };
  115741. // Type definitions for WebVR API
  115742. // Project: https://w3c.github.io/webvr/
  115743. // Definitions by: six a <https://github.com/lostfictions>
  115744. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115745. interface VRDisplay extends EventTarget {
  115746. /**
  115747. * Dictionary of capabilities describing the VRDisplay.
  115748. */
  115749. readonly capabilities: VRDisplayCapabilities;
  115750. /**
  115751. * z-depth defining the far plane of the eye view frustum
  115752. * enables mapping of values in the render target depth
  115753. * attachment to scene coordinates. Initially set to 10000.0.
  115754. */
  115755. depthFar: number;
  115756. /**
  115757. * z-depth defining the near plane of the eye view frustum
  115758. * enables mapping of values in the render target depth
  115759. * attachment to scene coordinates. Initially set to 0.01.
  115760. */
  115761. depthNear: number;
  115762. /**
  115763. * An identifier for this distinct VRDisplay. Used as an
  115764. * association point in the Gamepad API.
  115765. */
  115766. readonly displayId: number;
  115767. /**
  115768. * A display name, a user-readable name identifying it.
  115769. */
  115770. readonly displayName: string;
  115771. readonly isConnected: boolean;
  115772. readonly isPresenting: boolean;
  115773. /**
  115774. * If this VRDisplay supports room-scale experiences, the optional
  115775. * stage attribute contains details on the room-scale parameters.
  115776. */
  115777. readonly stageParameters: VRStageParameters | null;
  115778. /**
  115779. * Passing the value returned by `requestAnimationFrame` to
  115780. * `cancelAnimationFrame` will unregister the callback.
  115781. * @param handle Define the hanle of the request to cancel
  115782. */
  115783. cancelAnimationFrame(handle: number): void;
  115784. /**
  115785. * Stops presenting to the VRDisplay.
  115786. * @returns a promise to know when it stopped
  115787. */
  115788. exitPresent(): Promise<void>;
  115789. /**
  115790. * Return the current VREyeParameters for the given eye.
  115791. * @param whichEye Define the eye we want the parameter for
  115792. * @returns the eye parameters
  115793. */
  115794. getEyeParameters(whichEye: string): VREyeParameters;
  115795. /**
  115796. * Populates the passed VRFrameData with the information required to render
  115797. * the current frame.
  115798. * @param frameData Define the data structure to populate
  115799. * @returns true if ok otherwise false
  115800. */
  115801. getFrameData(frameData: VRFrameData): boolean;
  115802. /**
  115803. * Get the layers currently being presented.
  115804. * @returns the list of VR layers
  115805. */
  115806. getLayers(): VRLayer[];
  115807. /**
  115808. * Return a VRPose containing the future predicted pose of the VRDisplay
  115809. * when the current frame will be presented. The value returned will not
  115810. * change until JavaScript has returned control to the browser.
  115811. *
  115812. * The VRPose will contain the position, orientation, velocity,
  115813. * and acceleration of each of these properties.
  115814. * @returns the pose object
  115815. */
  115816. getPose(): VRPose;
  115817. /**
  115818. * Return the current instantaneous pose of the VRDisplay, with no
  115819. * prediction applied.
  115820. * @returns the current instantaneous pose
  115821. */
  115822. getImmediatePose(): VRPose;
  115823. /**
  115824. * The callback passed to `requestAnimationFrame` will be called
  115825. * any time a new frame should be rendered. When the VRDisplay is
  115826. * presenting the callback will be called at the native refresh
  115827. * rate of the HMD. When not presenting this function acts
  115828. * identically to how window.requestAnimationFrame acts. Content should
  115829. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115830. * asynchronously from other displays and at differing refresh rates.
  115831. * @param callback Define the eaction to run next frame
  115832. * @returns the request handle it
  115833. */
  115834. requestAnimationFrame(callback: FrameRequestCallback): number;
  115835. /**
  115836. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115837. * Repeat calls while already presenting will update the VRLayers being displayed.
  115838. * @param layers Define the list of layer to present
  115839. * @returns a promise to know when the request has been fulfilled
  115840. */
  115841. requestPresent(layers: VRLayer[]): Promise<void>;
  115842. /**
  115843. * Reset the pose for this display, treating its current position and
  115844. * orientation as the "origin/zero" values. VRPose.position,
  115845. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115846. * updated when calling resetPose(). This should be called in only
  115847. * sitting-space experiences.
  115848. */
  115849. resetPose(): void;
  115850. /**
  115851. * The VRLayer provided to the VRDisplay will be captured and presented
  115852. * in the HMD. Calling this function has the same effect on the source
  115853. * canvas as any other operation that uses its source image, and canvases
  115854. * created without preserveDrawingBuffer set to true will be cleared.
  115855. * @param pose Define the pose to submit
  115856. */
  115857. submitFrame(pose?: VRPose): void;
  115858. }
  115859. declare var VRDisplay: {
  115860. prototype: VRDisplay;
  115861. new(): VRDisplay;
  115862. };
  115863. interface VRLayer {
  115864. leftBounds?: number[] | Float32Array | null;
  115865. rightBounds?: number[] | Float32Array | null;
  115866. source?: HTMLCanvasElement | null;
  115867. }
  115868. interface VRDisplayCapabilities {
  115869. readonly canPresent: boolean;
  115870. readonly hasExternalDisplay: boolean;
  115871. readonly hasOrientation: boolean;
  115872. readonly hasPosition: boolean;
  115873. readonly maxLayers: number;
  115874. }
  115875. interface VREyeParameters {
  115876. /** @deprecated */
  115877. readonly fieldOfView: VRFieldOfView;
  115878. readonly offset: Float32Array;
  115879. readonly renderHeight: number;
  115880. readonly renderWidth: number;
  115881. }
  115882. interface VRFieldOfView {
  115883. readonly downDegrees: number;
  115884. readonly leftDegrees: number;
  115885. readonly rightDegrees: number;
  115886. readonly upDegrees: number;
  115887. }
  115888. interface VRFrameData {
  115889. readonly leftProjectionMatrix: Float32Array;
  115890. readonly leftViewMatrix: Float32Array;
  115891. readonly pose: VRPose;
  115892. readonly rightProjectionMatrix: Float32Array;
  115893. readonly rightViewMatrix: Float32Array;
  115894. readonly timestamp: number;
  115895. }
  115896. interface VRPose {
  115897. readonly angularAcceleration: Float32Array | null;
  115898. readonly angularVelocity: Float32Array | null;
  115899. readonly linearAcceleration: Float32Array | null;
  115900. readonly linearVelocity: Float32Array | null;
  115901. readonly orientation: Float32Array | null;
  115902. readonly position: Float32Array | null;
  115903. readonly timestamp: number;
  115904. }
  115905. interface VRStageParameters {
  115906. sittingToStandingTransform?: Float32Array;
  115907. sizeX?: number;
  115908. sizeY?: number;
  115909. }
  115910. interface Navigator {
  115911. getVRDisplays(): Promise<VRDisplay[]>;
  115912. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115913. }
  115914. interface Window {
  115915. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115916. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115917. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115918. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115919. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115920. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115921. }
  115922. interface Gamepad {
  115923. readonly displayId: number;
  115924. }
  115925. interface XRDevice {
  115926. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115927. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115928. }
  115929. interface XRSession {
  115930. getInputSources(): Array<any>;
  115931. baseLayer: XRWebGLLayer;
  115932. requestFrameOfReference(type: string): Promise<void>;
  115933. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115934. end(): Promise<void>;
  115935. requestAnimationFrame: Function;
  115936. addEventListener: Function;
  115937. }
  115938. interface XRSessionCreationOptions {
  115939. outputContext?: WebGLRenderingContext | null;
  115940. immersive?: boolean;
  115941. environmentIntegration?: boolean;
  115942. }
  115943. interface XRLayer {
  115944. getViewport: Function;
  115945. framebufferWidth: number;
  115946. framebufferHeight: number;
  115947. }
  115948. interface XRView {
  115949. projectionMatrix: Float32Array;
  115950. }
  115951. interface XRFrame {
  115952. getDevicePose: Function;
  115953. getInputPose: Function;
  115954. views: Array<XRView>;
  115955. baseLayer: XRLayer;
  115956. }
  115957. interface XRFrameOfReference {
  115958. }
  115959. interface XRWebGLLayer extends XRLayer {
  115960. framebuffer: WebGLFramebuffer;
  115961. }
  115962. declare var XRWebGLLayer: {
  115963. prototype: XRWebGLLayer;
  115964. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115965. };